efront 3.5.5 → 3.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,3 +2,4 @@
2
2
  login: options /::login-:a
3
3
  run: options /:::run
4
4
  share: options /::share-:opt
5
+ folder: options /::file-:opt:::path?:to
@@ -1,5 +1,6 @@
1
1
  首页: /home/welcome
2
2
  共享目录管理: /share/list
3
3
  短链接: /home/short
4
+ WEB文件管理: /wow/root
4
5
  # 用户: /home/short
5
6
  # 用户列表: /user/list
@@ -0,0 +1,10 @@
1
+ <div head>
2
+ <span v-text="origin?'修改':'添加'"></span>文件夹
3
+ </div>
4
+ <div body>
5
+ <field v-if="!f.readonly||!!data[f.key]" -repeat="f in fields" ng-src="[f,data]"></field>
6
+ </div>
7
+ <div foot>
8
+ <btn @click="remove()" class="white">取消</btn>
9
+ <button type="submit">保存</button>
10
+ </div>
@@ -0,0 +1,33 @@
1
+ var fields = refilm`
2
+ &原始名称/origin read
3
+ 输入新名称/name input
4
+ `;
5
+ function main({ path: root, name }) {
6
+ var a = view();
7
+ a.innerHTML = edit;
8
+ drag.on(a.firstChild, a);
9
+ var origin = name.replace(/\/$/, '');
10
+ renderWithDefaults(a, {
11
+ fields,
12
+ pathlist: root,
13
+ isFolder: /\/$/.test(name),
14
+ data: { name: origin, origin },
15
+ remove() {
16
+ remove(a);
17
+ },
18
+ });
19
+ on('submit')(a, async function (e) {
20
+ e.preventDefault();
21
+ var path = root.concat(a.$scope.data.name).join('/');
22
+ if (origin) {
23
+ var to = path;
24
+ path = origin;
25
+ }
26
+ await data.from("folder", { opt: origin ? 'mov' : 'add', path, to }).loading_promise;
27
+ dispatch(this, 'submited');
28
+ });
29
+ on("append")(a, lazy(function () {
30
+ a.querySelector("input").focus();
31
+ }));
32
+ return a;
33
+ }
@@ -0,0 +1,10 @@
1
+ <div class="address">
2
+ <input _value="pathlist.join('/')" />
3
+ </div>
4
+ <lattice ng-src="d in data">
5
+ <padding>
6
+ <item @click="open(d)" ng-class="{focus:active===this}">
7
+ <span ng-text=d.name></span>
8
+ </item>
9
+ </padding>
10
+ </lattice>
@@ -0,0 +1,100 @@
1
+ var fields = refilm`
2
+ 文件
3
+ `;
4
+
5
+ function main() {
6
+ var page = div();
7
+ page.innerHTML = root;
8
+ page.onback = function () {
9
+ var $scope = this.$scope;
10
+ if (!$scope.pathlist.length) {
11
+ return;
12
+ }
13
+ $scope.pathlist.pop();
14
+ $scope.open();
15
+ return false;
16
+ }
17
+ page.setAttribute('ng-mousedown', 'setActive')
18
+
19
+ renderWithDefaults(page, {
20
+ lattice,
21
+ pathlist: [],
22
+ active: null,
23
+ open(p) {
24
+ if (p) p = String(p.name || '').replace(/\/$/, '');
25
+ if (p) this.pathlist.push(p);
26
+ this.data = data.from("folder", { opt: 'list', path: "/" + this.pathlist.join('/') }, files => {
27
+ if (files) return files.map(f => {
28
+ return {
29
+ name: f,
30
+ type: /\/$/.test(f) ? 'folder' : 'file'
31
+ }
32
+ });
33
+ });
34
+ },
35
+ setActive(e) {
36
+ this.active = getActive(e);
37
+ },
38
+ data: [],
39
+ });
40
+ page.$scope.open();
41
+ var getActive = e => {
42
+ var p = page.querySelector('lattice');
43
+ var t = getTargetIn(e => e.parentNode && e.parentNode.parentNode === p, e.target);
44
+ return t;
45
+ };
46
+ var when = e => !!getActive(e);
47
+ var popupEdit = function (e) {
48
+ zimoli.prepare('/wow/edit', function () {
49
+ var p = popup("#/wow/edit", {
50
+ path: page.$scope.pathlist,
51
+ name: e || ''
52
+ });
53
+ on('submited')(p, function () {
54
+ page.$scope.open();
55
+ remove(p);
56
+ });
57
+ })
58
+
59
+ };
60
+ contextmenu(page, [
61
+ {
62
+ name: "新建文件夹",
63
+ when: e => !getActive(e),
64
+ do() {
65
+ popupEdit();
66
+ }
67
+ },
68
+ {
69
+ name: '编辑',
70
+ when,
71
+ do(e) {
72
+ popupEdit(e.$scope.d.name);
73
+ }
74
+ },
75
+ {
76
+ get name() {
77
+ return this.confirm ? "确认删除" : "删除";
78
+ },
79
+ confirm: false,
80
+ when(e) {
81
+ this.confirm = false;
82
+ return when(e);
83
+ },
84
+ type: "danger",
85
+ async do(e) {
86
+ if (!this.confirm) {
87
+ this.confirm = true;
88
+ setTimeout(_ => {
89
+ this.confirm = false;
90
+ render.refresh();
91
+ }, 2000);
92
+ return false;
93
+ }
94
+ await data.from("folder", { opt: 'del', path: "/" + page.$scope.pathlist.concat(e.$scope.d.name).join("/") }).loading_promise;
95
+ page.$scope.open();
96
+ }
97
+ }
98
+ ]);
99
+ return page;
100
+ }
@@ -0,0 +1,63 @@
1
+ & {
2
+ height: 100%;
3
+ }
4
+
5
+ @height: 44px;
6
+
7
+ >lattice {
8
+ box-sizing: content-box;
9
+ margin-top: -@height;
10
+ padding-top: @height + 6px;
11
+
12
+ a {
13
+ vertical-align: top;
14
+ }
15
+ }
16
+
17
+ padding {
18
+ border-right-width: 60px;
19
+ }
20
+
21
+ >.address {
22
+ position: relative;
23
+ z-index: 3;
24
+ margin-left: 140px;
25
+ margin-top: -@height - 6px;
26
+ height: @height;
27
+ padding: 0 6px;
28
+ line-height: @height;
29
+
30
+ input {
31
+ width: 100%;
32
+ }
33
+ }
34
+
35
+ item {
36
+ border: 1px solid #0002;
37
+ position: relative;
38
+ display: block;
39
+ padding: 10px 20px;
40
+
41
+ &:hover {
42
+ outline: 2px solid #2cf;
43
+ }
44
+
45
+ &:active {
46
+ color: #28c;
47
+ outline: 2px solid;
48
+ }
49
+
50
+ &.focus {
51
+ color: #28c;
52
+ outline: 2px solid;
53
+ }
54
+
55
+ >a {
56
+ vertical-align: top;
57
+ }
58
+
59
+ >[op] {
60
+ left: 6px;
61
+ margin-left: 6px;
62
+ }
63
+ }
@@ -1,5 +1,5 @@
1
- // -------/// ---------------1-------------//////////////2---3--------//////// ----4----2/////5-----------------------6------------------------//////////////-7--5///8----9----//10--11---10///--12-----8//
2
- var reg = /^([^\:\/\?#]+\:(?![^\:\/\?\#]*@))?(?:\/\/)?(?:(([^\:\/\?#]+)?(?:\:([^\/\?#]+))?)@)?(([^\/@\:\?\#]*(?:[^\d\@\:\/\?#]|\.)[^\/@\:\?\#]*)?(?:(?:\:|^)(\d+))?)((\/[^\?#]*)?(\?([^#]*))?(#[\s\S]*)?)$/;
1
+ // -------/// ---------------1-------------//////////////2---3--------//////// ----4----2/////5-----------------------6-----------------------//////////////-7--5///8----9----//10--11---10///--12-----8//
2
+ var reg = /^([^\:\/\?#\[]+\:(?![^\:\/\?\#]*@))?(?:\/\/)?(?:(([^\:\/\?#]+)?(?:\:([^\/\?#]+))?)@)?(([^\/@\:\?\#]*(?:[^\d\@\:\/\?#]|\.)[^\/@\?\#]*?)?(?:(?:\:|^)(\d+))?)((\/[^\?#]*)?(\?([^#]*))?(#[\s\S]*)?)$/;
3
3
  function parseURL(url) {
4
4
  if (url === undefined || url === null) url = '';
5
5
  var [__, protocol, auth, username, password, host, hostname, port, path, pathname, search, query, hash] = reg.exec(url);
@@ -30,3 +30,10 @@ test('?80', 'path', '?80')
30
30
  test('?80', 'search', '?80')
31
31
  test('?80', 'query', '80')
32
32
  test('#?80', 'hash', '#?80')
33
+ test("http://[fe80::caa:a647:ef1d:b4db]/", "host", "[fe80::caa:a647:ef1d:b4db]")
34
+ test("http://[::1]/", "host", "[::1]")
35
+ test("http://[::]/", "host", "[::]")
36
+ test("http://[::%12]/", "host", "[::%12]")
37
+ test("http://[::]:80/", "hostname", "[::]")
38
+ test("[::]:80/", "hostname", "[::]")
39
+ test("[fd64:f52:f52:f52:f52:f52:f52:97]", "hostname", "[fd64:f52:f52:f52:f52:f52:f52:97]")
@@ -260,16 +260,31 @@ function parse(piece) {
260
260
  }
261
261
  var [name, type, options] = piece, key, repeat;
262
262
  if (piece.length === 1 && isObject(name)) {
263
- var { name, needs, required, checks, type, key, size, unit, endwith, ratio, value, repeat, comment, options } = name;
263
+ var {
264
+ name, type, key, value, comment, options,
265
+ size, unit, ratio,
266
+ needs, checks, repeat, endwith,
267
+ required, inlist, hidden, readonly,
268
+ delete_onempty, delete_onsubmit,
269
+ } = name;
264
270
  } else {
265
- var is_require = a => {
266
- if (/^\*|\*$/.test(a)) {
267
- required = true;
268
- return a.replace(/^\*|\*$/, '');
271
+ var test = (reg,a) => {
272
+ if (reg.test(a)) {
273
+ return true;
269
274
  }
270
- return a;
271
275
  };
272
- type = is_require(type);
276
+ var is = function (a) {
277
+ var reg = /^[\*\+\-\!\-\$&\?\~]|[\*\+\-\!\-\$&\?\~]$/;
278
+ if (!reg.test(a)) return a;
279
+ required = test(/^\*|\*$/, a);
280
+ inlist = test(/^[\+\!]|[\+\!]$/, a);
281
+ hidden = test(/^\-|\-$/, a);
282
+ readonly = test(/^[\$&]|[\$&]$/, a);
283
+ delete_onempty = test(/^\?|\?$/, a);
284
+ delete_onsubmit = test(/^\~|\~$/, a);
285
+ return a.replace(reg, '');
286
+ };
287
+ type = is(type);
273
288
  if (typeof name === 'string') {
274
289
  if (!isContainer) {
275
290
  if (!type) {
@@ -370,17 +385,23 @@ function parse(piece) {
370
385
  type = type.slice(1);
371
386
  }
372
387
  if (typeof options === "string") {
373
- options = is_require(options);
388
+ options = is(options);
374
389
  var needUnfold = /^\[|\]$/.test(options);
375
390
  options = options.replace(/^\[|\]$/g, '');
376
391
  if (/,/.test(options)) options = scanSlant(options, ',');
377
392
  else options = scanSlant(options, "");
378
393
  if (needUnfold) unfoldOptions(size, options);
379
394
  }
380
- name = is_require(name);
381
- key = is_require(key);
395
+ name = is(name);
396
+ key = is(key);
382
397
  }
383
- var field = { name, checks, required, needs, type, key, size, unit, endwith, ratio, value, repeat, comment, options };
398
+ var field = {
399
+ name, type, key, value, comment, options,
400
+ size, unit, ratio,
401
+ needs, checks, repeat, endwith,
402
+ required, inlist, hidden, readonly,
403
+ delete_onempty, delete_onsubmit,
404
+ };
384
405
  var parent = piecepath[piecepath.length - 1];
385
406
  if (parent) {
386
407
  field.parent = parent;
@@ -0,0 +1,60 @@
1
+ var prime = [2, 3];
2
+ var updatePrime = function (m) {
3
+ var n = prime[prime.length - 1];
4
+ var i = 1;
5
+ a: while (n < m) {
6
+ n += 2;
7
+ if (prime[i] * prime[i] < n) i++;
8
+ for (var cx = 0, dx = i + 1; cx < dx; cx++) {
9
+ if (n % prime[cx] === 0) continue a;
10
+ }
11
+ prime.push(n);
12
+ }
13
+ }
14
+ var isPrime = function (s) {
15
+ var n = Math.sqrt(Number(s));
16
+ s = BigInt(s);
17
+ if (n > prime[prime.length - 1]) updatePrime(n);
18
+ for (var cx = 0; prime[cx] < n; cx++)if (s % BigInt(prime[cx]) === 0n) return false;
19
+ return true;
20
+ };
21
+ prime.isPrime = isPrime;
22
+ prime.find = function (start, delta, end) {
23
+ var isBigInt = typeof start === 'bigint' || typeof end === 'bigint';
24
+ var n = [0, 1, 2];
25
+ if (isBigInt) {
26
+ start = BigInt(start);
27
+ delta = BigInt(delta);
28
+ n = n.map(BigInt);
29
+ } else {
30
+ start = Number(start);
31
+ delta = Number(delta);
32
+ }
33
+ if (!(delta > n[0]) && !(delta < n[0])) {
34
+ return isPrime(start);
35
+ }
36
+ if (delta != n[1] && delta != -n[1] && start % delta == n[0]) {
37
+ return null;
38
+ }
39
+
40
+ if (delta % n[1]) return null;
41
+ if (start % n[2] === n[0]) {
42
+ start += delta > n[0] ? n[1] : -n[1];
43
+ }
44
+ if (delta === n[1] || delta === -n[1]) {
45
+ delta *= n[2];
46
+ }
47
+ if (end) {
48
+ var res = [];
49
+ if (isBigInt) end = BigInt(end);
50
+ else end = Number(end);
51
+ for (var cx = start, dx = end + n[1], ex = delta; ex > n[0] ? cx < dx : cx > dx; cx += ex) {
52
+ if (isPrime(cx)) res.push(cx);
53
+ }
54
+ } else {
55
+ while (!isPrime(start)) start += delta;
56
+ var res = start;
57
+ }
58
+ return res;
59
+
60
+ };
@@ -0,0 +1,10 @@
1
+ var test = function (a, b, c) {
2
+ var start = new Date;
3
+ prime.find(a, b, c)
4
+ var end = new Date;
5
+ console.log(a, b, c, '用时', end - start);
6
+ }
7
+ test(19000000n, 1, 21000000n);
8
+ test(19000000, 1, 21000000);
9
+ test(19000000, 1, 21000000);
10
+ test(19000000n, 1, 21000000n);
@@ -1,15 +1,15 @@
1
1
  <div class="menu-items">
2
2
  <btn class="menu-item menu-switch" ng-click=switchMenu()>
3
- <i class="fa fa-bars"></i>
3
+
4
4
  </btn>
5
5
  <btn ng-if="fullscreen.is()" ng-click="fullscreen.exit(alert)" class="menu-switch menu-item">
6
- <i class="fa fa-compress"></i>
6
+
7
7
  </btn>
8
8
  <btn ng-if="fullscreen.allow&&!fullscreen.is()" ng-click=fullscreen.exec() class="menu-switch menu-item">
9
- <i class="fa fa-expand"></i>
9
+
10
10
  </btn>
11
- <btn class="menu-item menu-switch" ng-click="route.reload()">
12
- <i class="fa fa-refresh" ng-class="{'fa-pulse':data.loading_count>0}"></i>
11
+ <btn class="menu-item menu-switch" ng-class="{'load':data.loading_count>0}" ng-click="route.reload()">
12
+
13
13
  </btn>
14
14
  <btn class="menu-item" @title="option.name" ng-click="open(option)" ng-repeat="option in options" pop>
15
15
  <i class="fa" ng-class="option.icon"></i>
@@ -166,4 +166,26 @@
166
166
  width: 50px;
167
167
  margin: 5px;
168
168
  }
169
+ }
170
+
171
+ btn {
172
+ vertical-align: top;
173
+ }
174
+ @keyframes rotate {
175
+ 0%{
176
+ transform: rotate(0deg);
177
+ }
178
+ 50%{
179
+ transform: rotate(240deg);
180
+ }
181
+ 100%{
182
+ transform: rotate(360deg);
183
+ }
184
+ }
185
+ .load{
186
+ >.label{
187
+ display: inline-block;
188
+ animation: rotate 1s infinite;
189
+ }
190
+
169
191
  }
@@ -3,8 +3,7 @@ function main(config, item, params) {
3
3
  if (!config) return ok();
4
4
  if (isObject(config)) {
5
5
  if (config.do instanceof Function) {
6
- config.do();
7
- return;
6
+ return ok(config.do(item, params));
8
7
  }
9
8
  if (config.modal) {
10
9
  var path = isString(config.modal) ? config.modal : config.modal.path;
@@ -337,7 +337,7 @@ function addhook() {
337
337
  }
338
338
  if (!mousedownEvent) return;
339
339
  var target = targetElement || mousedownEvent.currentTarget;
340
- hooka(function (target) {
340
+ hooka.call(targetElement, function (target) {
341
341
  var res = [].filter.call(allowdrops || (matcher ? matcher(target) : document.querySelectorAll("[allowdrop]")), function (child) {
342
342
  return target && overlap(child, target);
343
343
  }).filter(e => {
@@ -14,9 +14,9 @@
14
14
  display: inline-block;
15
15
  white-space: nowrap;
16
16
  text-align: center;
17
- // cursor: default;
18
17
  overflow: hidden;
19
18
  outline: none;
19
+ user-select: none;
20
20
  }
21
21
  >.label{
22
22
  position: relative;
@@ -177,7 +177,6 @@
177
177
 
178
178
  a&,
179
179
  &[type$=anchor] {
180
- padding: 0;
181
180
  box-shadow: none;
182
181
  text-shadow: none;
183
182
  background: none;
@@ -3,23 +3,28 @@ var createMenu = function (event, items) {
3
3
  var menulist = sampleElement.cloneNode();
4
4
  menulist.setAttribute("mode", "v");
5
5
  menulist.tabIndex = 0;
6
-
7
- var elem = menuList(menulist, items, function () {
8
- if (action.apply(this, arguments) !== false) {
6
+ items = items.filter(item => {
7
+ if (!item.when) return true;
8
+ if (!item.when(event)) return false;
9
+ return true;
10
+ });
11
+ var elem = menuList(menulist, items, async function (item) {
12
+ if (await action.call(this, item, event.target) !== false) {
9
13
  remove(elem);
10
14
  }
11
15
  });
12
16
 
13
17
  return elem;
14
18
  }
15
- function contextmenu(target, menu) {
19
+ function contextmenu(target, menuItems) {
16
20
  on("contextmenu")(target, function (event) {
17
21
  event.preventDefault();
18
- if (menu instanceof Function) {
19
- menu = menu.call(this, event);
22
+ var menu;
23
+ if (menuItems instanceof Function) {
24
+ menu = menuItems.call(this, event);
20
25
  }
21
- if (menu instanceof Array) {
22
- menu = createMenu.call(this, event, menu);
26
+ if (menuItems instanceof Array) {
27
+ menu = createMenu.call(this, event, menuItems);
23
28
  }
24
29
  if (!menu) return;
25
30
  css(menu, {
@@ -175,8 +175,8 @@ function cross(method, url, headers) {
175
175
  onerror({ status: "网络断开" });
176
176
  break;
177
177
  }
178
- if (!navigator.response) {
179
- onerror({ status: "服务器无响应" });
178
+ if (!xhr.response) {
179
+ onerror({ status: "无法访问服务器" });
180
180
  break;
181
181
  }
182
182
  case 200:
@@ -268,7 +268,7 @@ function cross(method, url, headers) {
268
268
  var then = xhr.then;
269
269
  delete xhr.then;
270
270
  if (loaded) onloads.splice(0, onloads.length).map(e => e instanceof Function && e(xhr));
271
- if (errored) onerrors.splice(0, onerrors.length).map(e => e instanceof Function && e(xhr));
271
+ if (errored) onerrors.splice(0, onerrors.length).map(e => e instanceof Function && e(errored));
272
272
  xhr.then = then;
273
273
  };
274
274
  var onloads = [], onerrors = [];
@@ -16,7 +16,7 @@ function main(elem) {
16
16
  }, false);
17
17
  elem.setAttribute("field", '');
18
18
  elem.renders = [function () {
19
- if (!this.src) return;
19
+ if (!(this.src instanceof Array)) return;
20
20
  var [f, data] = this.src;
21
21
  if (!f || !data) return;
22
22
  var v = data[f.key];
@@ -1,3 +1,4 @@
1
- <menu-item ng-repeat="menu in menus" ng-click="open(menu,event)" ng-mouseleave="clearTimeout(popTimer)"
2
- ng-mouseenter="popTimer=popMenu(menu,event)" ng-class="{'has-children':menu.children&&menu.children.length}">
1
+ <menu-item ng-repeat="menu in menus" ng-if="!menu.hidden" ng-click="open(menu,event)"
2
+ ng-mouseleave="clearTimeout(popTimer)" ng-mouseenter="popTimer=popMenu(menu,event)"
3
+ ng-class="{'has-children':menu.children&&menu.children.length,'warn':menu.type==='danger'||menu.type==='warn'||menu.type==='red'}">
3
4
  </menu-item>
@@ -1,38 +1,42 @@
1
1
  & {
2
- display : inline-block;
3
- width : auto;
4
- height : auto;
2
+ display: inline-block;
3
+ width: auto;
4
+ height: auto;
5
5
  background-color: #fff;
6
- box-shadow : 0 0 20px -6px rgba(0, 0, 0, .6);
7
- line-height : 28px;
8
- padding : 6px 0;
6
+ box-shadow: 0 0 20px -6px rgba(0, 0, 0, .1);
7
+ border: 1px solid #0003;
8
+ line-height: 28px;
9
+ padding: 6px 0;
9
10
 
10
11
  >menu-item {
11
- display : block;
12
- position : relative;
13
- padding : 0 16px;
14
- border-radius : 0;
12
+ display: block;
13
+ position: relative;
14
+ padding: 0 16px;
15
+ border-radius: 0;
15
16
  background-color: inherit;
16
- color : inherit;
17
- box-shadow : none;
18
- text-align : inherit;
17
+ color: inherit;
18
+ box-shadow: none;
19
+ text-align: inherit;
20
+ &.warn{
21
+ color: #c28;
22
+ }
19
23
 
20
24
  &.has-children {
21
25
  padding: 0 24px 0 16px;
22
26
 
23
27
  &:after {
24
- content : ">";
25
- display : block;
26
- width : 20px;
27
- height : 20px;
28
+ content: ">";
29
+ display: block;
30
+ width: 20px;
31
+ height: 20px;
28
32
  line-height: 20px;
29
- font-size : 18px;
30
- transform : scaleX(.56);
31
- position : absolute;
32
- right : 6px;
33
- top : 50%;
34
- margin-top : -10px;
35
- text-align : right;
33
+ font-size: 18px;
34
+ transform: scaleX(.56);
35
+ position: absolute;
36
+ right: 6px;
37
+ top: 50%;
38
+ margin-top: -10px;
39
+ text-align: right;
36
40
  }
37
41
  }
38
42
 
@@ -41,5 +45,5 @@
41
45
 
42
46
  i {
43
47
  display: inline-block;
44
- width : 20px;
48
+ width: 20px;
45
49
  }
@@ -142,7 +142,7 @@ function main(elem) {
142
142
  elem.setAttribute("type", field_type);
143
143
  }
144
144
  remove(elem.children);
145
- if (readonly) {
145
+ if (readonly || field.readonly) {
146
146
  if (field_type === "function") {
147
147
  field_editor(elem);
148
148
  } else {