Skip to content

Commit 9308d1c

Browse files
committed
[ refactoring ] tab to space
1 parent 425d13e commit 9308d1c

File tree

2 files changed

+136
-136
lines changed

2 files changed

+136
-136
lines changed

Assets/WebGLSupport/WebGLInput/WebGLInput.jslib

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
var WebGLInput = {
22
$instances: [],
3-
WebGLInputInit : function() {
3+
WebGLInputInit : function() {
44
// use WebAssembly.Table : makeDynCall
55
// when enable. dynCall is undefined
66
if(typeof dynCall === "undefined")
77
{
8-
// make Runtime.dynCall to undefined
8+
// make Runtime.dynCall to undefined
99
Runtime = { dynCall : undefined }
1010
}
1111
else
1212
{
13-
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
14-
// if Runtime not defined. create and add functon!!
15-
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
13+
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
14+
// if Runtime not defined. create and add functon!!
15+
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
1616
}
17-
},
17+
},
1818
WebGLInputCreate: function (canvasId, x, y, width, height, fontsize, text, placeholder, isMultiLine, isPassword, isHidden, isMobile) {
1919

2020
var container = document.getElementById(UTF8ToString(canvasId));
@@ -27,99 +27,99 @@ var WebGLInput = {
2727
container = canvas.parentNode;
2828
}
2929

30-
if(canvas)
31-
{
32-
var scaleX = container.offsetWidth / canvas.width;
33-
var scaleY = container.offsetHeight / canvas.height;
30+
if(canvas)
31+
{
32+
var scaleX = container.offsetWidth / canvas.width;
33+
var scaleY = container.offsetHeight / canvas.height;
3434

35-
if(scaleX && scaleY)
36-
{
37-
x *= scaleX;
38-
width *= scaleX;
39-
y *= scaleY;
40-
height *= scaleY;
41-
}
42-
}
35+
if(scaleX && scaleY)
36+
{
37+
x *= scaleX;
38+
width *= scaleX;
39+
y *= scaleY;
40+
height *= scaleY;
41+
}
42+
}
4343

4444
var input = document.createElement(isMultiLine?"textarea":"input");
4545
input.style.position = "absolute";
4646

47-
if(isMobile) {
48-
input.style.bottom = 1 + "vh";
49-
input.style.left = 5 + "vw";
50-
input.style.width = 90 + "vw";
51-
input.style.height = (isMultiLine? 18 : 10) + "vh";
52-
input.style.fontSize = 5 + "vh";
53-
input.style.borderWidth = 5 + "px";
54-
input.style.borderColor = "#000000";
55-
} else {
56-
input.style.top = y + "px";
57-
input.style.left = x + "px";
58-
input.style.width = width + "px";
59-
input.style.height = height + "px";
60-
input.style.fontSize = fontsize + "px";
61-
}
47+
if(isMobile) {
48+
input.style.bottom = 1 + "vh";
49+
input.style.left = 5 + "vw";
50+
input.style.width = 90 + "vw";
51+
input.style.height = (isMultiLine? 18 : 10) + "vh";
52+
input.style.fontSize = 5 + "vh";
53+
input.style.borderWidth = 5 + "px";
54+
input.style.borderColor = "#000000";
55+
} else {
56+
input.style.top = y + "px";
57+
input.style.left = x + "px";
58+
input.style.width = width + "px";
59+
input.style.height = height + "px";
60+
input.style.fontSize = fontsize + "px";
61+
}
6262

63-
input.style.outlineWidth = 1 + 'px';
64-
input.style.opacity = isHidden?0:1;
65-
input.style.resize = 'none'; // for textarea
66-
input.style.padding = '0px 1px';
67-
input.style.cursor = "default";
68-
input.style.touchAction = 'none';
63+
input.style.outlineWidth = 1 + 'px';
64+
input.style.opacity = isHidden?0:1;
65+
input.style.resize = 'none'; // for textarea
66+
input.style.padding = '0px 1px';
67+
input.style.cursor = "default";
68+
input.style.touchAction = 'none';
6969

70-
input.spellcheck = false;
71-
input.value = UTF8ToString(text);
72-
input.placeholder = UTF8ToString(placeholder);
73-
input.style.outlineColor = 'black';
74-
75-
if(isPassword){
76-
input.type = 'password';
77-
}
70+
input.spellcheck = false;
71+
input.value = UTF8ToString(text);
72+
input.placeholder = UTF8ToString(placeholder);
73+
input.style.outlineColor = 'black';
74+
75+
if(isPassword){
76+
input.type = 'password';
77+
}
7878

79-
if(isMobile) {
80-
document.body.appendChild(input);
81-
} else {
82-
container.appendChild(input);
83-
}
79+
if(isMobile) {
80+
document.body.appendChild(input);
81+
} else {
82+
container.appendChild(input);
83+
}
8484
return instances.push(input) - 1;
8585
},
86-
WebGLInputEnterSubmit: function(id, falg){
87-
var input = instances[id];
88-
// for enter key
89-
input.addEventListener('keydown', function(e) {
90-
if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) {
91-
if(falg)
92-
{
93-
e.preventDefault();
94-
input.blur();
95-
}
96-
}
97-
});
98-
},
99-
WebGLInputTab:function(id, cb) {
100-
var input = instances[id];
101-
// for tab key
86+
WebGLInputEnterSubmit: function(id, falg){
87+
var input = instances[id];
88+
// for enter key
89+
input.addEventListener('keydown', function(e) {
90+
if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) {
91+
if(falg)
92+
{
93+
e.preventDefault();
94+
input.blur();
95+
}
96+
}
97+
});
98+
},
99+
WebGLInputTab:function(id, cb) {
100+
var input = instances[id];
101+
// for tab key
102102
input.addEventListener('keydown', function (e) {
103103
if ((e.which && e.which === 9) || (e.keyCode && e.keyCode === 9)) {
104104
e.preventDefault();
105105

106-
// if enable tab text
107-
if(input.enableTabText){
106+
// if enable tab text
107+
if(input.enableTabText){
108108
var val = input.value;
109109
var start = input.selectionStart;
110110
var end = input.selectionEnd;
111111
input.value = val.substr(0, start) + '\t' + val.substr(end, val.length);
112112
input.setSelectionRange(start + 1, start + 1);
113113
input.oninput(); // call oninput to exe ValueChange function!!
114-
} else {
115-
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, e.shiftKey ? -1 : 1]) : {{{ makeDynCall("vii", "cb") }}}(id, e.shiftKey ? -1 : 1);
116-
}
114+
} else {
115+
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, e.shiftKey ? -1 : 1]) : {{{ makeDynCall("vii", "cb") }}}(id, e.shiftKey ? -1 : 1);
116+
}
117117
}
118-
});
119-
},
120-
WebGLInputFocus: function(id){
121-
var input = instances[id];
122-
input.focus();
118+
});
119+
},
120+
WebGLInputFocus: function(id){
121+
var input = instances[id];
122+
input.focus();
123123
},
124124
WebGLInputOnFocus: function (id, cb) {
125125
var input = instances[id];
@@ -133,66 +133,66 @@ var WebGLInput = {
133133
(!!Runtime.dynCall) ? Runtime.dynCall("vi", cb, [id]) : {{{ makeDynCall("vi", "cb") }}}(id);
134134
};
135135
},
136-
WebGLInputIsFocus: function (id) {
137-
return instances[id] === document.activeElement;
138-
},
139-
WebGLInputOnValueChange:function(id, cb){
136+
WebGLInputIsFocus: function (id) {
137+
return instances[id] === document.activeElement;
138+
},
139+
WebGLInputOnValueChange:function(id, cb){
140140
var input = instances[id];
141141
input.oninput = function () {
142-
var returnStr = input.value;
143-
var bufferSize = lengthBytesUTF8(returnStr) + 1;
144-
var buffer = _malloc(bufferSize);
145-
stringToUTF8(returnStr, buffer, bufferSize);
146-
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
142+
var returnStr = input.value;
143+
var bufferSize = lengthBytesUTF8(returnStr) + 1;
144+
var buffer = _malloc(bufferSize);
145+
stringToUTF8(returnStr, buffer, bufferSize);
146+
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
147147
};
148148
},
149-
WebGLInputOnEditEnd:function(id, cb){
149+
WebGLInputOnEditEnd:function(id, cb){
150150
var input = instances[id];
151151
input.onchange = function () {
152-
var returnStr = input.value;
153-
var bufferSize = lengthBytesUTF8(returnStr) + 1;
154-
var buffer = _malloc(bufferSize);
155-
stringToUTF8(returnStr, buffer, bufferSize);
156-
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
152+
var returnStr = input.value;
153+
var bufferSize = lengthBytesUTF8(returnStr) + 1;
154+
var buffer = _malloc(bufferSize);
155+
stringToUTF8(returnStr, buffer, bufferSize);
156+
(!!Runtime.dynCall) ? Runtime.dynCall("vii", cb, [id, buffer]) : {{{ makeDynCall("vii", "cb") }}}(id, buffer);
157157
};
158158
},
159-
WebGLInputSelectionStart:function(id){
159+
WebGLInputSelectionStart:function(id){
160160
var input = instances[id];
161-
return input.selectionStart;
162-
},
163-
WebGLInputSelectionEnd:function(id){
161+
return input.selectionStart;
162+
},
163+
WebGLInputSelectionEnd:function(id){
164164
var input = instances[id];
165-
return input.selectionEnd;
166-
},
167-
WebGLInputSelectionDirection:function(id){
165+
return input.selectionEnd;
166+
},
167+
WebGLInputSelectionDirection:function(id){
168168
var input = instances[id];
169-
return (input.selectionDirection == "backward")?-1:1;
170-
},
171-
WebGLInputSetSelectionRange:function(id, start, end){
172-
var input = instances[id];
173-
input.setSelectionRange(start, end);
174-
},
175-
WebGLInputMaxLength:function(id, maxlength){
169+
return (input.selectionDirection == "backward")?-1:1;
170+
},
171+
WebGLInputSetSelectionRange:function(id, start, end){
176172
var input = instances[id];
177-
input.maxLength = maxlength;
178-
},
179-
WebGLInputText:function(id, text){
173+
input.setSelectionRange(start, end);
174+
},
175+
WebGLInputMaxLength:function(id, maxlength){
180176
var input = instances[id];
181-
input.value = UTF8ToString(text);
182-
},
183-
WebGLInputDelete:function(id){
177+
input.maxLength = maxlength;
178+
},
179+
WebGLInputText:function(id, text){
180+
var input = instances[id];
181+
input.value = UTF8ToString(text);
182+
},
183+
WebGLInputDelete:function(id){
184184
var input = instances[id];
185185
input.parentNode.removeChild(input);
186186
instances[id] = null;
187187
},
188-
WebGLInputEnableTabText:function(id, enable) {
188+
WebGLInputEnableTabText:function(id, enable) {
189189
var input = instances[id];
190-
input.enableTabText = enable;
191-
},
192-
WebGLInputForceBlur:function(id) {
190+
input.enableTabText = enable;
191+
},
192+
WebGLInputForceBlur:function(id) {
193193
var input = instances[id];
194-
input.blur();
195-
},
194+
input.blur();
195+
},
196196
}
197197

198198
autoAddDeps(WebGLInput, '$instances');

Assets/WebGLSupport/WebGLWindow/WebGLWindow.jslib

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
var WebGLWindow = {
2-
WebGLWindowInit : function() {
2+
WebGLWindowInit : function() {
33
// use WebAssembly.Table : makeDynCall
44
// when enable. dynCall is undefined
55
if(typeof dynCall === "undefined")
66
{
7-
// make Runtime.dynCall to undefined
7+
// make Runtime.dynCall to undefined
88
Runtime = { dynCall : undefined }
99
}
1010
else
1111
{
12-
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
13-
// if Runtime not defined. create and add functon!!
14-
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
12+
// Remove the `Runtime` object from "v1.37.27: 12/24/2017"
13+
// if Runtime not defined. create and add functon!!
14+
if(typeof Runtime === "undefined") Runtime = { dynCall : dynCall }
1515
}
16-
},
16+
},
1717
WebGLWindowGetCanvasName: function() {
1818
var elements = document.getElementsByTagName('canvas');
1919
var returnStr = "";
@@ -26,11 +26,11 @@ var WebGLWindow = {
2626
returnStr = elements[0].parentNode.id = 'WebGLWindow:Canvas:ParentNode';
2727
}
2828
}
29-
var bufferSize = lengthBytesUTF8(returnStr) + 1;
30-
var buffer = _malloc(bufferSize);
31-
stringToUTF8(returnStr, buffer, bufferSize);
29+
var bufferSize = lengthBytesUTF8(returnStr) + 1;
30+
var buffer = _malloc(bufferSize);
31+
stringToUTF8(returnStr, buffer, bufferSize);
3232
return buffer;
33-
},
33+
},
3434
WebGLWindowOnFocus: function (cb) {
3535
window.addEventListener('focus', function () {
3636
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
@@ -41,12 +41,12 @@ var WebGLWindow = {
4141
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
4242
});
4343
},
44-
WebGLWindowOnResize: function(cb) {
44+
WebGLWindowOnResize: function(cb) {
4545
window.addEventListener('resize', function () {
4646
(!!Runtime.dynCall) ? Runtime.dynCall("v", cb, []) : {{{ makeDynCall("v", "cb") }}}();
4747
});
48-
},
49-
WebGLWindowInjectFullscreen : function () {
48+
},
49+
WebGLWindowInjectFullscreen : function () {
5050
document.makeFullscreen = function (id, keepAspectRatio) {
5151
// get fullscreen object
5252
var getFullScreenObject = function () {
@@ -124,7 +124,7 @@ var WebGLWindow = {
124124
canvas.style.height = "100%";
125125

126126
} else {
127-
fullscreenRoot.style.width = beforeWidth + 'px';
127+
fullscreenRoot.style.width = beforeWidth + 'px';
128128
fullscreenRoot.style.height = beforeHeight + 'px';
129129
beforeParent.insertBefore(fullscreenRoot, Array.from(beforeParent.children)[index]);
130130

@@ -151,11 +151,11 @@ var WebGLWindow = {
151151
else if (div.webkitRequestFullScreen) div.webkitRequestFullScreen();
152152
else if (div.msRequestFullscreen) div.msRequestFullscreen();
153153
else if (div.requestFullscreen) div.requestFullscreen();
154-
}
155-
},
154+
}
155+
},
156156
MakeFullscreen : function (str) {
157157
document.makeFullscreen(UTF8ToString(str));
158-
},
158+
},
159159
ExitFullscreen : function() {
160160
// get fullscreen object
161161
var doc = window.document;

0 commit comments

Comments
 (0)