MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
(Created page with "→Any JavaScript here will be loaded for all users on every page load.: // NeoGeo Color converter (function () { var cconvdiv = document.getElementById('color-converter...") |
mNo edit summary |
||
Line 8: | Line 8: | ||
'<input type="text" maxlength="3" size="4" id="color-green">' + | '<input type="text" maxlength="3" size="4" id="color-green">' + | ||
'<input type="text" maxlength="3" size="4" id="color-blue">' + | '<input type="text" maxlength="3" size="4" id="color-blue">' + | ||
'<input type="button" value="Convert" onClick="cconv( | '<input type="button" value="Convert" onClick="cconv();"></form>'; | ||
}()); | }()); | ||
Line 14: | Line 14: | ||
function cconv(frm) { | function cconv(frm) { | ||
var red = Math.floor( | var red = Math.floor(document.forms["cconvform"]["color-red"].value / 8); | ||
var green = Math.floor( | var green = Math.floor(document.forms["cconvform"]["color-green"].value / 8); | ||
var blue = Math.floor( | var blue = Math.floor(document.forms["cconvform"]["color-blue"].value / 8); | ||
document.getElementById('cconvresult').innerHTML = ((red&1)<<14)|((green&1)<<13)|((blue&1)<<12)|((red&0x1E)<<7)|((green&0x1E)<<3)|(blue>>1); | document.getElementById('cconvresult').innerHTML = ((red&1)<<14)|((green&1)<<13)|((blue&1)<<12)|((red&0x1E)<<7)|((green&0x1E)<<3)|(blue>>1); | ||
} | } |
Revision as of 10:22, 23 January 2016
/* Any JavaScript here will be loaded for all users on every page load. */
// NeoGeo Color converter
(function () {
var cconvdiv = document.getElementById('color-converter');
cconvdiv.innerHTML = '<form name="cconvform" action=""><input type="text" maxlength="3" size="4" id="color-red">' +
'<input type="text" maxlength="3" size="4" id="color-green">' +
'<input type="text" maxlength="3" size="4" id="color-blue">' +
'<input type="button" value="Convert" onClick="cconv();"></form>';
}());
function cconv(frm) {
var red = Math.floor(document.forms["cconvform"]["color-red"].value / 8);
var green = Math.floor(document.forms["cconvform"]["color-green"].value / 8);
var blue = Math.floor(document.forms["cconvform"]["color-blue"].value / 8);
document.getElementById('cconvresult').innerHTML = ((red&1)<<14)|((green&1)<<13)|((blue&1)<<12)|((red&0x1E)<<7)|((green&0x1E)<<3)|(blue>>1);
}