diff --git a/app/Controllers/AdminController.php b/app/Controllers/AdminController.php index ddedfda0a..fc21d5c6b 100644 --- a/app/Controllers/AdminController.php +++ b/app/Controllers/AdminController.php @@ -1,33 +1,23 @@ action !== 'DELETE') + CoreUtils::notAllowed(); + + clearstatcache(); + Response::done(); + } } diff --git a/app/Controllers/DiscordAuthController.php b/app/Controllers/DiscordAuthController.php index 2586dcccb..2950c877c 100644 --- a/app/Controllers/DiscordAuthController.php +++ b/app/Controllers/DiscordAuthController.php @@ -130,6 +130,8 @@ private function _setTarget($params){ } public function sync($params){ + Response::fail('The Discord account link got severed, you will need to re-link your account.', ['segway' => true]); + $this->_setTarget($params); $discordUser = $this->_target->discord_member; diff --git a/app/Models/Post.php b/app/Models/Post.php index 741883d46..99581d82a 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -128,7 +128,7 @@ public function get_approval_entry(){ FROM log__post_lock pl LEFT JOIN log l ON l.reftype = 'post_lock' AND l.refid = pl.entryid WHERE $where_query - ORDER BY pl.entryid ASC + ORDER BY pl.entryid LIMIT 1", $where_bind ); } @@ -327,9 +327,9 @@ public function getLi(bool $view_only = false, bool $cachebust_url = false, bool $HTML .= $post_label.$posted_at.$post_type.$reserved_at.$finished_at.$locked_at; if (!empty($this->fullsize)) - $HTML .= " Original image"; + $HTML .= " Original image"; if (!$approved && Permission::sufficient('staff')) - $HTML .= " View open submissions"; + $HTML .= " View open submissions"; } else $HTML .= $post_label.$posted_at.$reserved_at; } @@ -403,7 +403,7 @@ public function getActionsHTML($view_only, bool $hide_reserver_status, bool $ena } if (!empty($Buttons)){ if ($view_only !== false) - $HTML .= "
View
"; + $HTML .= "
View
"; else { $regularButton = \count($Buttons) < 3; foreach ($Buttons as $b){ diff --git a/assets/js/global.jsx b/assets/js/global.jsx index a9440a057..35f5635ea 100644 --- a/assets/js/global.jsx +++ b/assets/js/global.jsx @@ -163,7 +163,7 @@ } if (!cdExists || diff.past){ clearCD(); - $.API.get('/about/upcoming', $.mkAjaxHandler(function(){ + $.API.get('/about/upcoming', function(){ if (!this.status) return console.error(`Failed to load upcoming event list: ${this.message}`); const $uc = $('#upcoming'); @@ -172,7 +172,7 @@ $uc.addClass('hidden'); else $uc.removeClass('hidden'); window.setUpcomingCountdown(); - })); + }); return; } let text; @@ -540,11 +540,11 @@ $.Dialog.wait(title,'Signing out'); - $.API.post('/da-auth/sign-out',$.mkAjaxHandler(function(){ + $.API.post('/da-auth/sign-out', function(){ if (!this.status) return $.Dialog.fail(title,this.message); $.Navigation.reload(); - })); + }); }); }); @@ -556,7 +556,7 @@ if ($sessionUpdating === null) return; - $.API.get('/da-auth/status', $.mkAjaxHandler(function(){ + $.API.get('/da-auth/status', function(){ if ($sessionUpdating === null) return; @@ -568,7 +568,7 @@ if (this.deleted === true) $.Dialog.fail(sessionRefTitle, "We couldn't refresh your DeviantArt session automatically so you have been signed out. Due to elements on the page assuming you are signed in some actions will not work as expected until the page is reloaded."); $sessionUpdating.html(this.loggedIn).removeClass('updating-session'); - })); + }); }, pollInterval); } diff --git a/assets/js/jquery.ponycolorpalette.js b/assets/js/jquery.ponycolorpalette.js index fb20e6bbd..1b8ecc1b8 100644 --- a/assets/js/jquery.ponycolorpalette.js +++ b/assets/js/jquery.ponycolorpalette.js @@ -43,13 +43,13 @@ waitingList[this.appearanceId] = [this]; - $.API.post(`/cg/appearance/${this.appearanceId}/link-targets?hex`, $.mkAjaxHandler(data => { + $.API.post(`/cg/appearance/${this.appearanceId}/link-targets?hex`, data => { if (!data.status) return this.displayError(data.message); $.each(waitingList[this.appearanceId], (_, picker) => { picker.fillSwatchBox(data.list); }); - })); + }); } fillSwatchBox(list){ this.$swatchBox.removeClass('loading').children().first().nextAll().remove(); diff --git a/assets/js/pages/admin/index.js b/assets/js/pages/admin/index.js index 02b8d2f6c..a847c508d 100644 --- a/assets/js/pages/admin/index.js +++ b/assets/js/pages/admin/index.js @@ -80,7 +80,7 @@ const ids = deviationIDArray.join(','); - $.API.post('/admin/mass-approve', { ids }, $.mkAjaxHandler(function(){ + $.API.post('/admin/mass-approve', { ids }, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.html){ @@ -91,10 +91,24 @@ if (this.message) $.Dialog.success(false, this.message, true); else $.Dialog.close(); - })); + }); } })(); + $('#clear-stat-cache').on('click', e => { + e.preventDefault(); + + $.Dialog.wait('Clearing file stat cache'); + + $.API.delete('/admin/stat-cache', function () { + if (!this.status) return $.Dialog.fail(false, this.message); + + if (this.message) + $.Dialog.success(false, this.message, true); + else $.Dialog.close(); + }); + }); + const deviationIO = new IntersectionObserver(entries => { entries.forEach(entry => { if (!entry.isIntersecting) @@ -107,13 +121,13 @@ postID = el.dataset.postId, viewonly = el.dataset.viewonly; - $.API.get(`/post/${postID}/lazyload`,{viewonly},$.mkAjaxHandler(function(){ + $.API.get(`/post/${postID}/lazyload`,{viewonly},function(){ if (!this.status) return $.Dialog.fail(`Cannot load post ${postID}`, this.message); $.loadImages(this.html).then(function(resp){ $(el).closest('.image').replaceWith(resp.$el); }); - })); + }); }); }); const imageIO = new IntersectionObserver(entries => { diff --git a/assets/js/pages/admin/log.js b/assets/js/pages/admin/log.js index 511e5a33c..8a6222043 100644 --- a/assets/js/pages/admin/log.js +++ b/assets/js/pages/admin/log.js @@ -32,7 +32,7 @@ $this.addClass('typcn-times color-red').css('cursor','not-allowed').off('click'); }; - $.API.get(`/admin/logs/details/${EntryID}`,$.mkAjaxHandler(function(){ + $.API.get(`/admin/logs/details/${EntryID}`, function(){ if (!this.status){ if (this.unclickable === true) $this.replaceWith($this.text().trim()); @@ -61,7 +61,7 @@ $dataDiv.insertAfter($this).slideDown(); Time.update(); $this.addClass('typcn-minus color-darkblue'); - })).always(function(){ + }).always(function(){ requesting = false; $this.removeClass('typcn-refresh'); }).fail(fail); diff --git a/assets/js/pages/admin/useful-links.js b/assets/js/pages/admin/useful-links.js index e901341f4..d0106be64 100644 --- a/assets/js/pages/admin/useful-links.js +++ b/assets/js/pages/admin/useful-links.js @@ -13,7 +13,7 @@ $.Dialog.wait(`Editing link #${linkid}`, 'Retrieving link information from server'); - $.API.get(`/admin/usefullinks/${linkid}`,$.mkAjaxHandler(function(){ + $.API.get(`/admin/usefullinks/${linkid}`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); let data = this; @@ -23,7 +23,7 @@ $form.find('input[name=title]').val(data.title); $form.find('select[name=minrole]').val(data.minrole); }); - })); + }); }); $uflol.on('click','.delete-link',function(){ let $li = $(this).closest('[id^=ufl-]'), @@ -34,7 +34,7 @@ $.Dialog.wait(false, 'Removing link'); - $.API.delete(`/admin/usefullinks/${linkId}`,$.mkAjaxHandler(function(){ + $.API.delete(`/admin/usefullinks/${linkId}`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.remove(); @@ -42,7 +42,7 @@ if ($sbUflContainer.is(':empty')) $sbUflContainer.hide(); $.Dialog.close(); - })); + }); }); }); $('#add-link').on('click',function(){ @@ -113,11 +113,11 @@ list.push($(this).find('.typcn-arrow-move').remove().end().attr('id').split('-').pop()); }); - $.API.post('/admin/usefullinks/reorder', {list:list.join(',')}, $.mkAjaxHandler(function(){ + $.API.post('/admin/usefullinks/reorder', {list:list.join(',')}, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); } }); })(); diff --git a/assets/js/pages/admin/wsdiag.js b/assets/js/pages/admin/wsdiag.js index 7f38f0da0..5cede35b3 100644 --- a/assets/js/pages/admin/wsdiag.js +++ b/assets/js/pages/admin/wsdiag.js @@ -131,7 +131,7 @@ $.Dialog.success(false, 'Hello response received', true); }); - $.API.get('/admin/wsdiag/hello', { priv, clientid }, $.mkAjaxHandler(function(){ + $.API.get('/admin/wsdiag/hello', { priv, clientid }, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (!responseReceived) @@ -146,6 +146,6 @@ $w.off('ws-hello'); $.Dialog.fail(false, 'Hello response timed out'); }, timeout); - })); + }); }); })(); diff --git a/assets/js/pages/colorguide/full-list.js b/assets/js/pages/colorguide/full-list.js index 834283c3d..4cd76093c 100644 --- a/assets/js/pages/colorguide/full-list.js +++ b/assets/js/pages/colorguide/full-list.js @@ -84,7 +84,7 @@ if (EQG) data.eqg = true; - $.API.post('/cg/full/reorder', data, $.mkAjaxHandler(function(){ + $.API.post('/cg/full/reorder', data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $fullList.removeClass('sorting').html(this.html); @@ -92,7 +92,7 @@ $ReorderBtn.removeClass('typcn-tick green').addClass('typcn-arrow-unsorted darkblue').html('Re-order'); $ReorderCancelBtn.addClass('hidden'); $.Dialog.close(); - })); + }); } }); diff --git a/assets/js/pages/colorguide/guide.js b/assets/js/pages/colorguide/guide.js index 59aa13b9c..12091416a 100644 --- a/assets/js/pages/colorguide/guide.js +++ b/assets/js/pages/colorguide/guide.js @@ -151,9 +151,9 @@ source: (q, callback) => { if (appearanceAutocompleteCache.has(q)) return callback(appearanceAutocompleteCache.get(q)); - $.API.get(`/cg/appearances`, { q, EQG }, $.mkAjaxHandler(data => { + $.API.get(`/cg/appearances`, { q, EQG }, data => { callback(appearanceAutocompleteCache.set(q, data)); - })); + }); }, templates: { header: () => `
diff --git a/assets/js/pages/colorguide/manage.jsx b/assets/js/pages/colorguide/manage.jsx index defc4bb39..f304739ee 100644 --- a/assets/js/pages/colorguide/manage.jsx +++ b/assets/js/pages/colorguide/manage.jsx @@ -99,11 +99,11 @@ if (!sure) return; $.Dialog.wait(false); - $.API.delete(`/cg/appearance/${appearanceID}/selective`,data,$.mkAjaxHandler(function(){ + $.API.delete(`/cg/appearance/${appearanceID}/selective`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); }); }); }); @@ -114,11 +114,11 @@ let ponyLabel = data.label; $.Dialog.close(); $.Dialog.wait('Manage Cutie Mark of '+ponyLabel, 'Retrieving CM data from server'); - $.API.get(`/cg/appearance/${appearanceId}/cutiemarks`,$.mkAjaxHandler(function(){ + $.API.get(`/cg/appearance/${appearanceId}/cutiemarks`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); CutieMarkEditor.factory(false, appearanceId, ponyLabel, this); - })); + }); }, }, mkPonyEditor = function($this, title, data){ @@ -183,7 +183,7 @@ if (EQG) data.eqg = true; - $.API[editing?'put':'post'](`/cg/appearance${editing?`/${appearanceID}`:''}`,data,$.mkAjaxHandler(data => { + $.API[editing?'put':'post'](`/cg/appearance${editing?`/${appearanceID}`:''}`,data,data => { if (!data.status) return $.Dialog.fail(false, data.message); if (editing){ @@ -207,7 +207,7 @@ if (!data.info) return carryOn(); $.Dialog.segway(title, data.info,'View appearance page',carryOn); - })); + }); }); }); }; @@ -220,11 +220,11 @@ return mkPonyEditor($this,title); $.Dialog.wait(title, 'Checking whether there are available slots'); - $.API.get(`/user/${PersonalGuide}/pcg/slots`,$.mkAjaxHandler(function(){ + $.API.get(`/user/${PersonalGuide}/pcg/slots`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); mkPonyEditor($this,title); - })); + }); }); const $EditTagFormTemplate = $.mk('form','edit-tag'); @@ -338,7 +338,7 @@ if (data.addto && AppearancePage) data.APPEARANCE_PAGE = true; - $.API.post(`/cg/tag`,data,$.mkAjaxHandler(function(){ + $.API.post(`/cg/tag`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.tags){ @@ -347,7 +347,7 @@ } tagAutocompleteCache.clear(); $.Dialog.close(); - })); + }); }); }); } @@ -364,12 +364,12 @@ const data = {}; if (PersonalGuide) data.PERSONAL_GUIDE = PersonalGuide; - $.API.get('/cg/appearances/list',data,$.mkAjaxHandler(function(){ + $.API.get('/cg/appearances/list',data,function(){ if (!this.status) return $.Dialog.fail('Appearance list retrieval', this.message); _list = this.list; fulfill(_list); - })).fail(function(){ + }).fail(function(){ desert(); }); }); @@ -386,12 +386,12 @@ return; } - $.API.get(`/cg/appearance/${appearance_id}/link-targets`,$.mkAjaxHandler(function(){ + $.API.get(`/cg/appearance/${appearance_id}/link-targets`,function(){ if (!this.status) return $.Dialog.fail('Color group list retrieval', this.message); _list[appearance_id] = this.list; fulfill(_list[appearance_id]); - })).fail(function(){ + }).fail(function(){ desert(); }); }); @@ -617,7 +617,7 @@ $.Dialog.wait(false, 'Saving changes'); - $.API[this.editing?'put':'post'](`/cg/colorgroup${this.editing?`/${this.group_id}`:''}`, data, $.mkAjaxHandler(function(){ + $.API[this.editing?'put':'post'](`/cg/colorgroup${this.editing?`/${this.group_id}`:''}`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.cgs){ @@ -648,7 +648,7 @@ $.Dialog.close(); } else $.Dialog.close(); - })); + }); }); if (this.editing) @@ -1056,7 +1056,7 @@ if (AppearancePage) data.APPEARANCE_PAGE = true; $.Dialog.wait(false,'Saving cutie mark data'); - $.API.put(`/cg/appearance/${appearance_id}/cutiemarks`,data,$.mkAjaxHandler(data => { + $.API.put(`/cg/appearance/${appearance_id}/cutiemarks`,data,data => { if (!data.status) return $.Dialog.fail(false, data.message); $.Dialog.close(); @@ -1064,7 +1064,7 @@ this.$cmSection.children(':not(h2,p)').remove(); this.$cmSection.removeClass('hidden').append(data.html); } - })); + }); }).on('change input','.rotation-range',function(e){ let $this = $(e.target), val = $this.val(); @@ -1314,7 +1314,7 @@ let data = {}; if (AppearancePage) data.APPEARANCE_PAGE = true; - $.API.post(`/cg/appearance/${appearanceID}/template`,data,$.mkAjaxHandler(function(){ + $.API.post(`/cg/appearance/${appearanceID}/template`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let $pony = $(`#p${appearanceID}`); @@ -1322,7 +1322,7 @@ ctxmenus(); $.Dialog.close(); - })); + }); }); }; @@ -1610,7 +1610,7 @@ $.Dialog.wait(title, 'Retrieving tag details from server'); - $.API.get(`/cg/tag/${tagID}`,$.mkAjaxHandler(function(){ + $.API.get(`/cg/tag/${tagID}`,function(){ let tag = this; if (this.status) $.Dialog.request(title,$EditTagFormTemplate.clone(true, true).data('tag', tag),'Save', function($form){ $form.find(`input[name=type][value=${tag.type}]`).prop('checked', true); @@ -1626,7 +1626,7 @@ data.APPEARANCE_PAGE = $tag.closest('div[id^=p]').attr('id').replace(/\D/g, ''); $.Dialog.wait(false, 'Saving changes'); - $.API.put(`/cg/tag/${tagID}`, data, $.mkAjaxHandler(function(){ + $.API.put(`/cg/tag/${tagID}`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); let data = this, @@ -1647,11 +1647,11 @@ }); $.Dialog.close(); - })); + }); }); }); else $.Dialog.fail(title, this.message); - })); + }); }}, {text: 'Delete tag', icon: 'trash', click: function(){ let $tag = $(this), @@ -1668,7 +1668,7 @@ (function send(data){ $.Dialog.wait(title,'Sending removal request'); - $.API.delete(`/cg/tag/${tagID}`,data,$.mkAjaxHandler(function(){ + $.API.delete(`/cg/tag/${tagID}`,data,function(){ if (this.status){ let $affected = $('.id-' + tagID); $affected.remove(); @@ -1683,7 +1683,7 @@ send(data); }); else $.Dialog.fail(title, this.message); - })); + }); })(data); }); }}, @@ -1708,7 +1708,7 @@ $.Dialog.wait(title, 'Retrieving color group list from server'); const endpoint = `/cg/appearance/${appearanceID}/colorgroups`; - $.API.get(endpoint, $.mkAjaxHandler(function(){ + $.API.get(endpoint, function(){ if (!this.status) return $.Dialog.fail(false, this.message); let $CGReorderForm = $.mk('form','cg-reorder'), @@ -1744,16 +1744,16 @@ if (AppearancePage) data.APPEARANCE_PAGE = true; - $.API.put(endpoint,data,$.mkAjaxHandler(function(){ + $.API.put(endpoint,data,function(){ if (!this.status) return $.Dialog.fail(null, this.message); $colors.html(this.cgs); ctxmenus(); $.Dialog.close(); - })); + }); }); }); - })); + }); }}, {text: "Create new group", icon: 'folder-add', click: function(){ ColorGroupEditor.factory(`Create color group`, $(this).closest('[id^=p]').attr('id').substring(1)); @@ -1775,11 +1775,11 @@ $.Dialog.wait(title, `Retrieving color group details from server`); - $.API.get(`/cg/colorgroup/${groupID}`,$.mkAjaxHandler(function(){ + $.API.get(`/cg/colorgroup/${groupID}`,function(){ if (!this.status) return $.Dialog.fail(title, this.message); ColorGroupEditor.factory(title, $group, this); - })); + }); }}, {text: `Delete color group`, icon: 'trash', click: function(){ let $group = $(this).closest('li'), @@ -1791,7 +1791,7 @@ $.Dialog.wait(title, 'Sending removal request'); - $.API.delete(`/cg/colorgroup/${groupID}`,$.mkAjaxHandler(function(){ + $.API.delete(`/cg/colorgroup/${groupID}`,function(){ if (this.status){ const $parent = $group.parent(); if ($parent.children().length === 1) @@ -1800,7 +1800,7 @@ $.Dialog.close(); } else $.Dialog.fail(title, this.message); - })); + }); }); }}, $.ctxmenu.separator, @@ -1901,11 +1901,11 @@ $.Dialog.wait(title, 'Downloading external image to the server'); - $.API.post(`/cg/appearance/${appearanceID}/sprite`,{image_url: image_url}, $.mkAjaxHandler(function(){ + $.API.post(`/cg/appearance/${appearanceID}/sprite`,{image_url: image_url}, function(){ if (this.status) $uploadInput.trigger('set-image', [this]); else $.Dialog.fail(title,this.message); - })); + }); }); }); }}, @@ -1917,13 +1917,13 @@ $.Dialog.wait(false, 'Removing image'); - $.API.delete(`/cg/appearance/${appearanceID}/sprite`, $.mkAjaxHandler(function(){ + $.API.delete(`/cg/appearance/${appearanceID}/sprite`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $this.find('img').attr('src', this.sprite); updateSprite(); $.Dialog.close(); - })); + }); }); }} ], 'Sprite image').attr('title', isWebkit ? ' ' : '').on('click',function(e, forced){ @@ -1949,13 +1949,13 @@ $.Dialog.wait(title, 'Retrieving appearance details from server'); - $.API.get(`/cg/appearance/${appearanceID}`,$.mkAjaxHandler(function(){ + $.API.get(`/cg/appearance/${appearanceID}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let data = this; data.appearanceID = appearanceID; mkPonyEditor($this, title, data); - })); + }); }); $('button.delete-appearance').on('click',function(){ let $this = $(this), @@ -1971,7 +1971,7 @@ $.Dialog.wait(title, 'Sending removal request'); - $.API.delete(`/cg/appearance/${appearanceID}`,$.mkAjaxHandler(function(){ + $.API.delete(`/cg/appearance/${appearanceID}`,function(){ if (this.status){ $li.remove(); $.Dialog.success(title, this.message); @@ -1983,7 +1983,7 @@ else $.Navigation.reload(); } else $.Dialog.fail(title, this.message); - })); + }); }); }); $('.section-container').on('click','.edit-show-relations', function(){ @@ -1998,7 +1998,7 @@ $.Dialog.wait(title, 'Retrieving relations from server'); const endpoint = `/cg/appearance/${appearanceID}/guide-relations`; - $.API.get(endpoint, $.mkAjaxHandler(response => { + $.API.get(endpoint, response => { if (!response.status) return $.Dialog.fail(false, response.message); const { SplitSelector } = window.reactComponents; @@ -2022,7 +2022,7 @@ }, }; $.Dialog.request(false, , 'Save'); - })); + }); }).on('click', '.edit-appearance-relations', function() { let $this = $(this), $li = $this.closest('[id^=p]'), @@ -2035,7 +2035,7 @@ $.Dialog.wait(title, 'Retrieving relations from the server'); let $cgRelations = $content.find('section.related'); - $.API.get(`/cg/appearance/${appearanceID}/relations`, $.mkAjaxHandler(function() { + $.API.get(`/cg/appearance/${appearanceID}/relations`, function() { if (!this.status) return $.Dialog.fail(false, this.message); let data = this, @@ -2157,7 +2157,7 @@ }; if (AppearancePage) data.APPEARANCE_PAGE = true; - $.API.put(`/cg/appearance/${appearanceID}/relations`, data, $.mkAjaxHandler(function() { + $.API.put(`/cg/appearance/${appearanceID}/relations`, data, function() { if (!this.status) return $.Dialog.fail(false, this.message); if (this.section){ @@ -2172,10 +2172,10 @@ $cgRelations = { length: 0 }; } $.Dialog.close(); - })); + }); }); }); - })); + }); }); ctxmenus(); @@ -2268,9 +2268,9 @@ source: (s, callback) => { if (tagAutocompleteCache.has(s)) return callback(tagAutocompleteCache.get(s)); - $.API.get(`/cg/tags`, { s }, $.mkAjaxHandler(function(){ + $.API.get(`/cg/tags`, { s }, function(){ callback(tagAutocompleteCache.set(s, this)); - })); + }); }, templates: { suggestion: data => { @@ -2355,25 +2355,25 @@ $editTagsBtn.disable().html('Please wait…'); const appearanceID = $(this).closest('[id^=p]').attr('id').replace(/\D/g, ''); - $.API.get(`/cg/appearance/${appearanceID}/tagged`, $.mkAjaxHandler(function(){ + $.API.get(`/cg/appearance/${appearanceID}/tagged`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); const orig_tags = this.tags; const editor = new TagEditor(orig_tags, tags => { editor.disableButtons(); - $.API.put(`/cg/appearance/${appearanceID}/tagged`, { tags, orig_tags }, $.mkAjaxHandler(function(){ + $.API.put(`/cg/appearance/${appearanceID}/tagged`, { tags, orig_tags }, function(){ if (!this.status){ editor.enableButtons(); return $.Dialog.fail('Saving tags', this.message); } window.location.reload(); - })).fail(() => { + }).fail(() => { editor.enableButtons(); }); }); - })).always(() => { + }).always(() => { $editTagsBtn.html(oldHTML).enable(); }); }); @@ -2388,11 +2388,11 @@ $.Dialog.wait(false); - $.API.post('/cg/reindex',$.mkAjaxHandler(function(){ + $.API.post('/cg/reindex',function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.segway(false, this.message); - })); + }); }); }); @@ -2402,11 +2402,11 @@ $.Dialog.wait(false,'Checking all sprite colors (this might take a while)'); - $.API.post('/cg/sprite-color-checkup',$.mkAjaxHandler(function(){ + $.API.post('/cg/sprite-color-checkup',function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, this.message, true); - })); + }); }); }); })(); diff --git a/assets/js/pages/colorguide/sprite.js b/assets/js/pages/colorguide/sprite.js index d15b888c2..6bba1c0ed 100644 --- a/assets/js/pages/colorguide/sprite.js +++ b/assets/js/pages/colorguide/sprite.js @@ -98,10 +98,10 @@ $.Dialog.wait('Server-side sprite color check'); - $.API.post(`/cg/appearance/${AppearanceID}/sprite/check-colors`, $.mkAjaxHandler(function(){ + $.API.post(`/cg/appearance/${AppearanceID}/sprite/check-colors`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.segway(false, this.message); - })); + }); }); })(); diff --git a/assets/js/pages/colorguide/tag-list.js b/assets/js/pages/colorguide/tag-list.js index 5d03a0947..3ec7e4a4c 100644 --- a/assets/js/pages/colorguide/tag-list.js +++ b/assets/js/pages/colorguide/tag-list.js @@ -12,7 +12,7 @@ $.Dialog.segway(false, this.message ? $.mk('span').attr('class','color-green').html(this.message) : undefined); }, tagUseUpdateHandler = function(successDialog){ - return $.mkAjaxHandler(function(){ + return function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.counts){ @@ -28,7 +28,7 @@ if (successDialog) $.Dialog.success(false, this.message, true); else $.Dialog.close(); - }); + }; }; window.cgTagEditing = function(tagName, tagID, action, $tr){ switch (action){ @@ -38,15 +38,15 @@ $.Dialog.wait(false,'Deleting tag'); - $.API.delete(`/cg/tag/${tagID}`, {sanitycheck: true},$.mkAjaxHandler(function(){ + $.API.delete(`/cg/tag/${tagID}`, {sanitycheck: true},function(){ updateList.call(this, $tr, action); - })); + }); }); break; case "synon": $.Dialog.wait(`Make ${tagName} a synonym`, 'Retrieving tag list from server'); - $.API.get('/cg/tags',{not:tagID,action:action},$.mkAjaxHandler(function(){ + $.API.get('/cg/tags',{not:tagID,action:action},function(){ if (!this.length){ if (this.undo) return window.cgTagEditing.call(this, tagName, tagID, 'unsynon', $tr); @@ -88,12 +88,12 @@ let sent = $form.mkData(); $.Dialog.wait(false, 'Creating tag synonym'); - $.API.put(`/cg/tag/${tagID}/synonym`,sent, $.mkAjaxHandler(function(data){ + $.API.put(`/cg/tag/${tagID}/synonym`,sent, function(data){ updateList.call(data, $tr, action); - })); + }); }); }); - })); + }); break; case "unsynon": { let message = this.message; @@ -115,9 +115,9 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Removing synonym'); - $.API.delete(`/cg/tag/${tagID}/synonym`,data,$.mkAjaxHandler(function(){ + $.API.delete(`/cg/tag/${tagID}/synonym`,data,function(){ updateList.call(this, $tr, action); - })); + }); }); }); }); diff --git a/assets/js/pages/event/list-manage.js b/assets/js/pages/event/list-manage.js index ba28cd34d..a2632413b 100644 --- a/assets/js/pages/event/list-manage.js +++ b/assets/js/pages/event/list-manage.js @@ -192,13 +192,13 @@ $.Dialog.wait(title, 'Retrieving event details from server'); - $.API.get(`/event/${eventID}`,$.mkAjaxHandler(function(){ + $.API.get(`/event/${eventID}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let data = this; data.eventID = eventID; mkEventEditor($this, title, data); - })); + }); }); $content.on('click','[id^=event-] .finalize-event',function(e){ e.preventDefault(); @@ -221,12 +221,12 @@ const data = $form.mkData(); $.Dialog.wait(false,'Finalizing event'); - $.API.post(`/event/${eventID}/finalize`,data,$.mkAjaxHandler(function(){ + $.API.post(`/event/${eventID}/finalize`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, 'Event finalized successfully'); $.Navigation.reload(true); - })); + }); }); }); }); @@ -244,7 +244,7 @@ $.Dialog.wait(false); - $.API.delete(`/event/${eventid}`,$.mkAjaxHandler(function(){ + $.API.delete(`/event/${eventid}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (EventPage){ @@ -255,7 +255,7 @@ } $.Navigation.reload(true); - })); + }); }); }); })(); diff --git a/assets/js/pages/event/view.js b/assets/js/pages/event/view.js index 32bc0965b..e87d5eefb 100644 --- a/assets/js/pages/event/view.js +++ b/assets/js/pages/event/view.js @@ -43,7 +43,7 @@ $.Dialog.wait('New entry','Checking whether you can submit any more entries'); - $.API.get(`/event/${eventID}/check-entries`,$.mkAjaxHandler(function(){ + $.API.get(`/event/${eventID}/check-entries`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.message) @@ -56,15 +56,15 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Submitting your entry'); - $.API.post(`/event/${eventID}/entry`,data,$.mkAjaxHandler(function(){ + $.API.post(`/event/${eventID}/entry`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $eventEntries.html(this.entrylist).rebindFluidbox(); $.Dialog.close(); - })); + }); }); }); - })); + }); }); $eventEntries.rebindFluidbox().on('click','.edit-entry', function(e){ @@ -75,7 +75,7 @@ $.Dialog.wait(`Editing entry #${entryID}`,'Retrieving entry details from server'); - $.API.get(`/event/entry/${entryID}`,$.mkAjaxHandler(function(){ + $.API.get(`/event/entry/${entryID}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let data = this; @@ -93,15 +93,15 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Saving changes'); - $.API.put(`/event/entry/${entryID}`,data,$.mkAjaxHandler(function(){ + $.API.put(`/event/entry/${entryID}`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.html(this.entryhtml).rebindFluidbox(); $.Dialog.close(); - })); + }); }); }); - })); + }); }); $eventEntries.on('click','.delete-entry', function(e){ @@ -116,14 +116,14 @@ $.Dialog.wait(false, 'Sending deletion request'); - $.API.delete(`/event/entry/${entryID}`,$.mkAjaxHandler(function(){ + $.API.delete(`/event/entry/${entryID}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.close(); $li.fadeOut(500,function(){ $li.remove(); }); - })); + }); }); }); @@ -137,7 +137,7 @@ un = $btn.hasClass('clicked'); $btn.siblings('button').addBack().disable(); - $.API[un?'delete':'post'](`/event/entry/${entryID}/vote`,{value},$.mkAjaxHandler(function(){ + $.API[un?'delete':'post'](`/event/entry/${entryID}/vote`,{value},function(){ let $otherBtn = $btn.siblings('button'); if (!this.disable) $otherBtn.addBack().enable(); @@ -149,7 +149,7 @@ $btn.siblings('.score').text(this.score); $eventEntries.triggerHandler('reorder-items'); - })); + }); }).on('reorder-items',function(){ if ($eventEntries.find('.voting').length === 0) return; @@ -168,13 +168,13 @@ $entry = this, entryID = $entry.attr('id').split('-')[1]; - $.API.get(`/event/entry/${entryID}/vote`,$.mkAjaxHandler(function(){ + $.API.get(`/event/entry/${entryID}/vote`,function(){ if (!this.status) return $.Dialog.fail('Refresh voting buttons of entry #'+entryID, this.message); $entry.find('.voting').replaceWith(this.voting); $eventEntries.triggerHandler('reorder-items'); - })); + }); }; if (window.EventType === 'contest') @@ -191,7 +191,7 @@ const { entryid } = el.dataset; - $.API.get(`/event/entry/${entryid}/lazyload`,$.mkAjaxHandler(function(){ + $.API.get(`/event/entry/${entryid}/lazyload`,function(){ if (!this.status) return $.Dialog.fail(`Failed to load preview for entry #${entryid}`, this.message); $.loadImages(this.html).then(function(resp){ @@ -200,7 +200,7 @@ $el.replaceWith(resp.$el); $parent.rebindFluidbox(); }); - })); + }); }); }); diff --git a/assets/js/pages/show/index-manage.jsx b/assets/js/pages/show/index-manage.jsx index a0be06818..77d6d188e 100644 --- a/assets/js/pages/show/index-manage.jsx +++ b/assets/js/pages/show/index-manage.jsx @@ -111,7 +111,7 @@ $this.disable(); - $.API.get('/show/prefill', $.mkAjaxHandler(function(){ + $.API.get('/show/prefill', function(){ if (!this.status) return $.Dialog.fail(false, this.message); let airs = setSat830(this.airday); @@ -124,7 +124,7 @@ }, (name, value) => { $form.find(`[name=${name}]`).val(value); }); - })).always(function(){ + }).always(function(){ $this.enable(); }); }) @@ -148,13 +148,13 @@ const what = is_episode ? 'episode' : 'show entry'; $.Dialog.wait(false, `Adding ${what} to database`); - $.API.post('/show', data, $.mkAjaxHandler(function(){ + $.API.post('/show', data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.wait(false, `Opening ${what} page`, true); $.Navigation.visit(this.url); - })); + }); }); }); }); @@ -171,7 +171,7 @@ $.Dialog.wait(`Editing show entry #${id}`); const endpoint = `/show/${id}`; - $.API.get(endpoint, $.mkAjaxHandler(function(){ + $.API.get(endpoint, function(){ if (!this.status) return $.Dialog.fail(false,this.message); const { show } = this; @@ -215,15 +215,15 @@ $.Dialog.wait(false, 'Saving changes'); - $.API.put(endpoint, data, $.mkAjaxHandler(function(){ + $.API.put(endpoint, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.wait(false, 'Updating page', true); $.Navigation.reload(); - })); + }); }); }); - })); + }); } $content.on('click','#edit-show',EditEp); $tables.on('click', '.edit-show', EditEp).on('click', '.delete-show', function(e){ @@ -239,11 +239,11 @@ $.Dialog.wait(false, 'Removing episode'); - $.API.delete(`/show/${id}`, $.mkAjaxHandler(function(){ + $.API.delete(`/show/${id}`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); }); }); })(); diff --git a/assets/js/pages/show/manage.jsx b/assets/js/pages/show/manage.jsx index 8c94c12cc..e88efc2e0 100644 --- a/assets/js/pages/show/manage.jsx +++ b/assets/js/pages/show/manage.jsx @@ -11,7 +11,7 @@ $.Dialog.wait('Set video links', 'Requesting links from the server'); const endpoint = `/show/${showId}/video-data`; - $.API.get(endpoint, $.mkAjaxHandler(function(){ + $.API.get(endpoint, function(){ const data = this; const { type } = data; @@ -74,7 +74,7 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Saving links'); - $.API.put(endpoint, data, $.mkAjaxHandler(function() { + $.API.put(endpoint, data, function() { if (!this.status) return $.Dialog.fail(false, this.message); if (this.epsection){ @@ -90,17 +90,17 @@ $epSection = {length:0}; } $.Dialog.close(); - })); + }); }); }); - })); + }); }); $('#cg-relations').on('click',function(){ $.Dialog.wait('Guide relation editor', 'Retrieving relations from server'); const endpoint = `/show/${showId}/guide-relations`; - $.API.get(endpoint, $.mkAjaxHandler(response => { + $.API.get(endpoint, response => { if (!response.status) return $.Dialog.fail(false, response.message); const { SplitSelector } = window.reactComponents; @@ -124,7 +124,7 @@ }, }; $.Dialog.request(false, , 'Save'); - })); + }); }); $('#edit-about_reservations, #edit-reservation_rules').on('click', function(e){ @@ -137,7 +137,7 @@ let text = $h2c.text().trim(); $.Dialog.wait(`Editing "${text}"`,"Retrieving setting's value"); - $.API.get(`/setting/${endpoint}`,$.mkAjaxHandler(function(){ + $.API.get(`/setting/${endpoint}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let $EditorForm = $.mk('form', `${endpoint}-editor`), @@ -156,16 +156,16 @@ let data = { value: dataEditor.getValue() }; $.Dialog.wait(false, 'Saving'); - $.API.put(`/setting/${endpoint}`, data, $.mkAjaxHandler(function(){ + $.API.put(`/setting/${endpoint}`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $h2.siblings().remove(); $h2.parent().append(this.value); $.Dialog.close(); - })); + }); }); }); - })); + }); }); function reservePost($li, reserveAs, id){ @@ -173,7 +173,7 @@ send = function(data){ $.Dialog.wait(title, 'Sending reservation to the server'); - $.API.post(`/post/${id}/reservation`, data, $.mkAjaxHandler(function(){ + $.API.post(`/post/${id}/reservation`, data, function(){ if (this.retry) return $.Dialog.confirm(false, this.message, function(sure){ if (!sure) return; @@ -193,7 +193,7 @@ $newli.rebindFluidbox(); } $.Dialog.close(); - })); + }); }; if (typeof USERNAME_REGEX === 'undefined' || !reserveAs) @@ -249,7 +249,7 @@ $.Dialog.wait(`Editing post #${id}`, `Retrieving details`); - $.API.get(`/post/${id}`,$.mkAjaxHandler(function(data){ + $.API.get(`/post/${id}`,function(data){ if (!data.status) return $.Dialog.fail(false, data.message); let $PostEditForm = $.mk('form').attr('id', 'post-edit-form').append( @@ -430,16 +430,16 @@ $.Dialog.wait(false, 'Saving changes'); - $.API.put(`/post/${id}`,newData, $.mkAjaxHandler(function(){ + $.API.put(`/post/${id}`,newData, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.reloadLi(); $.Dialog.close(); - })); + }); }); }); - })); + }); }) .on('click','li[id] .cancel',function(e){ e.preventDefault(); @@ -454,21 +454,21 @@ $li.addClass('deleting'); if (type === 'request') - $.API.delete(`/post/${id}/reservation`, $.mkAjaxHandler(function(){ + $.API.delete(`/post/${id}/reservation`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.removeClass('deleting').reloadLi(false); $.Dialog.close(); - })); + }); else { - $.API.delete(`/post/${id}/reservation`, $.mkAjaxHandler(function(){ + $.API.delete(`/post/${id}/reservation`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.close(); return $li[window.withinMobileBreakpoint()?'slideUp':'fadeOut'](500,function(){ $li.remove(); }); - })); + }); } }); }) @@ -513,7 +513,7 @@ (function attempt(){ $.Dialog.wait(false, 'Marking post as finished'); - $.API.put(`/post/${id}/finish`,sent_data,$.mkAjaxHandler(function(data){ + $.API.put(`/post/${id}/finish`,sent_data,function(data){ if (data.status){ $.Dialog.success(false, `${Type} has been marked as finished`); @@ -534,7 +534,7 @@ }); } else $.Dialog.fail(false, data.message); - })); + }); })(); }); }); @@ -572,12 +572,12 @@ $.Dialog.wait(false, 'Removing "finished" flag'+(unbind?' & unbinding from user':'')); - $.API.delete(`/post/${id}/finish${unbind?'?unbind':''}`,$.mkAjaxHandler(function(){ + $.API.delete(`/post/${id}/finish${unbind?'?unbind':''}`,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, typeof this.message !== 'undefined' ? this.message : '"finished" flag removed successfully'); $(`#${type}s`).trigger('pls-update'); - })); + }); }); }); }) @@ -589,13 +589,13 @@ $.Dialog.wait('Submission approval status','Checking'); - $.API.post(`/post/${id}/approval`, $.mkAjaxHandler(function(){ + $.API.post(`/post/${id}/approval`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); let message = this.message; $li.reloadLi(); $.Dialog.success(false, message, true); - })); + }); }) .on('click','li[id] .unlock',function(e){ e.preventDefault(); @@ -608,11 +608,11 @@ $.Dialog.wait(false); - $.API.delete(`/post/${id}/approval`, $.mkAjaxHandler(function(){ + $.API.delete(`/post/${id}/approval`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.closest('.posts').trigger('pls-update'); - })); + }); }); }) .on('click','li[id] .delete',function(e){ @@ -627,7 +627,7 @@ $.Dialog.wait(false); $li.addClass('deleting'); - $.API.delete(`/post/request/${id}`,$.mkAjaxHandler(function(){ + $.API.delete(`/post/request/${id}`,function(){ if (!this.status){ $li.removeClass('deleting'); return $.Dialog.fail(false, this.message); @@ -637,7 +637,7 @@ $li[window.withinMobileBreakpoint()?'slideUp':'fadeOut'](500,() => { $li.remove(); }); - })); + }); }); }) .on('click','li[id] .pls-transfer',function(e){ @@ -656,7 +656,7 @@ $.Dialog.wait(false); - $.API.post(`/post/${id}/transfer`,$.mkAjaxHandler(function(){ + $.API.post(`/post/${id}/transfer`,function(){ if (this.canreserve) return $.Dialog.confirm(false, this.message, function(sure){ if (!sure) return; @@ -667,7 +667,7 @@ return $.Dialog.fail(false, this.message); $.Dialog.success(false, this.message, true); - })); + }); }); }); $body @@ -703,7 +703,7 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Replacing image'); - $.API.put(`/post/${id}/image`,data,$.mkAjaxHandler(function(){ + $.API.put(`/post/${id}/image`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, 'Image has been updated', true); @@ -717,7 +717,7 @@ $newli.rebindFluidbox(); } else $li.reloadLi(); - })); + }); }); }); }) @@ -729,7 +729,7 @@ $.Dialog.close(); $.Dialog.wait('Fix Sta.sh fullsize URL', 'Fixing Sta.sh full size image URL'); - $.API.post(`/post/${id}/fix-stash`, $.mkAjaxHandler(function() { + $.API.post(`/post/${id}/fix-stash`, function() { if (!this.status){ if (this.rmdirect){ if (!finished){ @@ -743,7 +743,7 @@ $fullsize_link.attr('href', this.fullsize); $.Dialog.success(false, 'Fix successful', true); - })); + }); }) .on('click', '#dialog-clear-broken-status', function(e){ e.preventDefault(); @@ -753,7 +753,7 @@ $.Dialog.close(); $.Dialog.wait('Clear post broken status', 'Checking image availability'); - $.API.get(`/post/${id}/unbreak`, $.mkAjaxHandler(function() { + $.API.get(`/post/${id}/unbreak`, function() { if (!this.status) return $.Dialog.fail(false, this.message); if (this.li){ @@ -766,6 +766,6 @@ } $.Dialog.close(); - })); + }); }); })(); diff --git a/assets/js/pages/show/view.js b/assets/js/pages/show/view.js index f2f0c15b2..7f8112d20 100644 --- a/assets/js/pages/show/view.js +++ b/assets/js/pages/show/view.js @@ -84,7 +84,7 @@ $.Dialog.wait(false, 'Submitting your rating'); - $.API.post(`/show/${showId}/vote`,data,$.mkAjaxHandler(function(){ + $.API.post(`/show/${showId}/vote`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); let $section = $voteButton.closest('section'); @@ -92,7 +92,7 @@ $section.append(this.newhtml); $voting.bindDetails(); $.Dialog.close(); - })); + }); }); }); }); @@ -101,13 +101,13 @@ if (diff.past !== true) return; if (!$voting.children('.rate').length){ - $.API.get(`/show/${showId}/vote?html`,$.mkAjaxHandler(function(){ + $.API.get(`/show/${showId}/vote?html`,function(){ if (!this.status) return $.Dialog.fail('Display voting buttons',this.message); $voting.children('h2').nextAll().remove(); $voting.append(this.html); $voting.bindDetails(); - })); + }); $(this).removeData('dyntime-beforeupdate'); return false; } @@ -120,7 +120,7 @@ $.Dialog.wait('Voting details','Getting vote distribution information'); - $.API.get(`/show/${showId}/vote`, $.mkAjaxHandler(function(){ + $.API.get(`/show/${showId}/vote`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); const $ul = $.mk('ul'); @@ -141,7 +141,7 @@ $.mk('p').text("Here's how the votes are distributed:"), $.mk('div').attr('id','vote-distrib').append($ul, $bars) ]); - })); + }); }); }; $voting.bindDetails(); @@ -188,7 +188,7 @@ Kinds = $.capitalize(kinds); if (silent !== true) $.Dialog.wait($.Dialog.isOpen() ? false : Kinds, `Updating list of ${kinds}`, true); - $.API.get(`/show/${showId}/posts`, {section:kinds}, $.mkAjaxHandler(function(){ + $.API.get(`/show/${showId}/posts`, {section:kinds}, function(){ if (!this.status) return $.Dialog.fail(false, this.message); let $newChildren = $(this.render).filter('section').children(); @@ -201,7 +201,7 @@ callback(); else if (silent !== true) $.Dialog.close(); - })); + }); }); $posts.find('li[id]').each(function(){ $(this).rebindFluidbox(); @@ -260,7 +260,7 @@ deviation, show_id: showId, }; - $.API.post('/post/reservation',data,$.mkAjaxHandler(function(){ + $.API.post('/post/reservation',data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, this.message); @@ -268,7 +268,7 @@ $.Dialog.close(); window.location.hash = `#${this.id}`; }]); - })); + }); }); }); }); @@ -299,7 +299,7 @@ imgCheckDisabler(true); $.Dialog.wait(title,'Checking image, this can take a bit of time'); - $.API.post('/post/check-image', { image_url }, $.mkAjaxHandler(function(){ + $.API.post('/post/check-image', { image_url }, function(){ let data = this; if (!data.status){ $notice.children('p:not(.keep)').remove(); @@ -349,7 +349,7 @@ }); } load(data, 0); - })); + }); } $formImgCheck.on('click', function(e){ e.preventDefault(); @@ -397,7 +397,7 @@ (function submit(){ $.Dialog.wait(title,'Submitting post'); - $.API.post('/post',data,$.mkAjaxHandler(function(){ + $.API.post('/post',data,function(){ if (!this.status){ if (!this.canforce) return $.Dialog.fail(false, this.message); @@ -423,7 +423,7 @@ }); window.location.hash = '#'+id; }]); - })); + }); })(); }).on('reset',function(){ $formImgCheck.prop('disabled', false).addClass('red'); @@ -447,7 +447,7 @@ const { postId, viewonly } = el.dataset; - $.API.get(`/post/${postId}/lazyload`,{viewonly},$.mkAjaxHandler(function(){ + $.API.get(`/post/${postId}/lazyload`,{viewonly},function(){ const $el = $(el); if (!this.status){ $el.trigger('error'); @@ -457,7 +457,7 @@ $.loadImages(this.html).then(function(resp){ $el.trigger(resp.e).closest('.image').replaceWith(resp.$el); }); - })); + }); }); }); const screencapIO = new IntersectionObserver(entries => { @@ -512,7 +512,7 @@ const { id } = el.dataset; - $.API.get(`/show/${id}/synopsis`,$.mkAjaxHandler(function(){ + $.API.get(`/show/${id}/synopsis`,function(){ const $el = $(el); const $section = $el.closest('section'); if (!this.status){ @@ -528,7 +528,7 @@ $section.html(resp.$el); $section.find('.synopsis-image').fluidboxThis(); }); - })); + }); }); }); @@ -559,7 +559,7 @@ if (log) console.log(`[POST-FIX] Attempting to reload post #${id}`); - $.API.get(`/post/${id}/reload`,{cache:log},$.mkAjaxHandler(function(){ + $.API.get(`/post/${id}/reload`,{cache:log},function(){ reloading[_idAttr] = false; if (!this.status) return; if (this.broken === true){ @@ -586,7 +586,7 @@ if (log) console.log(`[POST-FIX] Reloaded post #${id}`); $.callCallback(callback); - })); + }); return this; }; @@ -614,7 +614,7 @@ const title = 'Scroll post into view'; // Attempt to find the post as a last resort, it might be on a different episode page const postID = location.hash.replace(/\D/g,''); - $.API.post(`/post/${postID}/locate`, { show_id: showId }, $.mkAjaxHandler(function(){ + $.API.post(`/post/${postID}/locate`, { show_id: showId }, function(){ if (!this.status) return $.Dialog.info(title, this.message); if (this.refresh){ @@ -648,7 +648,7 @@ $.Navigation.visit(castle.url); }); }); - })); + }); } } @@ -669,7 +669,7 @@ if (typeof $embedWrap === 'undefined'){ $.Dialog.wait($showPlayers.text()); - $.API.get(`/show/${showId}/video-embeds`, $.mkAjaxHandler(function(){ + $.API.get(`/show/${showId}/video-embeds`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (this.parts === 2){ @@ -686,7 +686,7 @@ .text('Hide on-site player') .triggerHandler('scroll-video-into-view'); $.Dialog.close(); - })); + }); } else { let show = $showPlayers.hasClass('typcn-eye'); @@ -711,7 +711,7 @@ $.Dialog.wait(false, 'Sending report'); - $.API.post(`/show/${showId}/broken-videos`, $.mkAjaxHandler(function(){ + $.API.post(`/show/${showId}/broken-videos`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (typeof this.epsection !== 'undefined'){ @@ -723,7 +723,7 @@ } $.Dialog.success(false, this.message, true); - })); + }); }); }); } diff --git a/assets/js/pages/user/manage.js b/assets/js/pages/user/manage.js index 83ea32d69..bbf65c9bc 100644 --- a/assets/js/pages/user/manage.js +++ b/assets/js/pages/user/manage.js @@ -4,7 +4,6 @@ if (typeof window.ROLES === 'undefined') return; let $briefing = $content.children('.briefing'), - name = $briefing.find('.username').text().trim(), $currRole = $briefing.find('.role-label'), currRole = $currRole.text().trim(), $RoleModFormTemplate = $.mk('form').attr('id','rolemod').html(''), @@ -29,14 +28,14 @@ let data = $form.mkData(); $.Dialog.wait(false,'Moving user to the new group'); - $.API.put(`/user/${userId}/role`, data, $.mkAjaxHandler(function(){ + $.API.put(`/user/${userId}/role`, data, function(){ if (this.already_in === true) return $.Dialog.close(); if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); }); }); }); @@ -53,11 +52,11 @@ let data = $form.mkData(); $.Dialog.wait(false,'Changing role mask'); - $.API.put(`/setting/dev_role_label`, data, $.mkAjaxHandler(function(){ + $.API.put(`/setting/dev_role_label`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); }); }); }); diff --git a/assets/js/pages/user/pcg-slots.js b/assets/js/pages/user/pcg-slots.js index f21a8a9a0..bee9af42f 100644 --- a/assets/js/pages/user/pcg-slots.js +++ b/assets/js/pages/user/pcg-slots.js @@ -16,11 +16,11 @@ if (!sure) return; $.Dialog.wait(false, 'Recalculating'); - $.API.post(`/user/${userId}/pcg/point-history/recalc`, $.mkAjaxHandler(function(){ + $.API.post(`/user/${userId}/pcg/point-history/recalc`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); } ); }); @@ -31,7 +31,7 @@ $.Dialog.wait(`Pending gifts for ${username}`, 'Checking for pending gifts'); - $.API.get(`/user/${userId}/pcg/pending-gifts`, $.mkAjaxHandler(function(){ + $.API.get(`/user/${userId}/pcg/pending-gifts`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); if (!this.pendingGifts) @@ -96,13 +96,13 @@ $.Dialog.wait(false, 'Refunding selected gifts'); - $.API.post('/user/pcg/refund-gifts', { giftids: ids.join(',') }, $.mkAjaxHandler(function(){ + $.API.post('/user/pcg/refund-gifts', { giftids: ids.join(',') }, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, this.message, true); - })); + }); }); }); - })); + }); }); })(); diff --git a/assets/js/pages/user/profile.js b/assets/js/pages/user/profile.js index 9ce67b7d9..50cff7243 100644 --- a/assets/js/pages/user/profile.js +++ b/assets/js/pages/user/profile.js @@ -31,7 +31,7 @@ $.Dialog.wait(false, 'Cancelling reservation'); let postId = $link.prop('hash').substring(1).split('-')[1]; - $.API.delete(`/post/${postId}/reservation`,{from:'profile'},$.mkAjaxHandler(function(){ + $.API.delete(`/post/${postId}/reservation`,{from:'profile'},function(){ if (!this.status) return $.Dialog.fail(false, this.message); let pendingRes = this.pendingReservations; @@ -43,7 +43,7 @@ } }); $.Dialog.close(); - })); + }); }); }); $pendingRes.on('click','button.fix',function(){ @@ -71,12 +71,12 @@ let data = $form.mkData(); $.Dialog.wait(false, 'Replacing image'); - $.API.put(`/post/${id}/image`,data,$.mkAjaxHandler(function(){ + $.API.put(`/post/${id}/image`,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, 'Image has been updated'); $.Navigation.reload(true); - })); + }); }); }); }); @@ -89,7 +89,7 @@ $.Dialog.wait(`Gifting PCG slots to ${username}`, 'Checking your available slot count'); - $.API.get('/user/pcg/giftable-slots', $.mkAjaxHandler(function(){ + $.API.get('/user/pcg/giftable-slots', function(){ if (!this.status) return $.Dialog.fail(false, this.message); const availableSlots = this.avail; @@ -125,15 +125,15 @@ $.Dialog.wait(false, 'Sending gift'); - $.API.post(`/user/${userId}/pcg/slots`, data, $.mkAjaxHandler(function(){ + $.API.post(`/user/${userId}/pcg/slots`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.success(false, this.message, true); - })); + }); }); }); }); - })); + }); }); } @@ -144,7 +144,7 @@ $.Dialog.wait('Giving PCG points to '+username, "Checking user's total points"); - $.API.get(`/user/${userId}/pcg/points`, $.mkAjaxHandler(function(){ + $.API.get(`/user/${userId}/pcg/points`, function(){ const $GiveForm = $.mk('form','pcg-point-give-form').append( $.mk('label').append( `

Choose how many points you want to give. Enter a negative number to take points. You cannot take more points than what the user has, and the free slot cannot be taken away.

Remember, 10 points = 1 slot!

`, @@ -186,15 +186,15 @@ $.Dialog.wait(false, 'Giving points'); - $.API.post(`/user/${userId}/pcg/points`, data, $.mkAjaxHandler(function(){ + $.API.post(`/user/${userId}/pcg/points`, data, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Dialog.segway(false, this.message); - })); + }); }); }); }); - })); + }); }); } @@ -225,7 +225,7 @@ $.Dialog.wait(title,`Signing out of ${browser}${platform}`); - $.API.delete(`/user/session/${sessionID}`, $.mkAjaxHandler(function(){ + $.API.delete(`/user/session/${sessionID}`, function(){ if (!this.status) return $.Dialog.fail(title,this.message); if ($li.siblings().length !== 0){ @@ -234,7 +234,7 @@ } $.Navigation.reload(true); - })); + }); }); }); $sessionList.find('button.useragent').on('click', function(e){ @@ -249,11 +249,11 @@ $.Dialog.wait(false, 'Signing out'); - $.API.post('/da-auth/signout?everywhere',{name: username},$.mkAjaxHandler(function(){ + $.API.post('/da-auth/signout?everywhere',{name: username},function(){ if (!this.status) return $.Dialog.fail(false, this.message); $.Navigation.reload(true); - })); + }); }); }); @@ -321,7 +321,7 @@ const { postId, viewonly } = el.dataset; - $.API.get(`/post/${postId}/lazyload`, { viewonly }, $.mkAjaxHandler(({ status, message, html }) => { + $.API.get(`/post/${postId}/lazyload`, { viewonly }, ({ status, message, html }) => { const $el = $(el); if (!status){ $el.trigger('error'); @@ -335,7 +335,7 @@ if (title) $li.children('.label').removeClass('hidden').find('a').text(title); }); - })); + }); }); }); @@ -350,12 +350,12 @@ $.Dialog.wait('Deviation acceptance status', 'Checking'); - $.API.post(`/post/${id}/approval`, $.mkAjaxHandler(function(){ + $.API.post(`/post/${id}/approval`, function(){ if (!this.status) return $.Dialog.fail(false, this.message); $li.remove(); $.Dialog.success(false, this.message, true); - })); + }); }); function settingChanged(which,from,to_what){ @@ -395,7 +395,7 @@ $(`.provider-${from}:not(.avatar-wrap)`).removeClass('provider-'+from).addClass('provider-'+to_what); let error = false; $.each(forUser, (forId, elements) => { - $.API.get(`/user/${forId}/avatar-wrap`, $.mkAjaxHandler(function(){ + $.API.get(`/user/${forId}/avatar-wrap`, function(){ if (!this.status){ error = true; return $.Dialog.fail(`Update avatar elements for ${forId}`, false); @@ -404,7 +404,7 @@ $.each(elements, (_, $el) => { $el.replaceWith(this.html); }); - })); + }); }); if (!error) $.Dialog.close(); @@ -440,7 +440,7 @@ $.Dialog.wait('Saving setting','Please wait'); - $.API.put(endpoint,data,$.mkAjaxHandler(function(){ + $.API.put(endpoint,data,function(){ if (!this.status) return $.Dialog.fail(false, this.message); if ($input.is('[type=number]')) @@ -452,7 +452,7 @@ $input.data('orig', this.value).triggerHandler('change'); settingChanged(endpoint.split('/').pop(), orig, this.value); - })); + }); }); $slbl.children('input[type=number]').each(function(){ let $el = $(this); diff --git a/assets/js/pages/user/suggestion.js b/assets/js/pages/user/suggestion.js index e826f40ac..1616a705e 100644 --- a/assets/js/pages/user/suggestion.js +++ b/assets/js/pages/user/suggestion.js @@ -21,7 +21,7 @@ $btn.disable(); - $.API.get('/post/request/suggestion',{already_loaded: already_loaded.join(',')},$.mkAjaxHandler(function(){ + $.API.get('/post/request/suggestion',{already_loaded: already_loaded.join(',')},function(){ if (!this.status){ $btn.enable(); return $.Dialog.fail(false, this.message); @@ -42,16 +42,16 @@ }); $result.find('.reserve-request').on('click',function(){ let $this = $(this); - $.API.post(`/post/${postID}/reservation`,{from:'suggestion'},$.mkAjaxHandler(function(){ + $.API.post(`/post/${postID}/reservation`,{from:'suggestion'},function(){ if (!this.status) return $.Dialog.fail(false, this.message); $this.replaceWith(this.button); $pendingReservations.html($(this.pendingReservations).children()); - })); + }); }); $output.html($result); $btn.enable(); - })).fail(function(){ + }).fail(function(){ $btn.enable(); }); }); diff --git a/assets/js/react-components.jsx b/assets/js/react-components.jsx index 9e57e5537..b919d2070 100644 --- a/assets/js/react-components.jsx +++ b/assets/js/react-components.jsx @@ -59,11 +59,11 @@ $.Dialog.wait(false, 'Saving changes'); - $.API.put(this.props.endpoint, { ids }, $.mkAjaxHandler(data => { + $.API.put(this.props.endpoint, { ids }, data => { if (!data.status) return $.Dialog.fail(false, data.message); this.props.onSuccess(data); - })); + }); } handleSearch(e){ diff --git a/assets/js/shared-utils.js b/assets/js/shared-utils.js index 6f5ab9610..1ca3b6179 100644 --- a/assets/js/shared-utils.js +++ b/assets/js/shared-utils.js @@ -924,12 +924,12 @@ return; } - $.API.get(this._endpoint.replace('%d', id),this._params,$.mkAjaxHandler(data => { + $.API.get(this._endpoint.replace('%d', id),this._params,data => { if (!data.status) return $.Dialog.fail('Cache entry retrieval', data.message); this._list[id] = data.list; res(this._list[id]); - })).fail(() => rej()); + }).fail(() => rej()); }); } } @@ -963,7 +963,11 @@ $.each(['get','post','put','delete'], (i, el) => { ((method) => { $.API[method] = function(url, ...args) { - return $[method]($.API.API_PATH+url, ...args); + const lastArg = args.slice(-1)[0]; + if (typeof lastArg === 'function'){ + args.splice(-1, 1, $.mkAjaxHandler(lastArg)); + } + return $[method]($.API.API_PATH + url, ...args); }; })(el); }); diff --git a/assets/js/websocket.js b/assets/js/websocket.js index 11aabb6ff..655ef9e2e 100644 --- a/assets/js/websocket.js +++ b/assets/js/websocket.js @@ -3,8 +3,7 @@ "use strict"; const $scriptTag = $('#wss'); - let conn, - connpath = $scriptTag.attr('src').replace(/^(.*?:\d+\/).*$/,'$1'), + let connpath = $scriptTag.attr('src').replace(/^(.*?:\d+\/).*$/,'$1'), wsdecoder = f => data => { if (typeof data === 'string'){ @@ -69,13 +68,13 @@ $notifCnt.empty(); }); } - else $.API.get('/notif',$.mkAjaxHandler(data => { + else $.API.get('/notif', data => { $notifCnt.text(cnt); $notifSbList.html(data.list); Time.update(); this.bindMarkRead(); $notifSb.stop().slideDown(); - })); + }); })); this.conn.on('post-delete', wsdecoder(data => { if (!data.id) @@ -113,7 +112,7 @@ if ($(`.posts #post-${data.id}`).length > 0) return; - $.API.get(`/post/${data.id}/reload`,$.mkAjaxHandler(resp => { + $.API.get(`/post/${data.id}/reload`, resp => { if (!resp.status) return; if ($(`.posts #post-${data.id}`).length > 0) @@ -124,7 +123,7 @@ Time.update(); $newli.rebindHandlers().parent().reorderPosts(); console.log(`[WS] Post added (id=${data.id}) to container ${this.section}`); - })); + }); })); this.conn.on('post-update', wsdecoder(data => { if (!data.id) @@ -281,14 +280,14 @@ send = () => { $el.siblings('.mark-read').addBack().addClass('disabled'); - $.API.post(`/notif/${nid}/mark-read`,data,$.mkAjaxHandler(data => { + $.API.post(`/notif/${nid}/mark-read`,data, data => { if (!data.status) return $.Dialog.fail(title, data.message); if (data.message) return $.Dialog.success(title, data.message, true); $.Dialog.close(); - })).always(() => { + }).always(() => { $el.siblings('.mark-read').addBack().removeClass('disabled'); }); }; diff --git a/config/routes/private_api.php b/config/routes/private_api.php index a4d5a22e0..121fd6275 100644 --- a/config/routes/private_api.php +++ b/config/routes/private_api.php @@ -17,6 +17,7 @@ $private_api_endpoint('/admin/wsdiag/hello', 'AdminController#wshello'); $private_api_endpoint('/admin/mass-approve', 'AdminController#massApprove'); $private_api_endpoint('/admin/notices/[i:id]?', 'AdminController#noticesApi'); +$private_api_endpoint('/admin/stat-cache', 'AdminController#statCacheApi'); $private_api_endpoint('/cg/appearances', 'AppearanceController#autocomplete'); $private_api_endpoint('/cg/appearances/list', 'AppearanceController#listApi'); $private_api_endpoint('/cg/appearance/[i:id]?', 'AppearanceController#api'); diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig index 98c2d02a6..5645d1a64 100644 --- a/templates/admin/index.html.twig +++ b/templates/admin/index.html.twig @@ -7,17 +7,21 @@ {% extends "layout/base.html.twig" %} {% block content %} +{% set is_dev = permission('developer') %}

{{ title }}

Various tools related to managing the site

Logs Notices - {% if permission('developer') %} + {% if is_dev %} WS {% endif %} Useful Links PCG Appearances + {% if is_dev %} + + {% endif %}
@@ -25,7 +29,7 @@
- {% if permission('developer') %} + {% if is_dev %}

Elasticsearch status

{% if elastic_down %}