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
165
166
167
168
169
170
171
|
/*
* jason - Javascript based skin for xxv
* Copyright(c) 2008-2012, anbr
*
* http://projects.vdr-developer.org/projects/xxv
*
*/
Ext.xxv.MonitorWindow = function() {
this.UpdateRate = 2;
this.UpdateRateInv = [1000,2000,5000,10000,15000,30000,60000];
// '<img id="monitor_img" src="?cmd=gdisplay&width={width}&height={height}&_dc={random}" width="{width}" height="{height}" />'
var tpl = new Ext.XTemplate(
'<img id="monitor_img" style="background:black" src="extjs/resources/images/default/s.gif" width="{width}" height="{height}" />'
);
var width = configuration.monitorWidth;
var height = configuration.monitorHeight;
if(Ext.state.Manager.getProvider()) {
var monitorwin = Ext.state.Manager.get('monitor-win');
if(monitorwin && monitorwin.width && monitorwin.width >= 160 && monitorwin.width <= 4096) {
width = monitorwin.width;
}
if(monitorwin && monitorwin.height && monitorwin.height >= 120 && monitorwin.height <= 2048) {
height = monitorwin.height;
}
}
var marginHeight = 33;
var marginWidth = 16;
Ext.xxv.MonitorWindow.superclass.constructor.call(this, {
title: this.szTitle
,monitortpl:tpl
,iconCls: 'monitor-icon'
,id: 'monitor-win'
,minWidth: 160
,minHeight: 120
,marginWidth: marginWidth
,marginHeight: marginHeight
,width: width
,height: height
,resizable: true
,plain: true
,modal: false
,autoScroll: false
,closeAction: 'hide'
,maximizable: true
,tools:[
{id:'gear', handler:this.aspect, scope:this, qtip:this.szAspect }
,{id:'plus', handler:this.upFast, scope:this, qtip:this.szUpdateFast }
,{id:'refresh',handler:this.update, scope:this, qtip:this.szUpdate }
,{id:'minus', handler:this.upSlow, scope:this, qtip:this.szUpdateSlow }
]
,items: [{
id: 'monitor'
,region: 'center'
,width: width - marginWidth
,height: height - marginHeight
,html: tpl.apply({
width : width - marginWidth,
height : height - marginHeight
})
}]
});
Ext.xxv.MonitorWindow.superclass.show.apply(this, arguments);
this.on('resize', this.onresize, this);
this.update();
};
Ext.extend(Ext.xxv.MonitorWindow, Ext.Window, {
szTitle : "Monitor"
,szAspect : "Restore aspect ratio correctly"
,szUpdate : "Update monitor"
,szUpdateFast : "Faster update monitor"
,szUpdateSlow : "Slower update monitor"
,aspect : function() {
var size = this.getSize();
this.setSize(size.width, Math.round((size.width * 3) / 4));
}
,onresize : function(window, width, height ){
width -= this.marginWidth;
height -= this.marginHeight;
var monitor = Ext.getCmp('monitor');
monitor.setWidth(width);
monitor.setHeight(height);
var style = {width:width+"px",height:height+"px"};
Ext.DomHelper.applyStyles('monitor_img', style);
}
,hide : function(){
if(this.timer) {
clearTimeout(this.timer);
delete this.timer;
}
Ext.xxv.MonitorWindow.superclass.hide.apply(this, arguments);
}
,upFast : function(){
if(this.UpdateRate > 0) {
this.UpdateRate -= 1;
this.update();
//var tool = Ext.getCmp(this.tools.minus.id);
//tool.enable();
} /*else {
//var tool = Ext.getCmp(this.tools.plus.id);
//tool.disable();
} */
}
,upSlow : function(){
if(this.UpdateRate < this.UpdateRateInv.length) {
this.UpdateRate += 1;
this.update();
//var tool = Ext.getCmp(this.tools.plus.id);
//tool.enable();
} /*else {
//var tool = Ext.getCmp(this.tools.minus.id);
//tool.disable();
} */
}
,update : function(){
var monitor = Ext.getCmp('monitor');
if(!monitor || this.hidden) {
return;
}
var size = monitor.getSize();
if(!size) {
return;
}
var img = Ext.get('monitor_img');
if(!img) {
return;
}
img.un('load', this.onupdate , this);
img.on('load', this.onupdate , this);
//img.hide();
img.dom.src = XXV.help.cmdHTML('gdisplay', {
'width': size.width
,'height': size.height
,'_dc': (new Date().getTime())
,'__vdr': XXV.menu.host });
}
,onupdate : function(){
if(this.timer) {
clearTimeout(this.timer);
delete this.timer;
}
this.timer = setTimeout(function(){
Ext.getCmp('monitor-win').update();
}, this.UpdateRateInv[this.UpdateRate]);
}
});
Ext.xxv.MonitorWindowOpen = function(){
var viewer = Ext.getCmp('main-tabs');
if(!viewer.monitor){
viewer.monitor = new Ext.xxv.MonitorWindow();
} else {
viewer.monitor.show();
viewer.monitor.update();
}
};
|