Encyclopedia > User:Tim Starling Formula wikifier

  Article Content

User:Tim Starling/Formula wikifier

< User:Tim Starling

The formula wikifier is currently available on the internet at [1] (http://starling.f2g.net/wikify). Don't get too excited - it doesn't actually work straight from the website. I'm not exactly a crack JavaScript programmer - does anyone know if there's a way of getting around the security restriction my script suffers?

Other stuff: it only works in IE, it could be made 30 times faster with a small amount of programming effort, and I've only tested in IE 6.

Anyway, here's the code:

wikify

<html>
<frameset cols="270,*">
<frame name="fJsframe" src="jsframe">
<frame name="fContent" src="">
</frameset>
</html>
jsframe
<html>
<script>
<!--
function wikify()
{
elements=[
"H",
"Hydrogen",
"He",
"Helium",
"Li",
"Lithium",
"Be",
"Beryllium",
"B",
"Boron",
"C",
"Carbon",
"N",
"Nitrogen",
"O",
"Oxygen",
"F",
"Fluorine",
"Ne",
"Neon",
"Na",
"Sodium",
"Mg",
"Magnesium",
"Al",
"Aluminium",
"Si",
"Silicon",
"P",
"Phosphorus",
"S",
"Sulfur",
"Cl",
"Chlorine",
"Ar",
"Argon",
"K",
"Potassium",
"Ca",
"Calcium",
"Sc",
"Scandium",
"Ti",
"Titanium",
"V",
"Vanadium",
"Cr",
"Chromium",
"Mn",
"Manganese",
"Fe",
"Iron",
"Co",
"Cobalt",
"Ni",
"Nickel",
"Cu",
"Copper",
"Zn",
"Zinc",
"Ga",
"Gallium",
"Ge",
"Germanium",
"As",
"Arsenic",
"Se",
"Selenium",
"Br",
"Bromine",
"Kr",
"Krypton",
"Rb",
"Rubidium",
"Sr",
"Strontium",
"Y",
"Yttrium",
"Zr",
"Zirconium",
"Nb",
"Niobium",
"Mo",
"Molybdenum",
"Tc",
"Technetium",
"Ru",
"Ruthenium",
"Rh",
"Rhodium",
"Pd",
"Palladium",
"Ag",
"Silver",
"Cd",
"Cadmium",
"In",
"Indium",
"Sn",
"Tin",
"Sb",
"Antimony",
"Te",
"Tellurium",
"I",
"Iodine",
"Xe",
"Xenon",
"Cs",
"Cesium",
"Ba",
"Barium",
"La",
"Lanthanum",
"Hf",
"Hafnium",
"Ta",
"Tantalum",
"W",
"Tungsten",
"Re",
"Rhenium",
"Os",
"Osmium",
"Ir",
"Iridium",
"Pt",
"Platinum",
"Au",
"Gold",
"Hg",
"Mercury (element)",
"Tl",
"Thallium",
"Pb",
"Lead",
"Bi",
"Bismuth",
"Po",
"Polonium",
"At",
"Astatine",
"Rn",
"Radon",
"Fr",
"Francium",
"Ra",
"Radium",
"Ac",
"Actinium",
"Rf",
"Rutherfordium",
"Db",
"Dubnium",
"Sg",
"Seaborgium",
"Bh",
"Bohrium",
"Hs",
"Hassium",
"Mt",
"Meitnerium",
"Uun",
"Ununnilium",
"Uuu",
"Unununium",
"Uub",
"Ununbium",
"Uuq",
"Ununquadium",
"Uuh",
"Unuhexium",
"Uuo",
"Ununoctium",
"Ce",
"Cerium",
"Pr",
"Praseodymium",
"Nd",
"Neodymium",
"Pm",
"Promethium",
"Sm",
"Samarium",
"Eu",
"Europium",
"Gd",
"Gadolinium",
"Tb",
"Terbium",
"Dy",
"Dysprosium",
"Ho",
"Holmium",
"Er",
"Erbium",
"Tm",
"Thulium",
"Yb",
"Ytterbium",
"Lu",
"Lutetium",
"Th",
"Thorium",
"Pa",
"Protactinium",
"U",
"Uranium",
"Np",
"Neptunium",
"Pu",
"Plutonium",
"Am",
"Americium",
"Cm",
"Curium",
"Bk",
"Berkelium",
"Cf",
"Californium",
"Es",
"Einsteinium",
"Fm",
"Fermium",
"Md",
"Mendelevium",
"No",
"Nobelium",
"Lr",
"Lawrencium"]

	tr = top.fContent.document.selection.createRange();
	output = "";
	for (p=0; p<tr.text.length; p++) {
		found = false;
		for (i=0; i<230 && !found; i+=2) {
			if (elements[i] == tr.text.substr(p, 2)) {
				output += "[[" + elements[i+1] + "|" + elements[i] + "]]";
				found = true;
				p++;
			}
		}
		for (i=0; !found && i<230; i+=2) {
			if (elements[i] == tr.text.substr(p,1)) {
				output += "[[" + elements[i+1] + "|" + elements[i] + "]]";
				found = true;
			}
		}
		if (!found) {
			output+=tr.text.substr(p,1);
		}
	}
	tr.text = output;
}

//-->
</script>

<p>URL: <input name=eUrl type=text value= width=250>
<input type=button value="Go" onclick="top.fContent.location=eUrl.value">
<p><input type=button name=cbWikify value="Wikify" onClick="wikify()">

</html>



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
Great River, New York

... of age or older. The median age is 39 years. For every 100 females there are 104.2 males. For every 100 females age 18 and over, there are 97.8 males. The median income ...

 
 
 
This page was created in 37.2 ms