MediaWiki:Calculators/ODI.js
From WikiMSK
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (โ-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (โ-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/**
* ReplaceAll by Fagner Brack (MIT Licensed)
* Replaces all occurrences of a substring in a string
*/
String.prototype.replaceAll = function(token, newToken, ignoreCase) {
var str, i = -1, _token;
if((str = this.toString()) && typeof token === "string") {
_token = ignoreCase === true? token.toLowerCase() : undefined;
while((i = (
_token !== undefined?
str.toLowerCase().indexOf(
_token,
i >= 0? i + newToken.length : 0
) : str.indexOf(
token,
i >= 0? i + newToken.length : 0
)
)) !== -1 ) {
str = str.substring(0, i)
.concat(newToken)
.concat(str.substring(i + token.length));
}
}
return str;
};
/**************** Pลevod do html podoby ****************/
var content = $( '#lekarska_kalkulacka_ABCD2_content' ).text();
$( '#lekarska_kalkulacka_ABCD2' ).html( content.replaceAll('paragraph', 'p' ).replaceAll( 'resValue', 'span' ) );
/**************** Vlastnรญ vรฝpoฤet ****************/
$( '#lekarska_kalkulacka_ABCD2 input:radio' ).change( function() {
var points = 0;
$( '#lekarska_kalkulacka_ABCD2 input:radio' ).each( function() {
if ( this.checked ) {
points += parseInt( this.value );
}
});
$( '#lekarska_kalkulacka_ABCD2-result' ).html( points );
});