User:BorisTM/InfoBoxFunctions.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | Documentation for this user script can be added at User:BorisTM/InfoBoxFunctions. |
//<pre>
function clear_Spaces(st_old) {
i2L=st_old.length;
for (i2=0; i2<i2L; i2++) {
if (myRegExp.test(st_old.charAt(i2))) {break;}
}
for (i3=i2L; i3>i2; i3--) {
if (myRegExp.test(st_old.charAt(i3))) {break;}
}
st_new=st_old.substring(i2,(i3-(-1)));
return st_new;
}
function build_acid_base(f_acid_prop,f_a_href,f_a_title,f_a_text) {
if (inf[f_acid_prop] && !(inf[f_acid_prop]=="")) {
build_TR("","2");
code_Storage = "<a href='"+wiki+f_a_href+"' title='"+f_a_title+"'>";
code_Storage += f_a_text;
new_TD.innerHTML=code_Storage;
new_TD.style.fontWeight="bold";
build_TD("");
new_TD.innerHTML=inf[f_acid_prop];
}
}
function build_H_bond(f_h_bond,f_a_add_text) {
if (inf[f_h_bond] && !(inf[f_h_bond]=="")) {
vr_Str=build_wiki_A("Hydrogen_bond","Hydrogen bond","H bond")
build_TR(vr_Str,"2");
new_Text=document.createTextNode(f_a_add_text);
new_TD.appendChild(new_Text);
new_TD.style.fontWeight="bold";
new_TD.style.whiteSpace="nowrap";
build_TD(document.createTextNode(inf[f_h_bond]));
}
}
function build_wiki_A(f_v_href,f_v_title,f_a_text) {
new_Text=document.createTextNode(f_a_text);
new_A=document.createElement("A");
new_A.style.fontWeight="bold";
f_v_href=wiki+f_v_href;
add_href(f_v_href,f_v_title);
return new_A;
}
function build_TD_phys(f_a_text,f_a_href,f_a_title,f_a_id) {
new_TD=document.createElement("TD");
new_TR.appendChild(new_TD);
new_TD.setAttribute("bgColor","#FFFFFF");
new_TD.style.textAlign="center";
new_TD.innerHTML=f_a_text;
if (f_a_href) {
new_TD.setAttribute("verticalAlign","top");
new_TD.setAttribute("width","25%");
new_A=document.getElementById(f_a_id);
v_href=wiki+f_a_href;
new_A.setAttribute("href",v_href);
new_A.title=f_a_title;
new_A.style.fontWeight="bold";
}
}
function build_ref_A(f_v_num) {
new_Text=document.createTextNode(f_v_num);
if (!(f_v_num=="?")) {
new_A=document.createElement("A");
new_A.className="external text";
new_A.setAttribute("id",v_id);
if (f_v_num.indexOf("-")>0) {
var regExpNum=/\d/; vr_Str=""; i_L=f_v_num.length;
for (i=0; i<i_L; i++) {
if (regExpNum.test(f_v_num.charAt(i))) {vr_Str += ("" + f_v_num.charAt(i));}
}
i_L=vr_Str.length;
for (i=i_L; i<9; i++) {vr_Str = "0" + vr_Str;}
v_title="CAS_"+vr_Str;
v_href="http://chem.sis.nlm.nih.gov/chemidplus/ProxyServlet?objectHandle=DBMaint&";
v_href +="actionHandle=default&nextPage=jsp/chemidlite/ResultScreen.jsp&";
v_href +="TXTSUPERLISTID="+vr_Str;
}
else {
v_title="PubChem_"+f_v_num;
v_href="http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid="+f_v_num;
}
add_href(v_href,v_title);
}
else new_A=document.createTextNode(f_v_num);
return new_A;
}
function add_href(f_v_href,f_v_title) {
new_A.setAttribute("href",f_v_href);
new_A.title=f_v_title;
new_A.appendChild(new_Text);
}
function build_TR(f_any_Element,f_td_colspan,f_td_bgColor){
num_colSPan=f_td_colspan;
new_TR=document.createElement("TR");
build_TD(f_any_Element,f_td_bgColor);
obj.appendChild(new_TR);
}
function build_TD(f_any_Element,f_td_bgColor) {
new_TD=document.createElement("TD");
new_TR.appendChild(new_TD);
if (f_any_Element) new_TD.appendChild(f_any_Element);
new_TD.setAttribute("colSpan",num_colSPan);
if (f_td_bgColor) {
new_TD.setAttribute("bgColor",f_td_bgColor);
new_TD.style.fontWeight="bold";
new_TD.style.textAlign="center";
}
else new_TD.setAttribute("bgColor","#FFFFFF");
}
//</pre>