User:BorisTM/NatOrganicBoxInfo.js

//

function build_InfoBox() {

vr_Str=obj.innerHTML; /* obj=document.getElementById('bioChemInfoBox'); or obj=document.getElementById('drugInfoBox'); */

if (obj.attributes.length < 3 && document.getElementById('theBoxInfo')) {

// ------------ Get the data

ip=vr_Str.indexOf('^^',vr_Str.indexOf('theBoxInfo'));

if (ip > 0) {

tb_nf=(na_ua.indexOf("Netscape") >= 0 || na_ua.indexOf("Firefox") >= 0)?true:false;

if (tb_nf)

vr_Str=vr_Str.substring((ip-(-2)),vr_Str.lastIndexOf('

else {

vr_Str=vr_Str.substring((ip-(-2)),vr_Str.lastIndexOf('

}

var tem=vr_Str.split("^^");

i1L=tem.length;

for (i1=0; i1

ip_eq=tem[i1].indexOf('=');

prop_Name=clear_Spaces(tem[i1].substring(0,ip_eq));

ip_eq += 1;

prop_Value=clear_Spaces(tem[i1].substring(ip_eq));

inf[prop_Name]=prop_Value;

}

}

// ------------ Gets the image src

vr_Str=obj.innerHTML;

ip=vr_Str.indexOf("http://upload.wikimedia.org/wikipedia/");

if (tb_nf) {

ip_2=vr_Str.indexOf(">

obj.style.backgroundColor="#C0C090";

obj.style.borderWidth="0px";

obj.style.borderCollapse="separate";

obj.style.padding="0px";

obj.style.fontSize="95%";

obj.style.float="right";

obj.setAttribute("align","right");

obj.cellPadding="2";

obj.cellSpacing="1";

obj.setAttribute("border","0");

obj.setAttribute("width","326px");

obj.style.width="326px";

obj=obj.firstChild;

while (obj.firstChild) obj.removeChild(obj.firstChild);

// ------------ Builds the NAME header

if (!inf['name'] || inf['name']=="") {

vr_Str=document.title;

firstIndex=vr_Str.indexOf(":")>0?vr_Str.indexOf(":")+1:0;

inf['name']=vr_Str.substring(firstIndex,vr_Str.indexOf(" - Wikipedia, the free encyclopedia"));

}

build_TR(document.createTextNode(inf['name']),"4","#F8EABA");

// ------------ Builds the IMAGE section

build_TR("","4");

_html = "

_html += "src='http://www.molbiology.com/wiki/"+_f+"/f1.png' ";

_html += "alt='The structure of "+inf['name']+"' width='"+inf['width']+"' />";

new_TD.innerHTML=_html;

/* ---------------------------------------

Builds the GENERAL header

--------------------------------------- */

build_TR(document.createTextNode("General"),"4","#F8EABA");

// ------------ Builds the IUPAC NAME section

if (!inf['IUPAC'] || inf['IUPAC']=="") inf['IUPAC']="?";

build_TR(build_wiki_A("IUPAC_nomenclature","IUPAC_nomenclature","Chemical name"),"4");

build_TR("","4");

new_TD.innerHTML=inf['IUPAC'];

// ------------ Builds the SYNONYMS section

if (inf['synonyms'] && !(inf['synonyms']=="")) {

build_TR(build_wiki_A("Synonyms","Synonyms","Synonyms"),"4");

build_TR("","4");

if (!(inf['num_syn'] == undefined)) {

if (inf['num_syn'] == "small") new_TD.innerHTML=inf['synonyms'];

else build_the_synonyms(inf['synonyms']);

}

}

// ------------ Builds the ABBREVIATION section

if (inf['abbreviations'] && !(inf['abbreviations']=="")) {

build_TR(build_wiki_A("Abbreviations","Abbreviations","Abbreviations"),"2");

build_TD("");

new_TD.innerHTML=inf['abbreviations'];

new_TD.setAttribute("verticalAlign","top");

}

// ------------ Builds the FORMULA section

if (!inf['formula'] || inf['formula']=="") inf['formula']="?";

build_TR(build_wiki_A("Chemical formula","Chemical formula","Chemical formula"),"2");

new_TD.setAttribute("verticalAlign","top");

new_TD.setAttribute("whiteSpace","nowrap");

new_TD.setAttribute("width","50%");

build_TD("");

new_TD.innerHTML=inf['formula'];

new_TD.setAttribute("width","50%");

/* ---------------------------------------

Builds the PHYSICAL PROPERTIES header

--------------------------------------- */

build_TR(document.createTextNode("Physical properties"),"4","#F8EABA");

// ------------ Builds the MAS, DENSITY, and TEMPERATURES sections

new_TR=document.createElement("TR");

obj.appendChild(new_TR);

if (!inf['mass'] || inf['mass']=="") inf['mass']="?";

build_TD_phys(" M (g/mol) ","Molecular_mass","Molecular_mass","id_M");

if (!inf['density'] || inf['density']=="") inf['density']="?";

build_TD_phys(" ρ (g/cm3) ","Density","Density","id_rho");

if (!inf['Tm'] || inf['Tm']=="") inf['Tm']="?";

build_TD_phys(" Tm (°C) ","Melting_point","Melting point","id_Tm");

if (!inf['Td']) {

build_TD_phys(" Tb (°C) ","Boiling_point","Boiling point","id_Tb");

t_CritVal=(!inf['Tb'] || inf['Tb']=="")?'?':inf['Tb'];

}

else {

build_TD_phys(" Td (°C) ","Decomposition_temperature","Decomposition temperature","id_Td");

t_CritVal=(!(inf['Td']==""))?inf['Td']:'?';

}

new_TR=document.createElement("TR");

obj.appendChild(new_TR);

build_TD_phys(inf['mass']);

build_TD_phys(inf['density']);

build_TD_phys(inf['Tm']);

build_TD_phys(t_CritVal);

/* ---------------------------------------

Builds the CHEMICAL PROPERTIES header

--------------------------------------- */

build_TR(document.createTextNode("Chemical properties"),"4","#F8EABA");

// ------------ Builds the pKi section

build_acid_base("pI","Isoelectric_point","Isoelectric point","pI");

// ------------ Builds the pKa section

build_acid_base("pKa","Acid_dissociation_constant","Acid dissociation constant","pKa");

// ------------ Builds the H-BOND ACCEPTOR section

build_H_bond("h_bond_acceptor"," acceptors");

// ------------ Builds the H-BOND DONOR section

build_H_bond("h_bond_donor"," donors");

// ------------ Builds the TAUTOMERS section

if (inf['tautomers'] && !(inf['tautomers']=="")) {

build_TR(build_wiki_A("Tautomers","Tautomer","Tautomers"),"2");

build_TD(document.createTextNode(inf['tautomers']));

}

/* ---------------------------------------

Builds the MISCELLANEOUS header

--------------------------------------- */

build_TR(document.createTextNode("Miscellaneous"),"4","#F8EABA");

// ------------ Builds the CAS section

if (!inf['CAS'] || inf['CAS']=="") inf['CAS']="?";

build_TR(build_wiki_A("CAS_registry_number","CAS registry number","CAS"),"2");

build_TD(build_ref_A(inf['CAS']));

// ------------ Builds the EINECS section

if (inf['EINECS'] && !(inf['EINECS']=="")) {

build_TR(build_wiki_A("EINECS_number","EINECS","EINECS"),"2");

build_TD(document.createTextNode(inf['EINECS']));

}

// ------------ Builds the PubChem section

if (!inf['PubChem'] || inf['PubChem']=="") inf['PubChem']="?";

build_TR(build_wiki_A("PubChem","PubChem","PubChem"),"2");

build_TD(build_ref_A(inf['PubChem']));

/* ------------ Builds the SMILES section

if (!inf['SMILES'] || inf['SMILES']=="") inf['SMILES']="?";

build_TR(build_wiki_A("SMILES","SMILES","SMILES"),"4");

build_TR(document.createTextNode(inf['SMILES']),"4");

  • /

}

//