Difference between revisions of "MediaWiki:LipoqualityCommon.js"

From Jcbl.jp
Jump to: navigation, search
(Created page with "// XSS対策用 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// function escape(text) { if(isFinite(text)) r...")
 
 
Line 17: Line 17:
 
return text;
 
return text;
 
return text.replace(/^InChIKey=/, "").replace(/[^A-Z0-9-]/g, "");
 
return text.replace(/^InChIKey=/, "").replace(/[^A-Z0-9-]/g, "");
 +
}
 +
// 子要素を全削除 //
 +
function removeAll(id)
 +
{
 +
parent = document.getElementById(id);
 +
while(parent.lastChild)
 +
parent.removeChild(parent.lastChild);
 
}
 
}

Latest revision as of 10:43, 23 March 2020

// XSS対策用 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function escape(text)
{
	if(isFinite(text))
		return text;
	return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function attrEscape(text)
{
	if(isFinite(text))
		return text;
	return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&rsquo;");
}
function inchiEscape(text)
{
	if(isFinite(text))
		return text;
	return text.replace(/^InChIKey=/, "").replace(/[^A-Z0-9-]/g, "");
}
// 子要素を全削除 //
function removeAll(id)
{
	parent = document.getElementById(id);
	while(parent.lastChild)
		parent.removeChild(parent.lastChild);
}
Personal tools