Difference between revisions of "MediaWiki:Common.js"
(added js and css url based loader) |
Kbjarkefur (talk | contribs) |
||
Line 24: | Line 24: | ||
} | } | ||
}); | }); | ||
/* Java script needed for the main page */ | |||
function dispTopics_lc(topicArray) | |||
{ | |||
var topicTable = '<div class="table-div"><table style="width:100%">'; | |||
topicTable += '<col width=20%><col width=80%><tr>'; | |||
topicTable += '<td rowspan="2">'+ topicArray[0] +'</td>'; | |||
topicTable += '<td class="td_lc_titl">'+ topicArray[1] +'</td>'; | |||
topicTable += '</tr><tr>'; | |||
topicTable += '<td class="td_lc_desc">'+ topicArray[2] +'</td>'; | |||
topicTable += '</tr></table></div>'; | |||
return topicTable; | |||
} | |||
function dispTopics_sa(topic) | |||
{ | |||
var topicTable = '<div class="table-div"><table style="width:100%">'; | |||
topicTable += '<tr><td class="td_sa">'+ topic +'</td></tr>'; | |||
topicTable += '</table></div>'; | |||
return topicTable; | |||
} |
Revision as of 13:46, 9 February 2017
/* Any JavaScript here will be loaded for all users on every page load. */
/**
* @source https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL
* @revision 2016-03-26
*/
mw.loader.using( ['mediawiki.util', 'mediawiki.notify'], function () {
var extraCSS = mw.util.getParamValue( 'withCSS' ),
extraJS = mw.util.getParamValue( 'withJS' );
if ( extraCSS ) {
if ( /^MediaWiki:[^&<>=%#]*\.css$/.test( extraCSS ) ) {
mw.loader.load( '/w/index.php?title=' + extraCSS + '&action=raw&ctype=text/css', 'text/css' );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withCSS value' } );
}
}
if ( extraJS ) {
if ( /^MediaWiki:[^&<>=%#]*\.js$/.test( extraJS ) ) {
mw.loader.load( '/w/index.php?title=' + extraJS + '&action=raw&ctype=text/javascript' );
} else {
mw.notify( 'Only pages from the MediaWiki namespace are allowed.', { title: 'Invalid withJS value' } );
}
}
});
/* Java script needed for the main page */
function dispTopics_lc(topicArray)
{
var topicTable = '<div class="table-div"><table style="width:100%">';
topicTable += '<col width=20%><col width=80%><tr>';
topicTable += '<td rowspan="2">'+ topicArray[0] +'</td>';
topicTable += '<td class="td_lc_titl">'+ topicArray[1] +'</td>';
topicTable += '</tr><tr>';
topicTable += '<td class="td_lc_desc">'+ topicArray[2] +'</td>';
topicTable += '</tr></table></div>';
return topicTable;
}
function dispTopics_sa(topic)
{
var topicTable = '<div class="table-div"><table style="width:100%">';
topicTable += '<tr><td class="td_sa">'+ topic +'</td></tr>';
topicTable += '</table></div>';
return topicTable;
}