MediaWiki:Common.js: Difference between revisions
From WikiDemocracy
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| 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. */ | ||
mw.loader.using('mediawiki.util', function() { | |||
$(document).ready(function() { | |||
// 1. Inject the Snipcart Stylesheet into the Head | |||
var snipcartStyle = document.createElement('link'); | |||
snipcartStyle.rel = 'stylesheet'; | |||
snipcartStyle.href = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.css'; | |||
document.head.appendChild(snipcartStyle); | |||
// | // 2. Inject the Snipcart JavaScript Engine into the Head | ||
var snipcartScript = document.createElement('script'); | var snipcartScript = document.createElement('script'); | ||
snipcartScript.src = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.js'; | snipcartScript.src = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.js'; | ||
snipcartScript. | snipcartScript.async = true; | ||
document.head.appendChild(snipcartScript); | |||
document.head.appendChild(snipcartScript); | |||
var | // 3. Create the REQUIRED hidden container hidden in the Body for the API Key | ||
if (!document.getElementById('snipcart')) { | |||
var snipcartDiv = document.createElement('div'); | |||
document. | snipcartDiv.id = 'snipcart'; | ||
snipcartDiv.setAttribute('data-api-key', 'MmVhODYxZWItMmRiZC00ZmQxLWE3ODgtMDY2NGI0ODE2NTg3NjM5MTY0NDgxODQ2NzAzNTgy'); | |||
snipcartDiv.hidden = true; | |||
document.body.appendChild(snipcartDiv); | |||
} | |||
}); | |||
}); | |||
Revision as of 00:51, 8 June 2026
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using('mediawiki.util', function() {
$(document).ready(function() {
// 1. Inject the Snipcart Stylesheet into the Head
var snipcartStyle = document.createElement('link');
snipcartStyle.rel = 'stylesheet';
snipcartStyle.href = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.css';
document.head.appendChild(snipcartStyle);
// 2. Inject the Snipcart JavaScript Engine into the Head
var snipcartScript = document.createElement('script');
snipcartScript.src = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.js';
snipcartScript.async = true;
document.head.appendChild(snipcartScript);
// 3. Create the REQUIRED hidden container hidden in the Body for the API Key
if (!document.getElementById('snipcart')) {
var snipcartDiv = document.createElement('div');
snipcartDiv.id = 'snipcart';
snipcartDiv.setAttribute('data-api-key', 'MmVhODYxZWItMmRiZC00ZmQxLWE3ODgtMDY2NGI0ODE2NTg3NjM5MTY0NDgxODQ2NzAzNTgy');
snipcartDiv.hidden = true;
document.body.appendChild(snipcartDiv);
}
});
});