Auto formatters used

# HTML
- VSCode built-in formatter
- `/index.html`

# JS
- https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
- `/js/*.js`

# CSS
- https://marketplace.visualstudio.com/items?itemName=aeschli.vscode-css-formatter
- `/styles/*.css`

# XML
- https://marketplace.visualstudio.com/items?itemName=DotJoshJohnson.xml
- `/locale/*.xml`
This commit is contained in:
bilogic
2022-09-11 15:10:08 +08:00
parent 8951e68ac1
commit df11e6f960
44 changed files with 6458 additions and 5661 deletions
+99 -82
View File
@@ -1,93 +1,110 @@
/* --------------------- window ------------ */
SQL.Window = function(owner) {
this.owner = owner;
this.dom = {
container:OZ.$("window"),
background:OZ.$("background"),
ok:OZ.$("windowok"),
cancel:OZ.$("windowcancel"),
title:OZ.$("windowtitle"),
content:OZ.$("windowcontent"),
throbber:OZ.$("throbber")
}
this.dom.ok.value = _("windowok");
this.dom.cancel.value = _("windowcancel");
this.dom.throbber.alt = this.dom.throbber.title = _("throbber");
OZ.Event.add(this.dom.ok, "click", this.ok.bind(this));
OZ.Event.add(this.dom.cancel, "click", this.close.bind(this));
OZ.Event.add(document, "keydown", this.key.bind(this));
this.sync = this.sync.bind(this);
OZ.Event.add(window, "scroll", this.sync);
OZ.Event.add(window, "resize", this.sync);
this.state = 0;
this.hideThrobber();
this.sync();
}
SQL.Window = function (owner) {
this.owner = owner;
this.dom = {
container: OZ.$("window"),
background: OZ.$("background"),
ok: OZ.$("windowok"),
cancel: OZ.$("windowcancel"),
title: OZ.$("windowtitle"),
content: OZ.$("windowcontent"),
throbber: OZ.$("throbber"),
};
this.dom.ok.value = _("windowok");
this.dom.cancel.value = _("windowcancel");
this.dom.throbber.alt = this.dom.throbber.title = _("throbber");
OZ.Event.add(this.dom.ok, "click", this.ok.bind(this));
OZ.Event.add(this.dom.cancel, "click", this.close.bind(this));
OZ.Event.add(document, "keydown", this.key.bind(this));
SQL.Window.prototype.showThrobber = function() {
this.dom.throbber.style.visibility = "";
}
this.sync = this.sync.bind(this);
SQL.Window.prototype.hideThrobber = function() {
this.dom.throbber.style.visibility = "hidden";
}
OZ.Event.add(window, "scroll", this.sync);
OZ.Event.add(window, "resize", this.sync);
this.state = 0;
this.hideThrobber();
SQL.Window.prototype.open = function(title, content, callback) {
this.state = 1;
this.callback = callback;
while (this.dom.title.childNodes.length > 1) { this.dom.title.removeChild(this.dom.title.childNodes[1]); }
this.sync();
};
var txt = OZ.DOM.text(title);
this.dom.title.appendChild(txt);
this.dom.background.style.visibility = "visible";
OZ.DOM.clear(this.dom.content);
this.dom.content.appendChild(content);
var win = OZ.DOM.win();
var scroll = OZ.DOM.scroll();
this.dom.container.style.left = Math.round(scroll[0] + (win[0] - this.dom.container.offsetWidth)/2)+"px";
this.dom.container.style.top = Math.round(scroll[1] + (win[1] - this.dom.container.offsetHeight)/2)+"px";
this.dom.cancel.style.visibility = (this.callback ? "" : "hidden");
this.dom.container.style.visibility = "visible";
SQL.Window.prototype.showThrobber = function () {
this.dom.throbber.style.visibility = "";
};
var formElements = ["input","select","textarea"];
var all = this.dom.container.getElementsByTagName("*");
for (var i=0;i<all.length;i++) {
if (formElements.indexOf(all[i].tagName.toLowerCase()) != -1) {
all[i].focus();
break;
}
}
}
SQL.Window.prototype.hideThrobber = function () {
this.dom.throbber.style.visibility = "hidden";
};
SQL.Window.prototype.key = function(e) {
if (!this.state) { return; }
if (e.keyCode == 13) { this.ok(e); }
if (e.keyCode == 27) { this.close(); }
}
SQL.Window.prototype.open = function (title, content, callback) {
this.state = 1;
this.callback = callback;
while (this.dom.title.childNodes.length > 1) {
this.dom.title.removeChild(this.dom.title.childNodes[1]);
}
SQL.Window.prototype.ok = function(e) {
if (this.callback) { this.callback(); }
this.close();
}
var txt = OZ.DOM.text(title);
this.dom.title.appendChild(txt);
this.dom.background.style.visibility = "visible";
OZ.DOM.clear(this.dom.content);
this.dom.content.appendChild(content);
SQL.Window.prototype.close = function() {
if (!this.state) { return; }
this.state = 0;
this.dom.background.style.visibility = "hidden";
this.dom.container.style.visibility = "hidden";
}
var win = OZ.DOM.win();
var scroll = OZ.DOM.scroll();
this.dom.container.style.left =
Math.round(scroll[0] + (win[0] - this.dom.container.offsetWidth) / 2) +
"px";
this.dom.container.style.top =
Math.round(scroll[1] + (win[1] - this.dom.container.offsetHeight) / 2) +
"px";
SQL.Window.prototype.sync = function() { /* adjust background position */
var dims = OZ.DOM.win();
var scroll = OZ.DOM.scroll();
this.dom.background.style.width = dims[0]+"px";
this.dom.background.style.height = dims[1]+"px";
this.dom.background.style.left = scroll[0]+"px";
this.dom.background.style.top = scroll[1]+"px";
}
this.dom.cancel.style.visibility = this.callback ? "" : "hidden";
this.dom.container.style.visibility = "visible";
var formElements = ["input", "select", "textarea"];
var all = this.dom.container.getElementsByTagName("*");
for (var i = 0; i < all.length; i++) {
if (formElements.indexOf(all[i].tagName.toLowerCase()) != -1) {
all[i].focus();
break;
}
}
};
SQL.Window.prototype.key = function (e) {
if (!this.state) {
return;
}
if (e.keyCode == 13) {
this.ok(e);
}
if (e.keyCode == 27) {
this.close();
}
};
SQL.Window.prototype.ok = function (e) {
if (this.callback) {
this.callback();
}
this.close();
};
SQL.Window.prototype.close = function () {
if (!this.state) {
return;
}
this.state = 0;
this.dom.background.style.visibility = "hidden";
this.dom.container.style.visibility = "hidden";
};
SQL.Window.prototype.sync = function () {
/* adjust background position */
var dims = OZ.DOM.win();
var scroll = OZ.DOM.scroll();
this.dom.background.style.width = dims[0] + "px";
this.dom.background.style.height = dims[1] + "px";
this.dom.background.style.left = scroll[0] + "px";
this.dom.background.style.top = scroll[1] + "px";
};