User:ItsP-dog/global.js

/* MIT License Copyright (c) 2020 7o'clock Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * ExtendedPageMaker * Version 0.9 */ !function(e,a,t){if(!("object"==typeof localStorage&&localStorage.optoutExtendedPageMaker||a.cookie("optoutExtendedPageMaker"))){importArticle({type:"style",article:"u:speedcubesolving:MediaWiki:ExtendedPageMaker.css"});var i,o=e.ExtendedPageMakerMessages=e.ExtendedPageMakerMessages||{New_Page:"New_Page",NewPage:"New Page",CreateANewPage:"Create A New Page",main:"Main",blog:"Blog",category:"Category",MediaWiki:"MediaWiki",Template:"Template",Forum:"Forum",PageTitle:"Page Title",PageLayout:"Page Layout",Blank:"Blank Page",Standard:"Standard Populated Layout",Create:"Create",NeedName:"Please give the name of a page to create.",BlogURL:"Special:CreateBlogPage",forumDomain:"Topic:",genericError:"An error occurred. Please check your input and try again.",alreadyExists:'Page $page already exists. Edit it or rename your page.',processing:"Processing previous request. Please wait."},n=new t.Api;a(function{var e='   &times; '+o.CreateANewPage+' '+o.main+'  '+o.blog+'  '+o.category+'  '+o.MediaWiki+'  '+o.Template+'  <label name="option" style="color: #1111FF; font-weight: bold;" class="extended-page-maker-option"><input type="radio" name="namespace" value="forum">'+o.Forum+'  <input type="text" id="NewPageTitle" placeholder="'+o.PageTitle+'" style="height:2.5em; width:99%;"/>  '+o.PageLayout+' <ul id="CreatePageDialogChoices"> <li id="CreatePageDialogBlankContainer" class="chooser accent" style="width: 50%"> <input type="radio" name="pagecontent" id="ExtendedPageMakerBlankContent" value="blank" checked="checked">'+o.Blank+'<img src="https://slot1-images.wikia.nocookie.net/__cb1590604275294/common/extensions/wikia/CreatePage/images/thumbnail_blank.png"> </li><li id="CreatePageDialogFormatContainer" class="chooser" style="width: 50%"> <input type="radio" name="pagecontent" value="populated">'+o.Standard+'<img src="https://slot1-images.wikia.nocookie.net/__cb1590604275294/common/extensions/wikia/CreatePage/images/thumbnail_format_video.png"> </li></ul> <button id="createpage" type="button" style="float: right; height:2.6em; width:10em; font-weight:700;" type="button">'+o.Create+"    ";function t{a("#ExtendedPageMakerModal").removeClass("opened"),a("#ExtendedPageMakerOptionMain, #ExtendedPageMakerBlankContent").prop("checked",!0),a(".chooser.accent").removeClass("accent"),a("#CreatePageDialogBlankContainer").addClass("accent"),a("#NewPageTitle").val(""),a("#ExtendedPageMakerErrors").html(""),a("#createpage").text("Create"),a("#NewPageTitle").show,i=!1}a("body").append(e),a(window).click(function(e){"ExtendedPageMakerModal"===e.target.id&&t}),a("#ExtendedPageMakerModal .close").click(function(e){t}),a(".createpage").off.click(function(e){e.preventDefault,e.stopImmediatePropagation,e.stopPropagation,a("#ExtendedPageMakerModal").addClass("opened")}),a("#p-search, #quickbar").append(a("",{href:url}).append(a(" ",{id:"newpagebutton",css:{height:"2em",width:"10em","font-weight":700},text:o.NewPage}))),a("#createpage").click(function(e){r}),a("#ExtendedPageMakerModal label").mousedown(function(e){(a(this).find('input[name="namespace"]').length&&!a(this).find("input:checked").length&&a("#ExtendedPageMakerErrors").html(""),a(this).find('input[name="namespace"]').length)&&("blog"===a(this).find('input[name="namespace"]').val?(a("#createpage").text("Create Blog Post"),a("#NewPageTitle").hide):(a("#createpage").text("Create"),a("#NewPageTitle").show));a(this).find('input[type="radio"]').prop("checked",!0)}),a("#CreatePageDialogChoices li label").click(function(e){var t=a(this).closest("li");t.hasClass("accent")||(a("li.chooser.accent").removeClass("accent"),t.addClass("accent"))}),a("#NewPageTitle").keypress(function(e){13===e.which&&r}).keydown(function(e){a("#ExtendedPageMakerErrors").html("")})})}function r{if(a("#ExtendedPageMakerErrors").html(""),i)a("#ExtendedPageMakerErrors").text(o.processing);else{i=!0;var r=a('#ExtendedPageMakerModal input[name="namespace"]:checked').val,l=a("#NewPageTitle").val,d=a('#ExtendedPageMakerModal input[name="pagecontent"]:checked').val;if(!l.trim&&"blog"!==r)return a("#ExtendedPageMakerErrors").text(o.NeedName),void(i=!1);var s,g,c=t.config.get("wgServer")+t.config.get("wgScriptPath")+"/wiki/";switch(r){case"main":s=c+l+"?action=edit",g=l;break;case"blog":s=c+o.BlogURL;break;case"category":s=c+o.category+l+"?action=edit",g=o.category+l;break;case"mediawiki":s=c+o.MediaWiki+l+"?action=edit",g=o.MediaWiki+l;break;case"template":s=c+o.Template+l+"?action=edit",g=o.Template+l;break;case"forum":s=c+o.forumDomain+l+"?action=edit",g=o.forumDomain+l;break;default:return a("#ExtendedPageMakerErrors").text(o.genericError),void(i=!1)}"populated"===d&&(s+="blog"!==r?"&useFormat=1":"?useFormat=1"),"blog"!==r?n.get({action:"query",format:"json",titles:g,prop:"info",inprop:"url|talkid",errorformat:"html"}).done(function(t){if(i){if(t.query&&t.query.pages){var n=t.query.pages;for(var r in n){"missing"in n[r]?e.location=s:a("#ExtendedPageMakerErrors").html(o.alreadyExists.replace("$pagelink",c+g).replace("$page",g).replace("$editlink",s));break}}else t.errors&&t.errors.html?a("#ExtendedPageMakerErrors").html(t.errors.html):a("#ExtendedPageMakerErrors").text(o.genericError);i=!1}}).error(function(e){i&&(e.errors&&e.errors.html?a("#ExtendedPageMakerErrors").html(data.errors.html):a("#ExtendedPageMakerErrors").text(o.genericError),i=!1)}):(e.location=s,i=!1)}}}(this,this.jQuery,this.mediaWiki);