mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
cleanup code
This commit is contained in:
14
html/vr.js
14
html/vr.js
@@ -9,8 +9,6 @@ CefSharp.BindObjectAsync(
|
|||||||
'VRCXStorage',
|
'VRCXStorage',
|
||||||
'SQLite'
|
'SQLite'
|
||||||
).then(function () {
|
).then(function () {
|
||||||
var isObject = (arg) => arg === Object(arg);
|
|
||||||
|
|
||||||
VRCXStorage.GetBool = function (key) {
|
VRCXStorage.GetBool = function (key) {
|
||||||
return this.Get(key) === 'true';
|
return this.Get(key) === 'true';
|
||||||
};
|
};
|
||||||
@@ -56,7 +54,7 @@ CefSharp.BindObjectAsync(
|
|||||||
VRCXStorage.GetObject = function (key) {
|
VRCXStorage.GetObject = function (key) {
|
||||||
try {
|
try {
|
||||||
var object = JSON.parse(this.Get(key));
|
var object = JSON.parse(this.Get(key));
|
||||||
if (isObject(object)) {
|
if (object === Object(object)) {
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -211,7 +209,7 @@ CefSharp.BindObjectAsync(
|
|||||||
var isGetRequest = init.method === 'GET';
|
var isGetRequest = init.method === 'GET';
|
||||||
if (isGetRequest) {
|
if (isGetRequest) {
|
||||||
// transform body to url
|
// transform body to url
|
||||||
if (isObject(params)) {
|
if (params === Object(params)) {
|
||||||
var url = new URL(resource);
|
var url = new URL(resource);
|
||||||
var { searchParams } = url;
|
var { searchParams } = url;
|
||||||
for (var key in params) {
|
for (var key in params) {
|
||||||
@@ -229,7 +227,7 @@ CefSharp.BindObjectAsync(
|
|||||||
'Content-Type': 'application/json;charset=utf-8',
|
'Content-Type': 'application/json;charset=utf-8',
|
||||||
...init.headers
|
...init.headers
|
||||||
};
|
};
|
||||||
init.body = isObject(params)
|
init.body = params === Object(params)
|
||||||
? JSON.stringify(params)
|
? JSON.stringify(params)
|
||||||
: '{}';
|
: '{}';
|
||||||
}
|
}
|
||||||
@@ -242,7 +240,7 @@ CefSharp.BindObjectAsync(
|
|||||||
this.$throw(res.status);
|
this.$throw(res.status);
|
||||||
}).then((json) => {
|
}).then((json) => {
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
if (isObject(json.success)) {
|
if (json.success === Object(json.success)) {
|
||||||
new Noty({
|
new Noty({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
text: escapeTag(json.success.message)
|
text: escapeTag(json.success.message)
|
||||||
@@ -250,8 +248,8 @@ CefSharp.BindObjectAsync(
|
|||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
if (isObject(json)) {
|
if (json === Object(json)) {
|
||||||
if (isObject(json.error)) {
|
if (json.error === Object(json.error)) {
|
||||||
this.$throw(
|
this.$throw(
|
||||||
json.error.status_code || res.status,
|
json.error.status_code || res.status,
|
||||||
json.error.message,
|
json.error.message,
|
||||||
|
|||||||
Reference in New Issue
Block a user