Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
m |
|||
(12 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
− | if ( mw.config.get( 'wgPageName' ) === 'User:Stitch/Test' ) { | + | if ( mw.config.get( 'wgPageName' ) === 'User:Stitch/Test' || mw.config.get( 'wgPageName' ) === 'Villages') { |
maplocation = document.getElementById('map'); | maplocation = document.getElementById('map'); | ||
− | maplocation.innerHTML = "<iframe src='https://map.emfcamp.org/' style='width: 100%; height: | + | maplocation.innerHTML = "<iframe src='https://map.emfcamp.org/' style='width: 100%; height: 600px'></iframe>"; |
+ | } | ||
+ | |||
+ | |||
+ | /* Map for individual village pages */ | ||
+ | |||
+ | var thisPage = mw.config.get('wgPageName'); | ||
+ | var mapEl = document.getElementById('villageMap'); | ||
+ | |||
+ | if (thisPage.substring(0, 8) == 'Village:' && window.fetch && mapEl) { // Can't use wgCanonicalNamespace as it's not a proper namespace | ||
+ | window.fetch("https://www.emfcamp.org/api/map") | ||
+ | .then(function (response) { | ||
+ | if (response.ok) { | ||
+ | return response.json(); | ||
+ | } | ||
+ | }) | ||
+ | .then(function (data) { | ||
+ | if (data.features) { | ||
+ | for (var i=0; i<data.features.length; ++i) { | ||
+ | var feature = data.features[i]; | ||
+ | if (feature.properties && feature.properties.wiki_page == thisPage) { | ||
+ | var mapUrl = 'https://map.emfcamp.org/#17/' + feature.geometry.coordinates[1] + '/' + feature.geometry.coordinates[0]; | ||
+ | mapEl.innerHTML = '<iframe src="' + mapUrl + '" style="width: 100%; height: 200px; border: 0;"></iframe>'; | ||
+ | return; | ||
+ | } | ||
+ | } | ||
+ | mapEl.innerHTML = "This village hasn't placed a map pin yet!" | ||
+ | } | ||
+ | }); | ||
+ | } | ||
+ | |||
+ | /* Trolling Camp Holland */ | ||
+ | |||
+ | if ( mw.config.get( 'wgPageName' ) === 'Village:CampHolland') { | ||
+ | myVidya = document.getElementById('vidya'); | ||
+ | myVidya.innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/MSR3jNZBZlo?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'; | ||
+ | |||
+ | var z = document.createElement('style'); | ||
+ | z.appendChild(document.createTextNode("#content {animation: example 10s linear infinite;}\n" + | ||
+ | "@keyframes example {0% {-o-transform: skew(0.1deg);\n" + | ||
+ | "-webkit-transform: skew(0.3deg);\n" + | ||
+ | "-moz-transform: skew(0.3deg);}\n" + | ||
+ | "50% { -o-transform: skew(-0.3deg);\n" + | ||
+ | "-webkit-transform: skew(-0.3deg);\n" + | ||
+ | "-moz-transform: skew(-0.3deg);}\n" + | ||
+ | "100% { -o-transform: skew(0.3deg);\n" + | ||
+ | "-webkit-transform: skew(0.3deg);\n" + | ||
+ | "-moz-transform: skew(0.3deg);}}")) | ||
+ | document.getElementsByTagName("head")[0].appendChild(z); | ||
} | } |
Latest revision as of 08:52, 15 August 2018
/* Any JavaScript here will be loaded for all users on every page load. */ if ( mw.config.get( 'wgPageName' ) === 'User:Stitch/Test' || mw.config.get( 'wgPageName' ) === 'Villages') { maplocation = document.getElementById('map'); maplocation.innerHTML = "<iframe src='https://map.emfcamp.org/' style='width: 100%; height: 600px'></iframe>"; } /* Map for individual village pages */ var thisPage = mw.config.get('wgPageName'); var mapEl = document.getElementById('villageMap'); if (thisPage.substring(0, 8) == 'Village:' && window.fetch && mapEl) { // Can't use wgCanonicalNamespace as it's not a proper namespace window.fetch("https://www.emfcamp.org/api/map") .then(function (response) { if (response.ok) { return response.json(); } }) .then(function (data) { if (data.features) { for (var i=0; i<data.features.length; ++i) { var feature = data.features[i]; if (feature.properties && feature.properties.wiki_page == thisPage) { var mapUrl = 'https://map.emfcamp.org/#17/' + feature.geometry.coordinates[1] + '/' + feature.geometry.coordinates[0]; mapEl.innerHTML = '<iframe src="' + mapUrl + '" style="width: 100%; height: 200px; border: 0;"></iframe>'; return; } } mapEl.innerHTML = "This village hasn't placed a map pin yet!" } }); } /* Trolling Camp Holland */ if ( mw.config.get( 'wgPageName' ) === 'Village:CampHolland') { myVidya = document.getElementById('vidya'); myVidya.innerHTML = '<iframe width="560" height="315" src="https://www.youtube.com/embed/MSR3jNZBZlo?autoplay=1" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'; var z = document.createElement('style'); z.appendChild(document.createTextNode("#content {animation: example 10s linear infinite;}\n" + "@keyframes example {0% {-o-transform: skew(0.1deg);\n" + "-webkit-transform: skew(0.3deg);\n" + "-moz-transform: skew(0.3deg);}\n" + "50% { -o-transform: skew(-0.3deg);\n" + "-webkit-transform: skew(-0.3deg);\n" + "-moz-transform: skew(-0.3deg);}\n" + "100% { -o-transform: skew(0.3deg);\n" + "-webkit-transform: skew(0.3deg);\n" + "-moz-transform: skew(0.3deg);}}")) document.getElementsByTagName("head")[0].appendChild(z); }