remote5-gui 0.1.4 → 0.1.6

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 CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('./lib/wbase-0.1.3.js');
3
+ module.exports = require('./lib/wbase-0.2.0.js');
package/index_lang.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./lib/wlang-0.2.0.js');
package/index_style.js ADDED
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ module.exports = require('./lib/wstyle-0.5.0.js');
@@ -4,12 +4,13 @@
4
4
  */
5
5
  // 0.1.1 - 2021.10.08 start
6
6
  // 0.1.2 - 2022.11.22
7
- // 0.1.3 - 2026.02.21 apply npm library
7
+ // 0.2.0 - 2026.02.21 apply npm library
8
8
 
9
+ export default
9
10
  (function(){
10
11
  "use strict";
11
12
 
12
- var version = "0.1.3";
13
+ var version = "0.2.0";
13
14
 
14
15
  var w2a = {
15
16
  q: [],
@@ -37,7 +38,7 @@ function procW2A(i){
37
38
  else if (typeof (i.cpct) == "object")
38
39
  i.cpct.cmd(mcmd);
39
40
  else
40
- location.href = mcmd;
41
+ window.location.href = mcmd;
41
42
  i.t = setTimeout(function () { i.t = null; procW2A(i); }, 0);
42
43
  }
43
44
 
@@ -173,11 +174,9 @@ var evt = {
173
174
  }
174
175
  };
175
176
 
176
- var R5;
177
- if (typeof exports != 'undefined')
178
- R5 = exports;
179
- else
180
- R5 = window.R5 ? window.R5 : (window.R5 = {});
177
+
178
+ function R5() {
179
+ }
181
180
 
182
181
  R5.wBase = {
183
182
  w2a: w2a,
@@ -205,4 +204,8 @@ R5.removeEventListener = function( type, listener ){
205
204
  R5.exitApp = function(){
206
205
  R5.command("EXIT_APP", {});
207
206
  }
207
+
208
+ window.R5 = R5;
209
+
210
+ return R5;
208
211
  })();
@@ -0,0 +1,214 @@
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
+ // 0.1.5 - 2026.02.19 add function finding by contrycode
9
+ // 0.2.0 - 2026.02.21 apply npm library. R5.wLang -> wLang
10
+
11
+ export default
12
+ (function(){
13
+ "use strict";
14
+
15
+ var version = "0.2.0";
16
+
17
+ function wl( defaultLang, cb ) {
18
+ var i = this;
19
+ if (typeof defaultLang == "string") {
20
+ var oLang = new XMLHttpRequest();
21
+ oLang.open("GET", defaultLang, true);
22
+ oLang.send();
23
+ oLang.onreadystatechange = e=>{
24
+ if (oLang.readyState == 4 && oLang.status == 200){
25
+ try{
26
+ var json = JSON.parse(oLang.responseText);
27
+ //console.dir(json);
28
+ i.defaultLang = json;
29
+ if (cb) cb();
30
+ }
31
+ catch {
32
+ console.error(defaultLang + " parsing error");
33
+ if (cb) cb();
34
+ }
35
+ }
36
+ else {
37
+ if (cb) cb();
38
+ }
39
+ }
40
+ }
41
+ else {
42
+ i.defaultLang = defaultLang;
43
+ if (cb) cb();
44
+ }
45
+ }
46
+ wl.prototype = {
47
+ From:function(key, section){
48
+ var lang = this.localLang;
49
+ if (lang != null && section != null)
50
+ lang = lang[section];
51
+ if (lang != null && lang[key] != null)
52
+ return lang[key];
53
+ if (this.defaultLang == null)
54
+ return key;
55
+ lang = this.defaultLang;
56
+ if (lang != null && section != null)
57
+ lang = lang[section];
58
+ if (lang != null) {
59
+ if (lang[key] != null)
60
+ return lang[key];
61
+ if (lang[key] !== undefined)
62
+ return key;
63
+ }
64
+ return null;
65
+ },
66
+ load:function(url, cb){
67
+ var i = this;
68
+ i.localLang = null;
69
+ if (typeof url == "string") {
70
+ var oLang = new XMLHttpRequest();
71
+ oLang.open("GET", url, true);
72
+ oLang.send();
73
+ oLang.onreadystatechange = e=>{
74
+ if (oLang.readyState == 4 && oLang.status == 200){
75
+ try{
76
+ var json = JSON.parse(oLang.responseText);
77
+ //console.dir(json);
78
+ i.localLang = json;
79
+ if (cb) cb();
80
+ }
81
+ catch {
82
+ console.error(url + " parsing error");
83
+ if (cb) cb();
84
+ }
85
+ }
86
+ else {
87
+ if (cb) cb();
88
+ }
89
+ }
90
+ }
91
+ else {
92
+ i.defaultLang = url;
93
+ if (cb) cb();
94
+ }
95
+ },
96
+ reset:function(){
97
+ this.localLang = null;
98
+ }
99
+ };
100
+
101
+ function wLang(key, section) {
102
+ for (let idx = wLang.lang_handles.length - 1; idx >= 0; idx--) {
103
+ let v = wLang.lang_handles[idx][1].From(key, section);
104
+ if (v != null)
105
+ return v;
106
+ }
107
+
108
+ return "[["+key+"]]";
109
+ }
110
+ wLang.version = version;
111
+ wLang.lang_handles = [];
112
+ wLang.c_defaultLocaleCode = "en-US"; //!!
113
+ wLang.s_langCode = "en";
114
+ wLang.s_countryCode = "US";
115
+ wLang.getDeviceCountryCode = function(){
116
+ return wLang.s_countryCode;
117
+ };
118
+ wLang.LocaleCode = function(){
119
+ return wLang.s_langCode+"-"+wLang.s_countryCode;
120
+ };
121
+ wLang.nearLocaleBrower = function(list){
122
+ var userLang = navigator.language || navigator.userLanguage;
123
+ if (userLang == null || userLang == "")
124
+ return null;
125
+ return this.nearLocale(list, userLang);
126
+ };
127
+ wLang.nearLocale = function(list, userLang){
128
+ for (let l in list) {
129
+ if (list[l] == userLang)
130
+ return userLang;
131
+ }
132
+ var lang = userLang.split('-')[0];
133
+ for (let l in list) {
134
+ if (list[l].split('-')[0] == lang)
135
+ return list[l];
136
+ }
137
+ var contry = userLang.split('-')[1];
138
+ for (let l in list) {
139
+ if (list[l].split('-')[1] == contry)
140
+ return list[l];
141
+ }
142
+ return null;
143
+ };
144
+ wLang.matchLocaleCode = function(locale_code){
145
+ let listLocale = JSON.parse(process.env.REACT_APP_LOCALECODES);
146
+ let locale = this.nearLocale(listLocale, locale_code);
147
+ if (locale !== null)
148
+ return locale;
149
+ return this.c_defaultLocaleCode;
150
+ };
151
+ wLang.Locale = function(locale_code, cb){
152
+ let locale_code_matched = this.matchLocaleCode(locale_code);
153
+ if (locale_code_matched.localeCompare(locale_code) != 0) {
154
+ //R5.Trace("wLang().Locale - "+locale_code+" => "+locale_code_matched);
155
+ locale_code = locale_code_matched;
156
+ }
157
+ else {
158
+ //R5.Trace("wLang().Locale - "+locale_code);
159
+ }
160
+ if (this.c_defaultLocaleCode.localeCompare(locale_code) == 0) {
161
+ this.lang_handles.forEach(o=>{o[1].reset()});
162
+ if (cb != null) cb();
163
+ }
164
+ else if (locale_code.localeCompare(this.s_langCode+"-"+this.s_countryCode) != 0) {
165
+ this.lang_handles.forEach(o=>{
166
+ o[1].load(o[0]+locale_code+".json", cb);
167
+ })
168
+ }
169
+ this.s_langCode = locale_code.substr(0, 2);
170
+ this.s_countryCode = locale_code.substr(3);
171
+ };
172
+ wLang.Add = function(prefix, cb, json){
173
+ let lang;
174
+ if (this.c_defaultLocaleCode.localeCompare(this.s_langCode+"-"+this.s_countryCode) == 0) {
175
+ lang = (json == null) ?
176
+ new wl(prefix+this.c_defaultLocaleCode+".json", cb) :
177
+ new wl(json, cb);
178
+ }
179
+ else {
180
+ lang = (json == null) ?
181
+ new wl(prefix+this.c_defaultLocaleCode+".json") :
182
+ new wl(json);
183
+ lang.load(prefix+this.s_langCode+"-"+this.s_countryCode+".json", cb);
184
+ }
185
+ this.lang_handles.push([prefix,lang]);
186
+ return lang;
187
+ };
188
+ wLang.Remove = function(handle){
189
+ let idx = this.lang_handles.length;
190
+ for (--idx; idx >= 0; idx--) {
191
+ if (Object.is(this.lang_handles[idx][1], handle))
192
+ this.lang_handles.splice(idx, 1);
193
+ }
194
+ };
195
+
196
+ /*
197
+ // text align
198
+ var s_language_right_align = {
199
+ ar:true
200
+ };
201
+ var s_langRightAlign = false;
202
+ s_langRightAlign = s_language_right_align[langcode] == true;
203
+
204
+ Lang.isRightAlign = e=>{
205
+ return false;
206
+ };
207
+ */
208
+
209
+ if (typeof module == 'undefined') {
210
+ window.wLang = wLang;
211
+ }
212
+
213
+ return wLang;
214
+ })();
@@ -10,12 +10,13 @@
10
10
  // 0.3.3 - 2023.09.16 add R5.wStyle.load <url>, cb(object)
11
11
  // 0.4.0 - 2026.02.16 media query css support
12
12
  // 0.4.1 - 2026.02.20 stop formula support
13
- // 0.4.2 - 2026.02.21 apply npm library
13
+ // 0.5.0 - 2026.02.22 apply npm library. R5.wStyle -> wStyle
14
14
 
15
+ export default
15
16
  (function(){
16
17
  "use strict";
17
18
 
18
- var version = "0.4.0";
19
+ var version = "0.5.0";
19
20
 
20
21
  function ws( style ) {
21
22
  var i = this;
@@ -31,7 +32,7 @@
31
32
  style = style.toString();
32
33
  i.style = style;
33
34
 
34
- i.updateScreenDensity(R5.screenDensity);
35
+ i.updateScreenDensity(wStyle.screenDensity);
35
36
  }
36
37
  ws.prototype = {
37
38
  updateScreenDensity:function( sd ){
@@ -40,9 +41,9 @@
40
41
 
41
42
  destroy:function(){
42
43
  var i = this;
43
- for (var idx = R5.wStyle.styles.length - 1; idx >= 0; idx--) {
44
- if (R5.wStyle.styles[idx] == this)
45
- R5.wStyle.styles.splice(idx, 1);
44
+ for (var idx = wStyle.styles.length - 1; idx >= 0; idx--) {
45
+ if (wStyle.styles[idx] == this)
46
+ wStyle.styles.splice(idx, 1);
46
47
  }
47
48
 
48
49
  i.stylesheet.disabled = true;
@@ -140,11 +141,11 @@
140
141
  var spvss = spv.splice(1);
141
142
  ispv = _rstrstyle2obj(spvs, ispv, espv, spvss, oSss);
142
143
  while (ispv < espv) {
143
- var spv = spvs[ispv];
144
- if (spv === "")
144
+ var spv2 = spvs[ispv];
145
+ if (spv2 === "")
145
146
  return ispv+1;
146
- spv = spv.split(/\s*{\s*/);
147
- ispv = _rstrstyle2obj(spvs, ispv, espv, spv, oSss);
147
+ spv2 = spv2.split(/\s*{\s*/);
148
+ ispv = _rstrstyle2obj(spvs, ispv, espv, spv2, oSss);
148
149
  }
149
150
  return ispv;
150
151
  }
@@ -226,16 +227,22 @@
226
227
  }
227
228
  }
228
229
 
230
+
229
231
  function wStyle( t ){
230
232
  var s = new ws(t);
231
- R5.wStyle.styles.push(s);
233
+ wStyle.styles.push(s);
232
234
  return s;
233
235
  }
234
236
  wStyle.version = version;
235
-
237
+ wStyle.styles = [];
238
+ wStyle.updateStyleInElements = updateStyleInElements;
239
+ wStyle.load = loadWcssFile;
240
+ wStyle.screenDensity = 1;
241
+ wStyle.setScreenDensity = setScreenDensity;
242
+
236
243
  function updateStyleInElements(){
237
244
  var bds = document.getElementsByTagName("body");
238
- _updateWStyleInElements(bds, R5.screenDensity);
245
+ _updateWStyleInElements(bds, wStyle.screenDensity);
239
246
 
240
247
  var styles = document.getElementsByTagName("style");
241
248
  var idx = 0;
@@ -247,7 +254,7 @@
247
254
  if (sty.R5_ws == null) {
248
255
  sty.R5_ws = new ws(sty.outerText);
249
256
  }
250
- sty.R5_ws.updateScreenDensity(R5.screenDensity);
257
+ sty.R5_ws.updateScreenDensity(wStyle.screenDensity);
251
258
  }
252
259
 
253
260
  var links = document.getElementsByTagName("link");
@@ -263,7 +270,7 @@
263
270
  wcss.onreadystatechange = function(){
264
271
  if (wcss.readyState == 4 && wcss.status == 200) {
265
272
  lnk.R5_ws = new ws(wcss.responseText);
266
- lnk.R5_ws.updateScreenDensity(R5.screenDensity);
273
+ lnk.R5_ws.updateScreenDensity(wStyle.screenDensity);
267
274
  }
268
275
  }
269
276
  }
@@ -276,36 +283,27 @@
276
283
  styleApp.send();
277
284
  styleApp.onreadystatechange = ()=>{
278
285
  if (styleApp.readyState == 4 && styleApp.status == 200)
279
- cb(R5.wStyle(styleApp.responseText));
286
+ cb(wStyle(styleApp.responseText));
280
287
  }
281
288
  }
282
289
 
283
290
  function setScreenDensity( sd ){
284
291
  if (sd == null)
285
- sd = R5.screenDensity;
292
+ sd = wStyle.screenDensity;
286
293
  else
287
- R5.screenDensity = sd;
294
+ wStyle.screenDensity = sd;
288
295
 
289
- R5.wStyle.styles.forEach(function( s ){
296
+ wStyle.styles.forEach(function( s ){
290
297
  s.updateScreenDensity(sd);
291
298
  });
292
299
 
293
300
  updateStyleInElements();
294
301
  }
295
-
296
-
297
- var R5;
298
- if ( typeof exports != 'undefined' )
299
- R5 = exports;
300
- else
301
- R5 = window.R5 ? window.R5 : (window.R5={});
302
-
303
- R5.wStyle = wStyle;
304
- R5.wStyle.styles = [];
305
- R5.wStyle.updateStyleInElements = updateStyleInElements;
306
- R5.wStyle.load = loadWcssFile;
307
- R5.screenDensity = 1;
308
- R5.setScreenDensity = setScreenDensity;
309
-
310
- window.addEventListener("load", function(){ R5.setScreenDensity() });
302
+
303
+ if (typeof module == 'undefined') {
304
+ window.wStyle = wStyle;
305
+ window.addEventListener("load", function(){ wStyle.setScreenDensity() });
306
+ }
307
+
308
+ return wStyle;
311
309
  })();
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "remote5-gui",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Remote5 GUI package.",
5
5
  "main": "./index.js",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "index.js",
9
+ "index_lang.js",
10
+ "index_style.js",
9
11
  "lib/"
10
12
  ],
11
13
  "exports": {
@@ -1,133 +0,0 @@
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
- // 0.1.5 - 2026.02.19 add function finding by contrycode
9
- // 0.1.6 - 2026.02.21 apply npm library
10
-
11
- (function(){
12
- "use strict";
13
-
14
- var version = "0.1.3";
15
-
16
- function wl( defaultLang, cb ) {
17
- var i = this;
18
- if (typeof defaultLang == "string") {
19
- var oLang = new XMLHttpRequest();
20
- oLang.open("GET", defaultLang, true);
21
- oLang.send();
22
- oLang.onreadystatechange = e=>{
23
- if (oLang.readyState == 4 && oLang.status == 200){
24
- try{
25
- var json = JSON.parse(oLang.responseText);
26
- //console.dir(json);
27
- i.defaultLang = json;
28
- if (cb) cb();
29
- }
30
- catch {
31
- console.error(defaultLang + " parsing error");
32
- if (cb) cb();
33
- }
34
- }
35
- else {
36
- if (cb) cb();
37
- }
38
- }
39
- }
40
- else {
41
- i.defaultLang = defaultLang;
42
- if (cb) cb();
43
- }
44
- }
45
- wl.prototype = {
46
- From:function(key, section){
47
- var lang = this.localLang;
48
- if (lang != null && section != null)
49
- lang = lang[section];
50
- if (lang != null && lang[key] != null)
51
- return lang[key];
52
- if (this.defaultLang == null)
53
- return key;
54
- lang = this.defaultLang;
55
- if (lang != null && section != null)
56
- lang = lang[section];
57
- if (lang != null) {
58
- if (lang[key] != null)
59
- return lang[key];
60
- if (lang[key] !== undefined)
61
- return key;
62
- }
63
- return null;
64
- },
65
-
66
- load:function(url, cb){
67
- this.localLang = null;
68
-
69
- var oLang = new XMLHttpRequest();
70
- oLang.open("GET", url, true);
71
- oLang.send();
72
- oLang.onreadystatechange = e=>{
73
- if (oLang.readyState == 4 && oLang.status == 200){
74
- try{
75
- var json = JSON.parse(oLang.responseText);
76
- //console.dir(json);
77
- this.localLang = json;
78
- if (cb) cb();
79
- }
80
- catch {
81
- console.error(url + " parsing error");
82
- if (cb) cb();
83
- }
84
- }
85
- else {
86
- if (cb) cb();
87
- }
88
- }
89
- },
90
- reset:function(){
91
- this.localLang = null;
92
- }
93
- };
94
-
95
- function nearLocaleBrower(list) {
96
- var userLang = navigator.language || navigator.userLanguage;
97
- if (userLang == null || userLang == "")
98
- return null;
99
- return nearLocale(list, userLang);
100
- }
101
- function nearLocale(list, userLang) {
102
- for (let l in list) {
103
- if (list[l] == userLang)
104
- return userLang;
105
- }
106
- var lang = userLang.split('-')[0];
107
- for (let l in list) {
108
- if (list[l].split('-')[0] == lang)
109
- return list[l];
110
- }
111
- var contry = userLang.split('-')[1];
112
- for (let l in list) {
113
- if (list[l].split('-')[1] == contry)
114
- return list[l];
115
- }
116
- return null;
117
- }
118
-
119
- function wLangusage( json, cb ){
120
- return new wl(json, cb);
121
- }
122
- wLangusage.version = version;
123
- wLangusage.nearLocaleBrower = nearLocaleBrower;
124
- wLangusage.nearLocale = nearLocale;
125
-
126
- var R5;
127
- if ( typeof exports != 'undefined' )
128
- R5 = exports;
129
- else
130
- R5 = window.R5 ? window.R5 : (window.R5={});
131
-
132
- R5.wLang = wLangusage;
133
- })();