跳转到内容

MediaWiki:Gadget-Purgecache.js:修订间差异

来自萌娘共享
代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot]
标签由机器人或全自动脚本执行的操作
代码变动:103d1a56 - feat: rename (#594) by U:AnnAngela, co-authored-by: GH:github-actions[bot]
标签由机器人或全自动脚本执行的操作
第8行: 第8行:
/* <pre> */
/* <pre> */


"use strict";
"use strict";$(()=>{if(!mw.config.get("wgIsArticle")||"Mainpage"===mw.config.get("wgPageName"))return;const $purgeButton=(e=wgULS("清除页面缓存","清除頁面快取"),t=wgULS("正在清除缓存","正在清除快取"),i=wgULS("清除缓存成功!","清除快取成功!"),a=wgULS("清除缓存失败,点击可重试","清除快取失敗,點選可重試",null,null,"清除快取失敗,點擊可重試"))=>{const n=$('<span class="n-button__content" />').text(e),o=$('<a class="n-button purgecache" />').append(n);let s=!1;return o.on("click",async()=>{if(s)return;n.text(`${t} 0/2`),n.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">'),s=!0;const o=new mw.Api,r={action:"purge",format:"json",forcelinkupdate:!0,titles:mw.config.get("wgPageName")};try{await o.post(r),n.text(`${t} 1/2`),n.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">'),await new Promise(e=>{setTimeout(e,300)}),await o.post(r),n.text(i),setTimeout(location.reload.bind(location),1e3)}catch{n.text(a),s=!1,setTimeout(()=>{s||n.text(e)},5e3)}}),o};"vector"===mw.config.get("skin")?$("#p-personal ul").append($('<li id="pt-purge" />').append($purgeButton())):($("#moe-article-header-top .right-block.flex").prepend($('<div class="flex" id="p-purge-cache"></div>').append($purgeButton().append('<div aria-hidden="true" class="n-base-wave"></div>','<div aria-hidden="true" class="n-button__border"></div>','<div aria-hidden="true" class="n-button__state-border"></div>'))),$("#mobile-page-actions .mobile-edit-button").append($purgeButton(wgULS("清除缓存","清除快取"),wgULS("正在清除","正在清除"),wgULS("清除成功!","清除成功!"),wgULS("清除失败,点击可重试","清除失敗,點選可重試",null,null,"清除失敗,點擊可重試")).append('<div aria-hidden="true" class="n-base-wave"></div>')))});  
$(() => {
    if (!mw.config.get("wgIsArticle") || mw.config.get("wgPageName") === "Mainpage") {
        return;
    }
    const $purgeButton = (buttonText = wgULS("清除页面缓存", "清除頁面快取"), purgingText = wgULS("正在清除缓存", "正在清除快取"), succesText = wgULS("清除缓存成功!", "清除快取成功!"), failText = wgULS("清除缓存失败,点击可重试", "清除快取失敗,點選可重試", null, null, "清除快取失敗,點擊可重試")) => {
        const $statusNode = $('<span class="n-button__content" />').text(buttonText);
        const $containerNode = $('<a class="n-button purgecache" />').append($statusNode);
        let runningStatus = false;
        $containerNode.on("click", async () => {
            if (runningStatus) {
                return;
            }
            $statusNode.text(`${purgingText} 0/2`);
            $statusNode.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">');
            runningStatus = true;
            const api = new mw.Api(), opt = {
                action: "purge",
                format: "json",
                forcelinkupdate: true,
                titles: mw.config.get("wgPageName"),
            };
            try {
                await api.post(opt);
                $statusNode.text(`${purgingText} 1/2`);
                $statusNode.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">');
                await new Promise((res) => {
                    setTimeout(res, 300);
                });
                await api.post(opt);
                $statusNode.text(succesText);
                setTimeout(location.reload.bind(location), 1000);
            }
            catch {
                $statusNode.text(failText);
                runningStatus = false;
                setTimeout(() => {
                    if (!runningStatus) {
                        $statusNode.text(buttonText);
                    }
                }, 5000);
            }
        });
        return $containerNode;
    };
    switch (mw.config.get("skin")) {
        case "vector":
            $("#p-personal ul").append($('<li id="pt-purge" />').append($purgeButton()));
            break;
        case "moeskin":
        default:
            $("#moe-article-header-top .right-block.flex").prepend($('<div class="flex" id="p-purge-cache"></div>').append($purgeButton().append('<div aria-hidden="true" class="n-base-wave"></div>', '<div aria-hidden="true" class="n-button__border"></div>', '<div aria-hidden="true" class="n-button__state-border"></div>')));
            $("#mobile-page-actions .mobile-edit-button").append($purgeButton(wgULS("清除缓存", "清除快取"), wgULS("正在清除", "正在清除"), wgULS("清除成功!", "清除成功!"), wgULS("清除失败,点击可重试", "清除失敗,點選可重試", null, null, "清除失敗,點擊可重試"))
                .append('<div aria-hidden="true" class="n-base-wave"></div>'));
    }
});  


/* </pre> */
/* </pre> */

2025年7月26日 (六) 00:02的版本

/**
 * -------------------------------------------------------------------------
 * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!!
 * -------------------------------------------------------------------------
 */
var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/Purgecache/Gadget-Purgecache.js|user=[[U:AnnAngela]]|co-authors=GH:github-actions[bot]|longId=103d1a563ea4ccc8ff29fb55c9bcd88329a56eb5|shortId=103d1a56|summary=feat: rename (#594)|body=<nowiki>Co-authored-by: github-actions[bot] <41898282+github-actions[bot]📧users.noreply.github.com></nowiki>}}'; 

/* <pre> */

"use strict";$(()=>{if(!mw.config.get("wgIsArticle")||"Mainpage"===mw.config.get("wgPageName"))return;const $purgeButton=(e=wgULS("清除页面缓存","清除頁面快取"),t=wgULS("正在清除缓存","正在清除快取"),i=wgULS("清除缓存成功!","清除快取成功!"),a=wgULS("清除缓存失败,点击可重试","清除快取失敗,點選可重試",null,null,"清除快取失敗,點擊可重試"))=>{const n=$('<span class="n-button__content" />').text(e),o=$('<a class="n-button purgecache" />').append(n);let s=!1;return o.on("click",async()=>{if(s)return;n.text(`${t} 0/2`),n.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">'),s=!0;const o=new mw.Api,r={action:"purge",format:"json",forcelinkupdate:!0,titles:mw.config.get("wgPageName")};try{await o.post(r),n.text(`${t} 1/2`),n.prepend('<img src="https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif" style="height: 1em; margin-top: -.25em;">'),await new Promise(e=>{setTimeout(e,300)}),await o.post(r),n.text(i),setTimeout(location.reload.bind(location),1e3)}catch{n.text(a),s=!1,setTimeout(()=>{s||n.text(e)},5e3)}}),o};"vector"===mw.config.get("skin")?$("#p-personal ul").append($('<li id="pt-purge" />').append($purgeButton())):($("#moe-article-header-top .right-block.flex").prepend($('<div class="flex" id="p-purge-cache"></div>').append($purgeButton().append('<div aria-hidden="true" class="n-base-wave"></div>','<div aria-hidden="true" class="n-button__border"></div>','<div aria-hidden="true" class="n-button__state-border"></div>'))),$("#mobile-page-actions .mobile-edit-button").append($purgeButton(wgULS("清除缓存","清除快取"),wgULS("正在清除","正在清除"),wgULS("清除成功!","清除成功!"),wgULS("清除失败,点击可重试","清除失敗,點選可重試",null,null,"清除失敗,點擊可重試")).append('<div aria-hidden="true" class="n-base-wave"></div>')))}); 

/* </pre> */