xframelib 0.6.1 → 0.6.2
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.
- package/README.md +1 -0
- package/dist/index.cjs +8 -8
- package/dist/index.js +7 -7
- package/dist/public/WSynchro.js +67 -0
- package/dist/utils/FileUpload.d.ts +1 -1
- package/dist/utils/H5Tool.d.ts +10 -1
- package/package.json +1 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** WSynchro object to synchronize windows
|
|
2
|
+
* - windows: array of windows to synchro (
|
|
3
|
+
* - source: the window source (undefined if first window)
|
|
4
|
+
*/
|
|
5
|
+
if (!window.WSynchro) {
|
|
6
|
+
var WSynchro = { windows: [] };
|
|
7
|
+
}
|
|
8
|
+
/** Open a new window to synchronize
|
|
9
|
+
* @param {url|undefined} url to open, default current window url
|
|
10
|
+
* @param {specs|undefined|null} specs (as for window.open), undefined to open in a new window, null to open in a new tab, default new window
|
|
11
|
+
*/
|
|
12
|
+
WSynchro.open = function (href, specs)
|
|
13
|
+
{ var w = window.open (href || window.location.href, "_blank", typeof(specs)=="undefined"? "location=1,menubar=1,toolbar=1,scrollbars=1" : specs);
|
|
14
|
+
if (!w.WSynchro) w.WSynchro = { windows: [ window ], source:window };
|
|
15
|
+
else
|
|
16
|
+
{ w.WSynchro.windows = [ window ];
|
|
17
|
+
w.WSynchro.source = window;
|
|
18
|
+
}
|
|
19
|
+
this.windows.push(w);
|
|
20
|
+
}
|
|
21
|
+
/** Trigger function
|
|
22
|
+
* @param {synchronize}
|
|
23
|
+
* @param {function} synchronize function
|
|
24
|
+
*/
|
|
25
|
+
WSynchro.on = function (e, syncFn)
|
|
26
|
+
{ if (!this.syncFn_) this.syncFn_ = [];
|
|
27
|
+
if (e==='synchronize') this.syncFn_.push(syncFn);
|
|
28
|
+
}
|
|
29
|
+
/** Synchronize windows
|
|
30
|
+
* @param {Object|undefined} if undefined stop synchro (when the window is synchronize)
|
|
31
|
+
*/
|
|
32
|
+
WSynchro.synchronize = function(params)
|
|
33
|
+
{ this.synchronize_ (params);
|
|
34
|
+
}
|
|
35
|
+
/** Synchronize windows:
|
|
36
|
+
* @param {Array} array of arguments to use with fn
|
|
37
|
+
* @param {} internal syncrho time to avoid stnchro loops
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
WSynchro.synchronize_ = function(args, sync) {
|
|
41
|
+
var i;
|
|
42
|
+
// Stop condition
|
|
43
|
+
if (!sync)
|
|
44
|
+
{ if (this.synchronizing) sync = this.sync;
|
|
45
|
+
else this.sync = sync = (new Date()).getTime();
|
|
46
|
+
this.synchronizing = false;
|
|
47
|
+
}
|
|
48
|
+
else
|
|
49
|
+
{ // Don't synchronize twice
|
|
50
|
+
if (sync == this.sync) return;
|
|
51
|
+
this.sync = sync;
|
|
52
|
+
this.synchronizing = true;
|
|
53
|
+
try
|
|
54
|
+
{ if (WSynchro.syncFn_)
|
|
55
|
+
{ args.type = "synchronize";
|
|
56
|
+
for (i=0; i<WSynchro.syncFn_.length; i++)
|
|
57
|
+
{ WSynchro.syncFn_[i].apply (null, [args]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} catch(e) { /* */ }
|
|
61
|
+
}
|
|
62
|
+
if (args) for (i=0; i<this.windows.length; i++)
|
|
63
|
+
{ try
|
|
64
|
+
{ this.windows[i].WSynchro.synchronize_(args, sync);
|
|
65
|
+
} catch(e) { /* */ }
|
|
66
|
+
}
|
|
67
|
+
}
|
package/dist/utils/H5Tool.d.ts
CHANGED
|
@@ -79,7 +79,16 @@ export default class H5Tool {
|
|
|
79
79
|
* @param fileObj file对象
|
|
80
80
|
* @param handleMd5Result 处理文件MD5结果
|
|
81
81
|
*/
|
|
82
|
-
static getFileShortMD5(fileObj:
|
|
82
|
+
static getFileShortMD5(fileObj: File, handleMd5Result: (data: {
|
|
83
|
+
isOK: boolean;
|
|
84
|
+
data: string;
|
|
85
|
+
}) => void): any;
|
|
86
|
+
/**
|
|
87
|
+
* 获取文件完整的MD5摘要
|
|
88
|
+
* @param fileObj
|
|
89
|
+
* @param handleMd5Result
|
|
90
|
+
*/
|
|
91
|
+
static getFileMD5(fileObj: File, handleMd5Result: (data: {
|
|
83
92
|
isOK: boolean;
|
|
84
93
|
data: string;
|
|
85
94
|
}) => void): any;
|