ultimate_tictactoe/tools.js

35 lines
776 B
JavaScript

function clear(node) {
while (node.hasChildNodes()) {
clear(node.firstChild);
}
node.parentNode.removeChild(node);
}
function clearInner(node) {
while (node.hasChildNodes()) {
clear(node.firstChild);
}
}
// encoding helper (found here: https://stackoverflow.com/a/2794366)
function encodeHTML(s) {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
}
Date.create_from_mysql = function(mysql_string)
{
var t, result = null;
if( typeof mysql_string === 'string' )
{
t = mysql_string.split(/[- :]/);
//when t[3], t[4] and t[5] are missing they defaults to zero
result = new Date(t[0], t[1] - 1, t[2], t[3] || 0, t[4] || 0, t[5] || 0);
}
return result;
}