Line 1: | Line 1: | ||
// <includeonly> | // <includeonly> | ||
function waitForWikiEditor(expeditionTemplate){ | function waitForWikiEditor(expeditionTemplate){ | ||
− | if(typeof $("#wpTextbox1").wikiEditor === "function"){ | + | |
+ | // if(typeof $("#wpTextbox1").wikiEditor === "function"){ | ||
+ | $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', function () { | ||
$("#wpTextbox1").wikiEditor("addToToolbar", { | $("#wpTextbox1").wikiEditor("addToToolbar", { | ||
section: "main", | section: "main", | ||
Line 19: | Line 21: | ||
} | } | ||
}); | }); | ||
− | } | + | } ); |
− | else{ | + | |
− | + | // } | |
− | } | + | // else{ |
+ | // setTimeout(function() { waitForWikiEditor(expeditionTemplate)}, 250); | ||
+ | // } | ||
} | } | ||
Revision as of 23:00, 13 February 2023
// <includeonly> function waitForWikiEditor(expeditionTemplate){ // if(typeof $("#wpTextbox1").wikiEditor === "function"){ $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-doneInitialSections', function () { $("#wpTextbox1").wikiEditor("addToToolbar", { section: "main", group: "insert", tools: { buttonId: { label: "Expedition template", type: "button", icon: "https://geohashing.site/images/thumb/4/4c/Landgeohash.png/24px-Landgeohash.png", action: { type: "encapsulate", options: { post: expeditionTemplate } } } } }); } ); // } // else{ // setTimeout(function() { waitForWikiEditor(expeditionTemplate)}, 250); // } } const userName = $('.navbar-userloggedin')[0].title.replace(/You are logged in as (.*)\./, '$1') const expeditionRegex = /\d{4}-\d{2}-\d{2}_-?\d{1,3}_-?\d{1,3}/ const expeditionMatch = location.toString().match(expeditionRegex) if(expeditionMatch !== null && (mw.config.get(['wgAction']).wgAction === "edit" || mw.config.get(['wgAction']).wgAction === "submit")){ const expeditionData = expeditionMatch[0].split("_") const meetupTemplate = "{{meetup graticule|date=" + expeditionData[0] + "|lat=" + expeditionData[1] + "|lon=" + expeditionData[2] + "}}" const expeditionTemplate = meetupTemplate + "\ \n\ ==Location==\n\ \n\ ==Participants==\n\ *[[User:" + userName + "|" + userName + "]]\n\ \n\ ==Expedition==\n\ \n\ ==Photos==\n\ <gallery>\n\ </gallery>\n\ \n\ ==Ribbons==\n\ {{#vardefine:ribbonwidth|100%}}\n\ \n\ __NOTOC__\n\ <!--\n\ [[Category:Expeditions]]\n\ [[Category:Coordinates reached]]\n\ [[Category:Coordinates not reached]]\n\ [[Category:Not reached - No public access]]\n\ [[Category:Not reached - Mother Nature]]\n\ [[Category:Expeditions with photos]]-->\n\ {{location|DE}}\n\ {{user categories|user=" + userName + "}}"; $(document).ready(function() {waitForWikiEditor(expeditionTemplate)}); } // </includeonly>