-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmonitor.js
64 lines (60 loc) · 1.96 KB
/
monitor.js
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
/**
*@author <a href="mailto:major.yezhouquan@gmail.com">Zhouquan.yezq</a>
*@description the monitor.js depend on the logging.js, that want to solve the log under ie6 etc lower browser do not show up problem.
*/
(function($) {
//the monitor constructor and config
var childWin;
var _m={
MONITOR_PAGE: "monitor.html", //this html file ,you should put together with your project file.
trunOn: false,
_openWindow: function() {
//var url = window.location.href;
var url=_m.MONITOR_PAGE;
//url = url.replace(window.location.pathname, '/' + this.MONITOR_PAGE);
childWin = window.open(url, "Monitor_", "directories=no," + "location=no," + "menubar=no," + "status=yes," + "personalbar=no," + "titlebar=yes," + "toolbar=no," + "resizable=yes," + "scrollbars=no," + "width=500," + "height=400");
window.childOpen = true;
if (childWin) {
window.focus();
}
window.onunload = this.UpdateChild;
},
UpdateChild: function() {
//if parent win close, then close the child win
if (window.childOpen == true) {
childWin.opener=null;
childWin.parentOpen = false
childWin.close();
childWin=null;
}
},
appendMessage: function(msg) {
if ( !window.childOpen) {
this._openWindow();
}
if (childWin && childWin.appendMessage) {
if (childWin.isFirstTime()) {
var memory = $.Logger().constructor.logPool;
for (var i = 0; i < memory.length; i++) {
childWin.appendMessage(memory[i]);
}
}
childWin.appendMessage(msg);
}
},
gc: function(){
childWin=null;
}
};
if($.Logger) {//if the log class exist, attend monitor to log prototype
window.childOpen = false;
var logPro=$.Logger().constructor.prototype;
logPro.monitor=_m;
$(document).keydown(function(e) {
if (e.ctrlKey && e.altKey && e.keyCode == 76) { //ctrl+alt+l
_m.trunOn = true;
_m._openWindow();
}
});
}
})(jQuery);