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