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. |
var obj,ip,ip_eq,prop_Name,prop_Value,st_new,t_Crit,t_CritVal,vr_Str;
var i,i_L,i1,i2,i3,i1F,i1L,i2F,i2L,i3F,i3L;
var _cc; /* _cc - "char's code" */
var _f=""; /* _f - "the substring used to find the folder or build the file's name" */
var _href=window.location.href;
var _html;
var _name;
var in_html; /* ---------- stores the innerHTML code --------- */
var na_ua=navigator.userAgent; /* ---------- navigator.userAgent ---------- */
var tb_nf; /* ---------- Type_of_Browser_Netscape_and_Firefox ---------- */
var ps="";
var code_Storage;
var wiki="/wiki/";
var new_Text,new_A,new_BR,new_BUTTON,new_DIV,new_Elem,new_FORM,new_H5,new_I,new_INPUT,new_LABEL;
var new_OPTION,new_SELECT,new_SPAN,new_SUB,new_SUP,new_TD,new_TR,num_colSPan,v_href,v_id,v_title;
var myRegExp=/[\S]/;
var inf=new Array();
var opt_value=new Array("all","cb","imi","na","pp","ps","sm","som");
var opt_text=new Array("All","Cell biology","Inorganic","Nucleic acids","Polypeptides","Polysaccharides","Small molecules","Synthetic");
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_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");
}
function build_the_synonyms(_f_v) {
new_TD.innerHTML="Many (Show)";
}
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 find_number(_v) {
switch (_v) {
case 48: _f +="zer"; break;
case 49: _f +="one"; break;
case 50: _f +="two"; break;
case 51: _f +="thr"; break;
case 52: _f +="for"; break;
case 53: _f +="fiv"; break;
case 54: _f +="six"; break;
case 55: _f +="svn"; break;
case 56: _f +="eit"; break;
case 57: _f +="nin"; break;
}
}
function get_wiki_file_name() {
if (_href.indexOf("index.php?title=") > -1) {
_name=_href.substring(_href.indexOf("index.php?title=")-(-16),_href.indexOf("&",_href.indexOf("index.php?title=")));
}
else {
_name=_href.substring(_href.indexOf("/wiki/")-(-6));
if (_name.indexOf("#") > -1) _name=_name.substring(0,_name.indexOf("#"));
}
}
function make_js_file_name() {
_cc=_name.charCodeAt(0);
if (_cc > 48 && _cc < 58) {
_f +="z_";
find_number(_cc);
}
else if (_cc > 64 && _cc <91) _f=String.fromCharCode(_cc+32);
else _f=String.fromCharCode(_cc);
_f += "/";
i1L=_name.length;
for (i1=0; i1<i1L; i1++) {
_cc=_name.charCodeAt(i1);
if (_cc > 47 && _cc < 58) {
find_number(_cc);
_f += "_";
}
else if (_cc > 64 && _cc < 91) _f +=_name.charAt(i1);
else if (_cc > 96 && _cc < 123) _f +=String.fromCharCode(_cc-32);
else {
switch (_cc) {
case 32: _f +="sp_"; break; /* space */
case 39: _f +="sq_"; break; /* single quote */
case 40: _f +="op_"; break; /* opening parenthesis */
case 41: _f +="cp_"; break; /* closing parenthesis */
case 42: _f +="as_"; break; /* asterisk */
case 43: _f +="ps_"; break; /* plus sign */
case 44: _f +="co_"; break; /* comma */
case 45: _f +="ms_"; break; /* minus sign */
case 46: _f +="pe_"; break; /* period */
case 47: _f +="sl_"; break; /* slash */
case 58: _f +="cn_"; break; /* colon */
case 59: _f +="sc_"; break; /* semi colon */
case 91: _f +="ob_"; break; /* opening bracket */
case 92: _f +="bs_"; break; /* back slash */
case 93: _f +="cb_"; break; /* closing bracket */
case 94: _f +="ca_"; break; /* caret */
case 95: _f +="un_"; break; /* underscore */
case 95: _f +="ga_"; break; /* grave accent */
}
}
}
}
function check_theID() {
if (!document.getElementById('footer')) {
setTimeout('check_theID()',200);
}
else {
build_search_form();
if (document.getElementById('drugInfoBox')) {
obj=document.getElementById('drugInfoBox');
if (inf['group'] == "nat") build_InfoBox();
if (inf['group'] == "syn") build_synInfoBox();
}
if (document.getElementById('bioChemInfoBox')) {
obj=document.getElementById('bioChemInfoBox');
build_InfoBox();
}
if (document.getElementById('synChemInfoBox')) {
obj=document.getElementById('synChemInfoBox');
build_synInfoBox();
}
if (document.getElementById("Structure") && ps.length > 1) build_protein_table();
}
}
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;
}