-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
164 lines (139 loc) · 4.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> demo </title>
<link href="css/typo.css" rel="stylesheet">
<link href="css/fekit.css" rel="stylesheet">
<style>
/*#targetPage{width: 1000px; height: 1000px;}*/
</style>
</head>
<body>
<div class="Nav">
<div class="group">
<div class="group__name">ui</div>
<div class="group__list">
<div class="group__item -active" data-path="ui">UI</div>
</div>
</div>
<div class="group">
<div class="group__name">编码解码</div>
<div class="group__list">
<div class="group__item" data-path="base64-encoder">url</div>
<div class="group__item " data-path="base64-encoder">base64</div>
<div class="group__item" data-path="base64-encoder">QRCode</div>
</div>
</div>
<div class="group">
<div class="group__name">校验</div>
<div class="group__list">
<div class="group__item" data-path="base64-encoder">JSON</div>
<div class="group__item" data-path="base64-encoder">RegExp</div>
</div>
</div>
</div>
<div class="Main">
<!-- <div class="Main__inner"> -->
<iframe id="targetPage" src="biz/base64-encoder/index.html" frameborder="0" scrolling="no" allowtransparency="true"></iframe>
<!-- </div> -->
</div>
<script>
void function(){
// gobal lib
var _ = require('lodash')
var $ = require('jquery')
var Mustache = require('mustache')
var multiline = require('multiline')
var menuJSON = require('./js/menu.json')
// gobal env
var gui = require('nw.gui');
if (process.platform === "darwin") {
var mb = new gui.Menu({type: 'menubar'});
mb.createMacBuiltin('RoboPaint', {
hideEdit: false
});
gui.Window.get().menu = mb;
}
// Menu render
renderMenu()
function renderMenu(){
var el, data, tpl
el = $('.Nav')
data = menuJSON
tpl = multiline(function(){/*!@preserve
{{#menu}}
<div class="group">
<div class="group__name">{{name}}</div>
<div class="group__list">
{{#items}}
<div class="group__item {{#default}}-active{{/default}}" data-path="{{path}}">{{name}}</div>
{{/items}}
</div>
</div>
{{/menu}}
*/console.log});
el.html(Mustache.render(tpl, data))
}
// Menu events
var $menu = $('.Nav'), $targetPage = $('#targetPage');
$menu.on('click', '[data-path]', function(e){
$menu.find('[data-path]').removeClass('-active')
var p = $(this).addClass('-active').data('path')
$targetPage.attr('src', calcPath(p))
})
$targetPage.attr('src', calcPath(getDefaultPage(menuJSON)))
function calcPath(p){
return 'biz/'+p+'/index.html'
}
function getDefaultPage(menuJSON){
var arr = []
_.each(menuJSON.menu, function (v) {
arr = arr.concat(v.items)
})
return _.find(arr, {default:true}).path
}
window.$ = $
// iframe_height_reset
window.__resetLayout = function(){
var el = $('#targetPage')[0]
return function(){
el.style.height =
el.contentWindow.document.body.offsetHeight + 'px';
}
}()
$('#targetPage').load(__resetLayout)
// var f = $('#targetPage')[0]
// var e = f.contentWindow.document.getElementById('out')
// window.f = f
// window.e = e
// e.on('DOMSubtreeModified', function(e){
// alert(1)
// }, false)
// $(f.contentWindow).on('click', function(e){
// console.log(1)
// })
}()
</script>
<!-- dev relaod -->
<script>
var gulp = require('gulp');
gulp.task('reload', function () {
// if (location) location.reload();
});
gulp.watch(['*.html', 'js/**', 'img/**', 'css/**', 'biz/**'], function(event){
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...')
// cleanCache(event.path)
});
function cleanCache(modulePath) {
var module = require.cache[modulePath];
// remove reference in module.parent
if (module.parent) {
module.parent.children.splice(module.parent.children.indexOf(module), 1);
}
require.cache[modulePath] = null;
}
</script>
</body>
</html>