Difference between revisions of "User:Leidenfrost/common.js"

From Geohashing
m (rm comments, will this work now?)
m (stolen)
Line 30: Line 30:
 
if(expeditionMatch !== null && (mw.config.get(['wgAction']).wgAction === "edit" || mw.config.get(['wgAction']).wgAction === "submit")){
 
if(expeditionMatch !== null && (mw.config.get(['wgAction']).wgAction === "edit" || mw.config.get(['wgAction']).wgAction === "submit")){
 
     var expeditionData = expeditionMatch[0].split("_")
 
     var expeditionData = expeditionMatch[0].split("_")
     var meetupTemplate = "{{meetup graticule\n\
+
     var meetupTemplate = "{{meetup graticule|date=" + expeditionData[0] + "|lat=" + expeditionData[1] + "|lon=" + expeditionData[2] + "}}"
|lat=" + expeditionData[1] + "\n\
 
|lon=" + expeditionData[2] + "\n\
 
|date=" + expeditionData[0] + "\n\
 
}}"
 
  
 
     var expeditionTemplate = meetupTemplate + "\n\
 
     var expeditionTemplate = meetupTemplate + "\n\
__NOTOC__\n\
 
 
==Location==\n\
 
==Location==\n\
\n\
 
 
\n\
 
\n\
 
==Participants==\n\
 
==Participants==\n\
\n\
+
*[[User:Leidenfrost|Leidenfrost]]\n\
*[[User:" + mw.config.values.wgUserName + "|" + mw.config.values.wgUserName + "]]\n\
 
\n\
 
==Plans==\n\
 
\n\
 
 
\n\
 
\n\
 
==Expedition==\n\
 
==Expedition==\n\
\n\
 
 
\n\
 
\n\
 
==Photos==\n\
 
==Photos==\n\
to follow\n\
+
<gallery>\n\
 +
</gallery>\n\
 
\n\
 
\n\
==Achievements==\n\
+
==Ribbons==\n\
 
{{#vardefine:ribbonwidth|100%}}\n\
 
{{#vardefine:ribbonwidth|100%}}\n\
 
\n\
 
\n\
[[Category:New report]]\n\
+
__NOTOC__\n\
\n\
 
<!--
 
[[Category:Expedition planning]]\n\
 
-->\n\
 
\n\
 
<!--[[Category:Not reached - Did not attempt]].-->\n\
 
\n\
 
 
<!--\n\
 
<!--\n\
 
[[Category:Expeditions]]\n\
 
[[Category:Expeditions]]\n\
[[Category:Expeditions with photos]]\n\
 
-->\n\
 
\n\
 
<!--\n\
 
 
[[Category:Coordinates reached]]\n\
 
[[Category:Coordinates reached]]\n\
\n\
 
\n\
 
--><!--\n\
 
 
[[Category:Coordinates not reached]]\n\
 
[[Category:Coordinates not reached]]\n\
\n\
+
[[Category:Not reached - No public access]]\n\
 
[[Category:Not reached - Mother Nature]]\n\
 
[[Category:Not reached - Mother Nature]]\n\
\n\
+
[[Category:Expeditions with photos]]-->\n\
[[Category:Not reached - No public access]]\n\
+
{{location|DE}}\n\";
\n\
 
(Don't forget to delete this final close comment marker) --> \n\
 
";
 
  
 
     $(document).ready(waitForWikiEditor);
 
     $(document).ready(waitForWikiEditor);
 
}
 
}
 
// </includeonly>
 
// </includeonly>

Revision as of 15:41, 13 August 2022

// <includeonly>
function waitForWikiEditor(){
    if(typeof $("#wpTextbox1").wikiEditor === "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/22px-Landgeohash.png",
                    action: {
                        type: "encapsulate",
                        options: {
                            post: expeditionTemplate
                        }
                    }
                }
            }
        });
    }
    else{
        setTimeout(waitForWikiEditor, 250);
    }
}

var expeditionRegex = /\d{4}-\d{2}-\d{2}_-?\d{1,3}_-?\d{1,3}/
var expeditionMatch = location.toString().match(expeditionRegex)

if(expeditionMatch !== null && (mw.config.get(['wgAction']).wgAction === "edit" || mw.config.get(['wgAction']).wgAction === "submit")){
    var expeditionData = expeditionMatch[0].split("_")
    var meetupTemplate = "{{meetup graticule|date=" + expeditionData[0] + "|lat=" + expeditionData[1] + "|lon=" + expeditionData[2] + "}}"

    var expeditionTemplate = meetupTemplate + "\n\
==Location==\n\
\n\
==Participants==\n\
*[[User:Leidenfrost|Leidenfrost]]\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\";

    $(document).ready(waitForWikiEditor);
}
// </includeonly>