remote5-gui 0.1.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/index.js +7 -0
- package/lib/wbase-0.1.2.js +207 -0
- package/lib/wlang-0.1.4.js +126 -0
- package/lib/wstyle-0.4.0.js +309 -0
- package/package.json +36 -0
package/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Remote5 wBase - 2022.11.22
|
|
3
|
+
* Author : Willy.Lee (wiljwilj@hotmail.com)
|
|
4
|
+
*/
|
|
5
|
+
// 0.1.1 - 2021.10.08 - start
|
|
6
|
+
// 0.1.2 - 2022.11.22 -
|
|
7
|
+
|
|
8
|
+
(function(){
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
var version = "0.1.2";
|
|
12
|
+
|
|
13
|
+
var w2a = {
|
|
14
|
+
q: [],
|
|
15
|
+
t: null,
|
|
16
|
+
cpct: null,
|
|
17
|
+
start: function(cap){
|
|
18
|
+
var i = this;
|
|
19
|
+
i.cpct = cap;
|
|
20
|
+
setTimeout(function(){ procW2A(i); }, 0);
|
|
21
|
+
},
|
|
22
|
+
call: function(func, args){
|
|
23
|
+
var i = this;
|
|
24
|
+
i.q.push({ f: func, a: args });
|
|
25
|
+
procW2A(i);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
function procW2A(i){
|
|
29
|
+
if (i.t != null || i.q.length <= 0 || i.cpct == null)
|
|
30
|
+
return;
|
|
31
|
+
var c = i.q.shift();
|
|
32
|
+
var a = c.a == null ? ":" : (":" + JSON.stringify(c.a).replace(/[\u007F-\uFFFF]/g, function(chr){ return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4) }));
|
|
33
|
+
var mcmd = "wBase:" + c.f + a;
|
|
34
|
+
if (typeof (i.cpct) == "function")
|
|
35
|
+
i.cpct(mcmd);
|
|
36
|
+
else if (typeof (i.cpct) == "object")
|
|
37
|
+
i.cpct.cmd(mcmd);
|
|
38
|
+
else
|
|
39
|
+
location.href = mcmd;
|
|
40
|
+
i.t = setTimeout(function () { i.t = null; procW2A(i); }, 0);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ret(id){
|
|
44
|
+
var i = this;
|
|
45
|
+
i.k = id;
|
|
46
|
+
}
|
|
47
|
+
ret.prototype = {
|
|
48
|
+
close: function(l){
|
|
49
|
+
var i = this;
|
|
50
|
+
R5.wBase.cmd.close(i.k, l);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
var cmd = {
|
|
55
|
+
l: [],
|
|
56
|
+
x: 1,
|
|
57
|
+
w2a: w2a,
|
|
58
|
+
ret: ret,
|
|
59
|
+
add: function(t, p, l){
|
|
60
|
+
var i = this;
|
|
61
|
+
var k = makeKey(i);
|
|
62
|
+
p.__ID__ = k;
|
|
63
|
+
i.l.unshift({ k: k, t: t, p: p, l: l });
|
|
64
|
+
i.w2a.call(t, p);
|
|
65
|
+
return new ret(k);
|
|
66
|
+
},
|
|
67
|
+
close: function(k, l){
|
|
68
|
+
var i = this;
|
|
69
|
+
var c = null, ix;
|
|
70
|
+
for (ix in i.l) {
|
|
71
|
+
if (i.l[ix].k == k) {
|
|
72
|
+
c = i.l[ix];
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (c) {
|
|
77
|
+
if (l)
|
|
78
|
+
c.l = l;
|
|
79
|
+
c.x = true;
|
|
80
|
+
i.w2a.call(c.t, k);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
remove: function(k){
|
|
84
|
+
var i = this;
|
|
85
|
+
for (var ix in i.l) {
|
|
86
|
+
if (i.l[ix].k == k) {
|
|
87
|
+
i.l.splice(ix, 1);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
notify: function(k, a){
|
|
93
|
+
var i = this;
|
|
94
|
+
for (var ix in i.l) {
|
|
95
|
+
if (i.l[ix].k == k) {
|
|
96
|
+
var c = i.l[ix];
|
|
97
|
+
if (c.x)
|
|
98
|
+
a.state = "closed";
|
|
99
|
+
if (c.l != undefined)
|
|
100
|
+
c.l(a);
|
|
101
|
+
if (a != null && a.state == "closed")
|
|
102
|
+
i.remove(k);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
function makeKey(i){
|
|
110
|
+
var cx = i.x;
|
|
111
|
+
do {
|
|
112
|
+
var x = cx;
|
|
113
|
+
for (var c in i.l) {
|
|
114
|
+
if (i.l[c].k == cx) {
|
|
115
|
+
cx++;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} while (x != cx);
|
|
120
|
+
i.x = cx + 1;
|
|
121
|
+
if (i.x > 0x7ffe)
|
|
122
|
+
i.x = 1;
|
|
123
|
+
return cx;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var evt = {
|
|
127
|
+
l:[],
|
|
128
|
+
add: function( t, l ){
|
|
129
|
+
var i = this;
|
|
130
|
+
i.l.unshift({t:t,l:l});
|
|
131
|
+
var ix, cnt = 0;
|
|
132
|
+
for ( ix in i.l ) { if ( i.l[ix].t == t ) cnt++; }
|
|
133
|
+
return cnt;
|
|
134
|
+
},
|
|
135
|
+
remove: function( t, l ){
|
|
136
|
+
var i = this;
|
|
137
|
+
var ix, cnt = 0;
|
|
138
|
+
for ( ix in i.l ) {
|
|
139
|
+
if ( i.l[ix].t == t && i.l[ix].l == l ) {
|
|
140
|
+
i.l.splice(ix, 1);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for ( ix in i.l ) {
|
|
145
|
+
if ( i.l[ix].t == t )
|
|
146
|
+
cnt++;
|
|
147
|
+
}
|
|
148
|
+
return cnt;
|
|
149
|
+
},
|
|
150
|
+
evt_lastest_state:null,
|
|
151
|
+
event: function( t, a ){
|
|
152
|
+
var i = this;
|
|
153
|
+
if ( t == "state" )
|
|
154
|
+
{
|
|
155
|
+
if ( a.state == 'start' || a.state == 'resume' || a.state == 'pause' || a.state == 'stop' )
|
|
156
|
+
i.evt_lastest_state = a;
|
|
157
|
+
else
|
|
158
|
+
{
|
|
159
|
+
if ( i.evt_lastest_state == null )
|
|
160
|
+
i.evt_lastest_state = {};
|
|
161
|
+
for ( var ak in a )
|
|
162
|
+
if ( ak != 'state' )
|
|
163
|
+
i.evt_lastest_state[ak] = a[ak];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for ( var ix in i.l ) {
|
|
167
|
+
if ( i.l[ix].t == t ) {
|
|
168
|
+
if ( i.l[ix].l(a, t) )
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
var R5;
|
|
176
|
+
if (typeof exports != 'undefined')
|
|
177
|
+
R5 = exports.R5 ? exports.R5 : (exports.R5 = {});
|
|
178
|
+
else
|
|
179
|
+
R5 = window.R5 ? window.R5 : (window.R5 = {});
|
|
180
|
+
|
|
181
|
+
R5.wBase = {
|
|
182
|
+
w2a: w2a,
|
|
183
|
+
cmd: cmd,
|
|
184
|
+
evt: evt,
|
|
185
|
+
|
|
186
|
+
version: version
|
|
187
|
+
};
|
|
188
|
+
// command( cmd, params, listener )
|
|
189
|
+
// cmd: command
|
|
190
|
+
R5.command = function(cmd, params, listener){
|
|
191
|
+
return R5.wBase.cmd.add(cmd, params, listener);
|
|
192
|
+
}
|
|
193
|
+
// addEventListener( type, listener )
|
|
194
|
+
// type: keyBack, starting, ...
|
|
195
|
+
R5.addEventListener = function( type, listener ){
|
|
196
|
+
if ( R5.wBase.evt.add(type, listener) == 1 )
|
|
197
|
+
R5.wBase.w2a.call("event", {type:type,use:true});
|
|
198
|
+
}
|
|
199
|
+
R5.removeEventListener = function( type, listener ){
|
|
200
|
+
if ( R5.wBase.evt.remove(type, listener) == 0 )
|
|
201
|
+
R5.wBase.w2a.call("event", {type:type,use:false});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
R5.exitApp = function(){
|
|
205
|
+
R5.command("EXIT_APP", {});
|
|
206
|
+
}
|
|
207
|
+
})();
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Remote5 wLanguages - 2023.11.03~
|
|
3
|
+
* Author : Willy.Lee (wiljwilj@hotmail.com)
|
|
4
|
+
*/
|
|
5
|
+
// 0.1.1 - 2023.11.03
|
|
6
|
+
// 0.1.3 - 2025.05.05 loading default lang-json
|
|
7
|
+
// 0.1.4 - 2026.02.13 syntex error fixed
|
|
8
|
+
|
|
9
|
+
(function(){
|
|
10
|
+
"use strict";
|
|
11
|
+
|
|
12
|
+
var version = "0.1.3";
|
|
13
|
+
|
|
14
|
+
function wl( defaultLang, cb ) {
|
|
15
|
+
var i = this;
|
|
16
|
+
if (typeof defaultLang == "string") {
|
|
17
|
+
var oLang = new XMLHttpRequest();
|
|
18
|
+
oLang.open("GET", defaultLang, true);
|
|
19
|
+
oLang.send();
|
|
20
|
+
oLang.onreadystatechange = e=>{
|
|
21
|
+
if (oLang.readyState == 4 && oLang.status == 200){
|
|
22
|
+
try{
|
|
23
|
+
var json = JSON.parse(oLang.responseText);
|
|
24
|
+
//console.dir(json);
|
|
25
|
+
i.defaultLang = json;
|
|
26
|
+
if (cb) cb();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
console.error(defaultLang + " parsing error");
|
|
30
|
+
if (cb) cb();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (cb) cb();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
i.defaultLang = defaultLang;
|
|
40
|
+
if (cb) cb();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
wl.prototype = {
|
|
44
|
+
From:function(key, section){
|
|
45
|
+
var lang = this.localLang;
|
|
46
|
+
if (lang != null && section != null)
|
|
47
|
+
lang = lang[section];
|
|
48
|
+
if (lang != null && lang[key] != null)
|
|
49
|
+
return lang[key];
|
|
50
|
+
if (this.defaultLang == null)
|
|
51
|
+
return key;
|
|
52
|
+
lang = this.defaultLang;
|
|
53
|
+
if (lang != null && section != null)
|
|
54
|
+
lang = lang[section];
|
|
55
|
+
if (lang != null) {
|
|
56
|
+
if (lang[key] != null)
|
|
57
|
+
return lang[key];
|
|
58
|
+
if (lang[key] !== undefined)
|
|
59
|
+
return key;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
load:function(url, cb){
|
|
65
|
+
this.localLang = null;
|
|
66
|
+
|
|
67
|
+
var oLang = new XMLHttpRequest();
|
|
68
|
+
oLang.open("GET", url, true);
|
|
69
|
+
oLang.send();
|
|
70
|
+
oLang.onreadystatechange = e=>{
|
|
71
|
+
if (oLang.readyState == 4 && oLang.status == 200){
|
|
72
|
+
try{
|
|
73
|
+
var json = JSON.parse(oLang.responseText);
|
|
74
|
+
//console.dir(json);
|
|
75
|
+
this.localLang = json;
|
|
76
|
+
if (cb) cb();
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
console.error(url + " parsing error");
|
|
80
|
+
if (cb) cb();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
if (cb) cb();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
reset:function(){
|
|
89
|
+
this.localLang = null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function nearLocaleBrower(list) {
|
|
94
|
+
var userLang = navigator.language || navigator.userLanguage;
|
|
95
|
+
if (userLang == null || userLang == "")
|
|
96
|
+
return null;
|
|
97
|
+
return nearLocale(list, userLang);
|
|
98
|
+
}
|
|
99
|
+
function nearLocale(list, userLang) {
|
|
100
|
+
for (let l in list) {
|
|
101
|
+
if (list[l] == userLang)
|
|
102
|
+
return userLang;
|
|
103
|
+
}
|
|
104
|
+
var lang = userLang.split('-')[0];
|
|
105
|
+
for (let l in list) {
|
|
106
|
+
if (list[l].split('-')[0] == lang)
|
|
107
|
+
return list[l];
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function wLangusage( json, cb ){
|
|
113
|
+
return new wl(json, cb);
|
|
114
|
+
}
|
|
115
|
+
wLangusage.version = version;
|
|
116
|
+
wLangusage.nearLocaleBrower = nearLocaleBrower;
|
|
117
|
+
wLangusage.nearLocale = nearLocale;
|
|
118
|
+
|
|
119
|
+
var R5;
|
|
120
|
+
if ( typeof exports != 'undefined' )
|
|
121
|
+
R5 = exports.R5 ? exports.R5 : (exports.R5={});
|
|
122
|
+
else
|
|
123
|
+
R5 = window.R5 ? window.R5 : (window.R5={});
|
|
124
|
+
|
|
125
|
+
R5.wLang = wLangusage;
|
|
126
|
+
})();
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Remote5 wStyle - 2021.10.13~
|
|
3
|
+
* Author : Willy.Lee (wiljwilj@hotmail.com)
|
|
4
|
+
*/
|
|
5
|
+
// 0.1.1 - 2021.10.13
|
|
6
|
+
// 0.2.0 - 2022.03.09 - wstyle=""
|
|
7
|
+
// 0.3.0 - 2022.11.22 - add style type="text/wcss", add link rel="wstylesheet", remove function type
|
|
8
|
+
// 0.3.1 - 2022.12.12 - loading wcss after load, add data-wstyle=""
|
|
9
|
+
// 0.3.2 - 2023.06.06 - bugfix: parsing key:v1:v2 to key + v1:v2 (add _toKV)
|
|
10
|
+
// 0.3.3 - 2023.09.16 - add R5.wStyle.load <url>, cb(object)
|
|
11
|
+
// 0.4.0 - 2026.02.16 - media query css support
|
|
12
|
+
|
|
13
|
+
(function(){
|
|
14
|
+
"use strict";
|
|
15
|
+
|
|
16
|
+
var version = "0.4.0";
|
|
17
|
+
|
|
18
|
+
function ws( style ) {
|
|
19
|
+
var i = this;
|
|
20
|
+
var d = document;
|
|
21
|
+
var s = i.ele = d.createElement("style");
|
|
22
|
+
d.head.appendChild(s);
|
|
23
|
+
i.stylesheet = s.sheet;
|
|
24
|
+
i.cssRules = s.sheet.cssRules;
|
|
25
|
+
|
|
26
|
+
if (style == null)
|
|
27
|
+
style = "";
|
|
28
|
+
else if (typeof style !== "string" && typeof style !== "object")
|
|
29
|
+
style = style.toString();
|
|
30
|
+
i.style = style;
|
|
31
|
+
|
|
32
|
+
i.updateScreenDensity(R5.screenDensity);
|
|
33
|
+
}
|
|
34
|
+
ws.prototype = {
|
|
35
|
+
updateScreenDensity:function( sd ){
|
|
36
|
+
_updateScreenDensity(this, sd);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
destroy:function(){
|
|
40
|
+
var i = this;
|
|
41
|
+
for (var idx = R5.wStyle.styles.length - 1; idx >= 0; idx--) {
|
|
42
|
+
if (R5.wStyle.styles[idx] == this)
|
|
43
|
+
R5.wStyle.styles.splice(idx, 1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
i.stylesheet.disabled = true;
|
|
47
|
+
document.head.removeChild(i.ele);
|
|
48
|
+
i.ele = null;
|
|
49
|
+
i.stylesheet = null;
|
|
50
|
+
i.cssRules = null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function _fromRules( i, sel ) {
|
|
55
|
+
sel = sel.toLowerCase().replace(/^\s+|\s+$/gm,'');
|
|
56
|
+
|
|
57
|
+
for (var idx = i.cssRules.length - 1; idx >= 0; idx--) {
|
|
58
|
+
var rule = i.cssRules[idx];
|
|
59
|
+
if (rule.selectorText === sel)
|
|
60
|
+
return rule;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function _evalValue( v, sd ) {
|
|
65
|
+
var v1 = v.replace(/screenDensity/gi, sd);
|
|
66
|
+
var v2 = v1.replace(/s?[\-0-9.\(\)\+\-\/\*]*dp+/gi, function(mtch) {
|
|
67
|
+
var mm = mtch.replace(/dp/gi, "*"+sd);
|
|
68
|
+
try {
|
|
69
|
+
mm = eval(mm) + "px";
|
|
70
|
+
} catch (e) {
|
|
71
|
+
mm = mtch;
|
|
72
|
+
}
|
|
73
|
+
return mm;
|
|
74
|
+
});
|
|
75
|
+
var v3 = v2.replace(/s?[\-0-9.\(\)\+\-\/\*]*px+/gi, function(mtch) {
|
|
76
|
+
var mm = mtch.replace(/px$/gi, "");
|
|
77
|
+
try {
|
|
78
|
+
mm = eval(mm) + "px";
|
|
79
|
+
} catch (e) {
|
|
80
|
+
mm = mtch;
|
|
81
|
+
}
|
|
82
|
+
return mm;
|
|
83
|
+
});
|
|
84
|
+
return v3;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function _toKV( s ) {
|
|
88
|
+
var n = s.indexOf(":");
|
|
89
|
+
if (n <= 0) return null;
|
|
90
|
+
return [s.substring(0, n).replace(/^\s+|\s+$/g,""),
|
|
91
|
+
s.substring(n+1).replace(/^\s+|\s+$/g,"")];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function _updateWStyleInElements( eles, sd ) {
|
|
95
|
+
for (var idx = 0; idx < eles.length; idx++) {
|
|
96
|
+
var ele = eles[idx];
|
|
97
|
+
var wstyle = ele.getAttribute("wstyle");
|
|
98
|
+
if (wstyle == null)
|
|
99
|
+
wstyle = ele.getAttribute("data-wstyle");
|
|
100
|
+
if (wstyle) {
|
|
101
|
+
var ss = wstyle.split(/\s*;\s*/);
|
|
102
|
+
ss.forEach(function( s ){
|
|
103
|
+
var pv = _toKV(s);
|
|
104
|
+
if (pv == null)
|
|
105
|
+
return;
|
|
106
|
+
var val = _evalValue(pv[1], sd);
|
|
107
|
+
ele.style[pv[0]] = val;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
_updateWStyleInElements(ele.children, sd);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function _strstyle2obj( str ){
|
|
115
|
+
var spvs = str.split(/\s*}\s*/);
|
|
116
|
+
var ispv = 0;
|
|
117
|
+
var espv = spvs.length - 1;
|
|
118
|
+
|
|
119
|
+
var oESs = {};
|
|
120
|
+
while (ispv < espv) {
|
|
121
|
+
var spv = spvs[ispv];
|
|
122
|
+
spv = spv.split(/\s*{\s*/);
|
|
123
|
+
ispv = _rstrstyle2obj(spvs, ispv, espv, spv, oESs);
|
|
124
|
+
}
|
|
125
|
+
return oESs;
|
|
126
|
+
}
|
|
127
|
+
function _rstrstyle2obj(spvs, ispv, espv, spv, oESs){
|
|
128
|
+
var sel = spv.length < 2 ? "" : spv[0].replace(/\/\/.*/gm, '').replace(/\s+/gm, ' ').replace(/^\s+|\s+$/gm,'');
|
|
129
|
+
if (sel === "")
|
|
130
|
+
return ispv+1;
|
|
131
|
+
if (spv.length === 2) {
|
|
132
|
+
_strkeyvalue(sel, spv[1], oESs);
|
|
133
|
+
return ispv+1;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
var oSss = {}
|
|
137
|
+
oESs[sel] = oSss;
|
|
138
|
+
var spvss = spv.splice(1);
|
|
139
|
+
ispv = _rstrstyle2obj(spvs, ispv, espv, spvss, oSss);
|
|
140
|
+
while (ispv < espv) {
|
|
141
|
+
var spv = spvs[ispv];
|
|
142
|
+
if (spv === "")
|
|
143
|
+
return ispv+1;
|
|
144
|
+
spv = spv.split(/\s*{\s*/);
|
|
145
|
+
ispv = _rstrstyle2obj(spvs, ispv+1, espv, spv, oSss);
|
|
146
|
+
}
|
|
147
|
+
return ispv;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function _strkeyvalue(sel, styles, oESs){
|
|
151
|
+
var oSs = {}
|
|
152
|
+
oESs[sel] = oSs;
|
|
153
|
+
try {
|
|
154
|
+
styles = styles.replace(/^\s+|\s+$/gm,'');
|
|
155
|
+
styles = styles.split(/\s*;\s*/);
|
|
156
|
+
styles.forEach(function( s ){
|
|
157
|
+
var pv = _toKV(s);
|
|
158
|
+
if (pv == null)
|
|
159
|
+
return;
|
|
160
|
+
oSs[pv[0]] = pv[1];
|
|
161
|
+
});
|
|
162
|
+
} catch (e) {
|
|
163
|
+
console.warn("wStyle: can't apply css - "+sel);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function _updateScreenDensity( i, sd ){
|
|
168
|
+
var istyle = i.style;
|
|
169
|
+
if (typeof istyle == "string") {
|
|
170
|
+
istyle = _strstyle2obj(istyle);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
for (var sel in istyle) {
|
|
174
|
+
var rule = _fromRules(i, sel);
|
|
175
|
+
try {
|
|
176
|
+
if (rule == null) {
|
|
177
|
+
var idxR = i.cssRules.length;
|
|
178
|
+
i.stylesheet.insertRule(sel+" {}", idxR);
|
|
179
|
+
rule = i.cssRules[idxR];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var styles = istyle[sel];
|
|
183
|
+
var prop, val, idxR2, rule2, prop2, val2;
|
|
184
|
+
switch (rule.constructor.name)
|
|
185
|
+
{
|
|
186
|
+
case "CSSStyleRule":
|
|
187
|
+
for (prop in styles) {
|
|
188
|
+
val = styles[prop];
|
|
189
|
+
val = _evalValue(val, sd);
|
|
190
|
+
rule.style[prop] = val;
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case "CSSMediaRule":
|
|
194
|
+
for (prop in styles) {
|
|
195
|
+
val = styles[prop];
|
|
196
|
+
idxR2 = rule.cssRules.length;
|
|
197
|
+
rule.insertRule(prop+" {}", idxR2);
|
|
198
|
+
rule2 = rule.cssRules[idxR2];
|
|
199
|
+
for (prop2 in val) {
|
|
200
|
+
val2 = val[prop2];
|
|
201
|
+
val2 = _evalValue(val2, sd);
|
|
202
|
+
rule2.style[prop2] = val2;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case "CSSKeyframesRule":
|
|
207
|
+
for (prop in styles) {
|
|
208
|
+
val = styles[prop];
|
|
209
|
+
rule.appendRule(prop+" {}");
|
|
210
|
+
rule2 = rule.cssRules[rule.cssRules.length - 1];
|
|
211
|
+
for (prop2 in val) {
|
|
212
|
+
val2 = val[prop2];
|
|
213
|
+
val2 = _evalValue(val2, sd);
|
|
214
|
+
rule2.style[prop2] = val2;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
default:
|
|
219
|
+
throw new Error(1);
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
console.warn("wStyle: can't apply json css - "+sel);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function wStyle( t ){
|
|
228
|
+
var s = new ws(t);
|
|
229
|
+
R5.wStyle.styles.push(s);
|
|
230
|
+
return s;
|
|
231
|
+
}
|
|
232
|
+
wStyle.version = version;
|
|
233
|
+
|
|
234
|
+
function updateStyleInElements(){
|
|
235
|
+
var bds = document.getElementsByTagName("body");
|
|
236
|
+
_updateWStyleInElements(bds, R5.screenDensity);
|
|
237
|
+
|
|
238
|
+
var styles = document.getElementsByTagName("style");
|
|
239
|
+
var idx = 0;
|
|
240
|
+
for (; idx < styles.length; idx++) {
|
|
241
|
+
var sty = styles[idx];
|
|
242
|
+
if (sty.type == null || sty.type.toLowerCase() !== "text/wcss")
|
|
243
|
+
continue;
|
|
244
|
+
|
|
245
|
+
if (sty.R5_ws == null) {
|
|
246
|
+
sty.R5_ws = new ws(sty.outerText);
|
|
247
|
+
}
|
|
248
|
+
sty.R5_ws.updateScreenDensity(R5.screenDensity);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var links = document.getElementsByTagName("link");
|
|
252
|
+
for (idx = 0; idx < links.length; idx++) {
|
|
253
|
+
var lnk = links[idx];
|
|
254
|
+
if (lnk.rel == null || lnk.rel.toLowerCase() !== "wstylesheet")
|
|
255
|
+
continue;
|
|
256
|
+
|
|
257
|
+
if (lnk.R5_ws == null) {
|
|
258
|
+
var wcss = new XMLHttpRequest();
|
|
259
|
+
wcss.open("GET", lnk.href, true);
|
|
260
|
+
wcss.send();
|
|
261
|
+
wcss.onreadystatechange = function(){
|
|
262
|
+
if (wcss.readyState == 4 && wcss.status == 200) {
|
|
263
|
+
lnk.R5_ws = new ws(wcss.responseText);
|
|
264
|
+
lnk.R5_ws.updateScreenDensity(R5.screenDensity);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function loadWcssFile(url, cb){
|
|
272
|
+
var styleApp = new XMLHttpRequest();
|
|
273
|
+
styleApp.open("GET", url, true);
|
|
274
|
+
styleApp.send();
|
|
275
|
+
styleApp.onreadystatechange = ()=>{
|
|
276
|
+
if (styleApp.readyState == 4 && styleApp.status == 200)
|
|
277
|
+
cb(R5.wStyle(styleApp.responseText));
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function setScreenDensity( sd ){
|
|
282
|
+
if (sd == null)
|
|
283
|
+
sd = R5.screenDensity;
|
|
284
|
+
else
|
|
285
|
+
R5.screenDensity = sd;
|
|
286
|
+
|
|
287
|
+
R5.wStyle.styles.forEach(function( s ){
|
|
288
|
+
s.updateScreenDensity(sd);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
updateStyleInElements();
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
var R5;
|
|
296
|
+
if ( typeof exports != 'undefined' )
|
|
297
|
+
R5 = exports.R5 ? exports.R5 : (exports.R5={});
|
|
298
|
+
else
|
|
299
|
+
R5 = window.R5 ? window.R5 : (window.R5={});
|
|
300
|
+
|
|
301
|
+
R5.wStyle = wStyle;
|
|
302
|
+
R5.wStyle.styles = [];
|
|
303
|
+
R5.wStyle.updateStyleInElements = updateStyleInElements;
|
|
304
|
+
R5.wStyle.load = loadWcssFile;
|
|
305
|
+
R5.screenDensity = 1;
|
|
306
|
+
R5.setScreenDensity = setScreenDensity;
|
|
307
|
+
|
|
308
|
+
window.addEventListener("load", function(){ R5.setScreenDensity() });
|
|
309
|
+
})();
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "remote5-gui",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Remote5 GUI package.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "",
|
|
9
|
+
"directory": "packages/remote5-gui"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"remote5"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "",
|
|
16
|
+
"peerDependencies": {},
|
|
17
|
+
"files": [
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md",
|
|
20
|
+
"index.js",
|
|
21
|
+
"lib/"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"default": "./index.js"
|
|
26
|
+
},
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
|
+
"directories": {
|
|
30
|
+
"lib": "lib"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
34
|
+
},
|
|
35
|
+
"author": "Willy.Lee.KW"
|
|
36
|
+
}
|