mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-27 17:58:22 +01:00
fix some travis bug
This commit is contained in:
parent
9281cfb8db
commit
ae11223c0c
@ -239,7 +239,7 @@ namespace OS {
|
|||||||
return range;
|
return range;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ant.__ = function (...args: any[]): FormattedString | string {
|
Ant.__ = function(...args: any[]): FormattedString | string {
|
||||||
if (!(args.length > 0)) {
|
if (!(args.length > 0)) {
|
||||||
return "Undefined";
|
return "Undefined";
|
||||||
}
|
}
|
||||||
@ -251,7 +251,7 @@ namespace OS {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ant.__e = function (e: Error): Error {
|
Ant.__e = function(e: Error): Error {
|
||||||
const reason = new Error(e.toString());
|
const reason = new Error(e.toString());
|
||||||
reason.stack += "\nCaused By:\n" + e.stack;
|
reason.stack += "\nCaused By:\n" + e.stack;
|
||||||
return reason;
|
return reason;
|
||||||
@ -611,7 +611,7 @@ namespace OS {
|
|||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
String.prototype.hash = function (): number {
|
String.prototype.hash = function(): number {
|
||||||
let hash = 5381;
|
let hash = 5381;
|
||||||
let i = this.length;
|
let i = this.length;
|
||||||
while (i) {
|
while (i) {
|
||||||
@ -619,10 +619,10 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
return hash >>> 0;
|
return hash >>> 0;
|
||||||
};
|
};
|
||||||
String.prototype.__v = function (): Version {
|
String.prototype.__v = function(): Version {
|
||||||
return new Version(this);
|
return new Version(this);
|
||||||
};
|
};
|
||||||
String.prototype.asBase64 = function (): string {
|
String.prototype.asBase64 = function(): string {
|
||||||
const tmp = encodeURIComponent(this);
|
const tmp = encodeURIComponent(this);
|
||||||
return btoa(
|
return btoa(
|
||||||
tmp.replace(/%([0-9A-F]{2})/g, (match, p1) =>
|
tmp.replace(/%([0-9A-F]{2})/g, (match, p1) =>
|
||||||
@ -630,8 +630,8 @@ namespace OS {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
String.prototype.escape = function (): string {
|
String.prototype.escape = function(): string {
|
||||||
return this.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function (
|
return this.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function(
|
||||||
c: string
|
c: string
|
||||||
) {
|
) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -658,11 +658,11 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
String.prototype.unescape = function (): string {
|
String.prototype.unescape = function(): string {
|
||||||
let json = JSON.parse(`{ "text": "${this}"}`)
|
let json = JSON.parse(`{ "text": "${this}"}`)
|
||||||
return json.text;
|
return json.text;
|
||||||
};
|
};
|
||||||
String.prototype.asUint8Array = function (): Uint8Array {
|
String.prototype.asUint8Array = function(): Uint8Array {
|
||||||
let bytes = [];
|
let bytes = [];
|
||||||
for (
|
for (
|
||||||
let i = 0, end = this.length - 1, asc = 0 <= end;
|
let i = 0, end = this.length - 1, asc = 0 <= end;
|
||||||
@ -675,8 +675,8 @@ namespace OS {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (!String.prototype.format) {
|
if (!String.prototype.format) {
|
||||||
String.prototype.format = function (...args: any[]): string {
|
String.prototype.format = function(...args: any[]): string {
|
||||||
return this.replace(/{(\d+)}/g, function (
|
return this.replace(/{(\d+)}/g, function(
|
||||||
match: string,
|
match: string,
|
||||||
number: number
|
number: number
|
||||||
) {
|
) {
|
||||||
@ -689,38 +689,38 @@ namespace OS {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
String.prototype.f = function (...args: any[]): FormattedString {
|
String.prototype.f = function(...args: any[]): FormattedString {
|
||||||
return new FormattedString(this, args);
|
return new FormattedString(this, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.__ = function (): string {
|
String.prototype.__ = function(): string {
|
||||||
const match = this.match(/^__\((.*)\)$/);
|
const match = this.match(/^__\((.*)\)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
return match[1].l();
|
return match[1].l();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
String.prototype.l = function (): string {
|
String.prototype.l = function(): string {
|
||||||
if (!API.lang[this]) {
|
if (!API.lang[this]) {
|
||||||
API.lang[this] = this;
|
API.lang[this] = this;
|
||||||
}
|
}
|
||||||
return API.lang[this];
|
return API.lang[this];
|
||||||
};
|
};
|
||||||
String.prototype.trimLeft = function (charlist: string): string {
|
String.prototype.trimLeft = function(charlist: string): string {
|
||||||
if (charlist === undefined) charlist = "s";
|
if (charlist === undefined) charlist = "s";
|
||||||
|
|
||||||
return this.replace(new RegExp("^[" + charlist + "]+"), "");
|
return this.replace(new RegExp("^[" + charlist + "]+"), "") as string;
|
||||||
};
|
};
|
||||||
String.prototype.trimRight = function (charlist: string): string {
|
String.prototype.trimRight = function(charlist: string): string {
|
||||||
if (charlist === undefined) charlist = "s";
|
if (charlist === undefined) charlist = "s";
|
||||||
|
|
||||||
return this.replace(new RegExp("[" + charlist + "]+$"), "");
|
return this.replace(new RegExp("[" + charlist + "]+$"), "") as string;
|
||||||
};
|
};
|
||||||
|
|
||||||
String.prototype.trimBy = function (charlist: string) {
|
String.prototype.trimBy = function(charlist: string): string {
|
||||||
return this.trimLeft(charlist).trimRight(charlist);
|
return this.trimLeft(charlist).trimRight(charlist) as string;
|
||||||
};
|
};
|
||||||
Date.prototype.toString = function (): string {
|
Date.prototype.toString = function(): string {
|
||||||
let dd = this.getDate();
|
let dd = this.getDate();
|
||||||
let mm = this.getMonth() + 1;
|
let mm = this.getMonth() + 1;
|
||||||
const yyyy = this.getFullYear();
|
const yyyy = this.getFullYear();
|
||||||
@ -746,7 +746,7 @@ namespace OS {
|
|||||||
return `${dd}/${mm}/${yyyy} ${hh}:${mi}:${se}`;
|
return `${dd}/${mm}/${yyyy} ${hh}:${mi}:${se}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
Date.prototype.timestamp = function (): number {
|
Date.prototype.timestamp = function(): number {
|
||||||
return (this.getTime() / 1000) | 0;
|
return (this.getTime() / 1000) | 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -825,7 +825,7 @@ namespace OS {
|
|||||||
console.log("Booting system");
|
console.log("Booting system");
|
||||||
API.handle
|
API.handle
|
||||||
.auth()
|
.auth()
|
||||||
.then(function (d: API.RequestResult) {
|
.then(function(d: API.RequestResult) {
|
||||||
// in case someone call it more than once :)
|
// in case someone call it more than once :)
|
||||||
if (d.error) {
|
if (d.error) {
|
||||||
// show login screen
|
// show login screen
|
||||||
@ -860,7 +860,7 @@ namespace OS {
|
|||||||
}
|
}
|
||||||
API.handle
|
API.handle
|
||||||
.setting()
|
.setting()
|
||||||
.then(function (r: any) {
|
.then(function(r: any) {
|
||||||
cleanup();
|
cleanup();
|
||||||
return API.handle.logout().then((d: any) => boot());
|
return API.handle.logout().then((d: any) => boot());
|
||||||
})
|
})
|
||||||
@ -1113,7 +1113,7 @@ namespace OS {
|
|||||||
* @returns {Promise<any>} a promise on the result data
|
* @returns {Promise<any>} a promise on the result data
|
||||||
*/
|
*/
|
||||||
export function post(p: string, d: any): Promise<any> {
|
export function post(p: string, d: any): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const q = announcer.getMID();
|
const q = announcer.getMID();
|
||||||
API.loading(q, p);
|
API.loading(q, p);
|
||||||
return $.ajax({
|
return $.ajax({
|
||||||
@ -1122,7 +1122,7 @@ namespace OS {
|
|||||||
contentType: "application/json",
|
contentType: "application/json",
|
||||||
data: JSON.stringify(
|
data: JSON.stringify(
|
||||||
d,
|
d,
|
||||||
function (k, v) {
|
function(k, v) {
|
||||||
if (k === "domel") {
|
if (k === "domel") {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -1133,11 +1133,11 @@ namespace OS {
|
|||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: null,
|
success: null,
|
||||||
})
|
})
|
||||||
.done(function (data) {
|
.done(function(data) {
|
||||||
API.loaded(q, p, "OK");
|
API.loaded(q, p, "OK");
|
||||||
return resolve(data);
|
return resolve(data);
|
||||||
})
|
})
|
||||||
.fail(function (j, s, e) {
|
.fail(function(j, s, e) {
|
||||||
API.loaded(q, p, "FAIL");
|
API.loaded(q, p, "FAIL");
|
||||||
return reject(API.throwe(s));
|
return reject(API.throwe(s));
|
||||||
});
|
});
|
||||||
@ -1156,12 +1156,12 @@ namespace OS {
|
|||||||
* @returns {Promise<ArrayBuffer>} a promise on the returned binary data
|
* @returns {Promise<ArrayBuffer>} a promise on the returned binary data
|
||||||
*/
|
*/
|
||||||
export function blob(p: string): Promise<ArrayBuffer> {
|
export function blob(p: string): Promise<ArrayBuffer> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const q = announcer.getMID();
|
const q = announcer.getMID();
|
||||||
const r = new XMLHttpRequest();
|
const r = new XMLHttpRequest();
|
||||||
r.open("GET", p, true);
|
r.open("GET", p, true);
|
||||||
r.responseType = "arraybuffer";
|
r.responseType = "arraybuffer";
|
||||||
r.onload = function (e) {
|
r.onload = function(e) {
|
||||||
if (this.status === 200 && this.readyState === 4) {
|
if (this.status === 200 && this.readyState === 4) {
|
||||||
API.loaded(q, p, "OK");
|
API.loaded(q, p, "OK");
|
||||||
resolve(this.response);
|
resolve(this.response);
|
||||||
@ -1186,13 +1186,13 @@ namespace OS {
|
|||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export function upload(p: string, d: string): Promise<any> {
|
export function upload(p: string, d: string): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const q = announcer.getMID();
|
const q = announcer.getMID();
|
||||||
//insert a temporal file selector
|
//insert a temporal file selector
|
||||||
const o = $("<input>")
|
const o = $("<input>")
|
||||||
.attr("type", "file")
|
.attr("type", "file")
|
||||||
.css("display", "none");
|
.css("display", "none");
|
||||||
o.change(function () {
|
o.change(function() {
|
||||||
API.loading(q, p);
|
API.loading(q, p);
|
||||||
const formd = new FormData();
|
const formd = new FormData();
|
||||||
formd.append("path", d);
|
formd.append("path", d);
|
||||||
@ -1206,12 +1206,12 @@ namespace OS {
|
|||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
})
|
})
|
||||||
.done(function (data) {
|
.done(function(data) {
|
||||||
API.loaded(q, p, "OK");
|
API.loaded(q, p, "OK");
|
||||||
resolve(data);
|
resolve(data);
|
||||||
return o.remove();
|
return o.remove();
|
||||||
})
|
})
|
||||||
.fail(function (j, s, e) {
|
.fail(function(j, s, e) {
|
||||||
API.loaded(q, p, "FAIL");
|
API.loaded(q, p, "FAIL");
|
||||||
reject(API.throwe(s));
|
reject(API.throwe(s));
|
||||||
return o.remove();
|
return o.remove();
|
||||||
@ -1291,7 +1291,7 @@ namespace OS {
|
|||||||
* @returns {Promise<any>} a Promise on the requested data
|
* @returns {Promise<any>} a Promise on the requested data
|
||||||
*/
|
*/
|
||||||
export function get(p: string, t: string = undefined): Promise<any> {
|
export function get(p: string, t: string = undefined): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const conf: any = {
|
const conf: any = {
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: p,
|
url: p,
|
||||||
@ -1302,11 +1302,11 @@ namespace OS {
|
|||||||
const q = announcer.getMID();
|
const q = announcer.getMID();
|
||||||
API.loading(q, p);
|
API.loading(q, p);
|
||||||
return $.ajax(conf)
|
return $.ajax(conf)
|
||||||
.done(function (data) {
|
.done(function(data) {
|
||||||
API.loaded(q, p, "OK");
|
API.loaded(q, p, "OK");
|
||||||
return resolve(data);
|
return resolve(data);
|
||||||
})
|
})
|
||||||
.fail(function (j, s, e) {
|
.fail(function(j, s, e) {
|
||||||
API.loaded(q, p, "FAIL");
|
API.loaded(q, p, "FAIL");
|
||||||
return reject(API.throwe(s));
|
return reject(API.throwe(s));
|
||||||
});
|
});
|
||||||
@ -1362,14 +1362,14 @@ namespace OS {
|
|||||||
* @returns {Promise<any>} a promise on the result data
|
* @returns {Promise<any>} a promise on the result data
|
||||||
*/
|
*/
|
||||||
export function requires(l: string): Promise<any> {
|
export function requires(l: string): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
if (!API.shared[l]) {
|
if (!API.shared[l]) {
|
||||||
const libfp = l.asFileHandle();
|
const libfp = l.asFileHandle();
|
||||||
switch (libfp.ext) {
|
switch (libfp.ext) {
|
||||||
case "css":
|
case "css":
|
||||||
return libfp
|
return libfp
|
||||||
.onready()
|
.onready()
|
||||||
.then(function () {
|
.then(function() {
|
||||||
$("<link>", {
|
$("<link>", {
|
||||||
rel: "stylesheet",
|
rel: "stylesheet",
|
||||||
type: "text/css",
|
type: "text/css",
|
||||||
@ -1383,7 +1383,7 @@ namespace OS {
|
|||||||
.catch((e: Error) => reject(__e(e)));
|
.catch((e: Error) => reject(__e(e)));
|
||||||
case "js":
|
case "js":
|
||||||
return API.script(libfp.getlink())
|
return API.script(libfp.getlink())
|
||||||
.then(function (data: any) {
|
.then(function(data: any) {
|
||||||
API.shared[l] = true;
|
API.shared[l] = true;
|
||||||
console.log("Loaded :", l);
|
console.log("Loaded :", l);
|
||||||
announcer.trigger("sharedlibraryloaded", l);
|
announcer.trigger("sharedlibraryloaded", l);
|
||||||
@ -1411,11 +1411,11 @@ namespace OS {
|
|||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export function require(libs: string[]): Promise<any> {
|
export function require(libs: string[]): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
if (!(libs.length > 0)) {
|
if (!(libs.length > 0)) {
|
||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
announcer.observable.one("sharedlibraryloaded", async function (
|
announcer.observable.one("sharedlibraryloaded", async function(
|
||||||
l
|
l
|
||||||
) {
|
) {
|
||||||
libs.splice(0, 1);
|
libs.splice(0, 1);
|
||||||
@ -1586,7 +1586,7 @@ namespace OS {
|
|||||||
* @returns {Promise<any>}
|
* @returns {Promise<any>}
|
||||||
*/
|
*/
|
||||||
export function setLocale(name: string): Promise<any> {
|
export function setLocale(name: string): Promise<any> {
|
||||||
return new Promise(async function (resolve, reject) {
|
return new Promise(async function(resolve, reject) {
|
||||||
const path = `resources/languages/${name}.json`;
|
const path = `resources/languages/${name}.json`;
|
||||||
try {
|
try {
|
||||||
const d = await API.get(path, "json");
|
const d = await API.get(path, "json");
|
||||||
@ -1641,7 +1641,7 @@ namespace OS {
|
|||||||
* @returns {Promise<any>} Promise on the clipboard data
|
* @returns {Promise<any>} Promise on the clipboard data
|
||||||
*/
|
*/
|
||||||
export function getClipboard(): Promise<any> {
|
export function getClipboard(): Promise<any> {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
const $el = $("#clipboard");
|
const $el = $("#clipboard");
|
||||||
if (!navigator.clipboard) {
|
if (!navigator.clipboard) {
|
||||||
return resolve($el.val());
|
return resolve($el.val());
|
||||||
@ -1685,7 +1685,7 @@ namespace OS {
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: p,
|
value: p,
|
||||||
});
|
});
|
||||||
const fn = function (o: any, v: any) {
|
const fn = function(o: any, v: any) {
|
||||||
return Object.defineProperty(o, v, {
|
return Object.defineProperty(o, v, {
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
set(value) {
|
set(value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user