" + " ... " + thiscont);
//alert("1 ... " + thiscont);
elemepos.push(ipos);
elempos.push(waspos);
elemtype.push(thistype.toLowerCase());
elemvalid.push(true);
elemcontent.push(thiscont);
if (thisis != "") elemucontent.push(relative_to_absolute(thiscont.replace(/absolute;/g, "relative;")));
subbits=thiscont.toUpperCase().split(' ID="');
if (subbits.length > 1) {
layer=waspos;
waspos+=subbits[0].length;
waspos+=5;
types=ac.substring(waspos).split('"');
elemid.push(types[0]);
//alert(types[0] + " .y.. " + ac.substring(waspos));
waspos=layer;
} else {
elemid.push("");
}
subbits=thiscont.toUpperCase().split(' CLASS="');
if (subbits.length > 1) {
layer=waspos;
waspos+=subbits[0].length;
waspos+=8;
types=ac.substring(waspos).split('"');
elemclass.push(types[0]);
//alert(types[0] + " .x.. " + ac.substring(waspos));
waspos=layer;
} else {
elemclass.push("");
}
layer=0;
//alert(87);
if (thisis != "") {
if (elemucontent[elemucontent.length - 1].indexOf("<") != -1 && elemucontent[elemucontent.length - 1].indexOf(" ") != -1) {
lsf+="";
tlsf=tlsf.replace("", "" + elemucontent[elemucontent.length - 1] + " |
");
}
} else {
lsf+="";
//alert(88);
lsf+="";
//alert(89);
}
} else if (thistype.substring(0,1) != "!" && thistype.substring(0,1) != "/") {
layer=1;
subbits=ac.substring(ipos).split(">");
thiscont=subbits[0] + ">";
subbits=ac.substring(ipos).split("/>");
if (eval(2 + subbits[0].length) < eval(thiscont.length)) {
thiscont=subbits[0] + "/>";
}
jpos+=thiscont.length;
// alert(ac.substring(ipos, jpos));
if (ipos != jpos) thiscont=ac.substring(ipos, jpos);
ipos=jpos;
if (ac.substring(ipos, eval(2 + ipos)) == "") {
thiscont+="" + ac.substring(eval(2 + ipos), eval(2 + ipos + thistype.length)) + ">";
jpos+=eval(3 + thistype.length);
ipos=jpos;
//alert("!" + " ... " + thistype + " +++ " + thiscont);
}
//alert("<" + thistype + "" + " ... " + thiscont);
//alert("2 ... " + thiscont);
if (thiscont.toUpperCase().indexOf("<" + thistype.toUpperCase()) != -1) {
elemepos.push(-1);
elempos.push(waspos);
elemtype.push(thistype.toLowerCase());
elemvalid.push(true);
elemcontent.push(thiscont);
if (thisis != "") elemucontent.push(relative_to_absolute(thiscont.replace(/absolute;/g, "relative;")));
subbits=thiscont.toUpperCase().split(' ID="');
if (subbits.length > 1) {
layer=waspos;
waspos+=subbits[0].length;
waspos+=5;
types=ac.substring(waspos).split('"');
elemid.push(types[0]);
waspos=layer;
//alert(types[0]);
} else {
elemid.push("");
}
subbits=thiscont.toUpperCase().split(' CLASS="');
if (subbits.length > 1) {
layer=waspos;
waspos+=subbits[0].length;
waspos+=9;
types=ac.substring(waspos).split('"');
elemclass.push(types[0]);
waspos=layer;
//alert(types[0]);
} else {
elemclass.push("");
}
layer=0;
if (thisis != "") {
if (elemucontent[elemucontent.length - 1].indexOf("<") != -1 && elemucontent[elemucontent.length - 1].indexOf(" ") != -1) {
rsf+="";
trsf=trsf.replace("", "" + elemucontent[elemucontent.length - 1] + " |
");
}
} else {
rsf+="";
rsf+="";
}
}
} else if (thistype.substring(0,1) != "/") {
layer=1;
subbits=ac.substring(ipos).split("-->");
thiscont=subbits[0] + "-->";
jpos+=thiscont.length;
if (ipos != jpos) thiscont+=ac.substring(ipos, jpos);
ipos=jpos;
//alert("huh<" + thistype + "" + " ... " + thiscont);
//alert("3 ... " + thiscont);
layer=0;
elemepos.push(-1);
elempos.push(waspos);
elemtype.push("");
elemvalid.push(false);
elemcontent.push(thiscont);
if (thisis != "") elemucontent.push(relative_to_absolute(thiscont.replace(/absolute;/g, "relative;")));
elemid.push("");
elemclass.push("");
}
}
kpos+=bits[ii].length;
kpos++;
}
if (thisis != "") {
lso.innerHTML=lsf;
rso.innerHTML=rsf;
} else {
lso.innerHTML=lsf;
rso.innerHTML=rsf;
if (tlsf.indexOf("", rsf + "" + trsf);
//document.body.innerHTML = document.body.innerHTML.replace(lsf + "", lsf + "" + tlsf);
document.getElementById('lefttd').innerHTML+=tlsf;
document.getElementById('righttd').innerHTML+=trsf;
tlsf=" ";
trsf=" ";
}
}
if (thisis != "") fillarrays('');
}
function docgetclass(inc, intag) {
if (document.getElementsByClassName) {
return document.getElementsByClassName(inc);
} else {
var ijl;
var anarris=[];
var huhs=document.getElementsByTagName(intag);
for (ijl=0; ijl") != -1) {
ispot=document.body.innerHTML.indexOf(intowhat.innerHTML + "");
} else {
ispot=document.body.innerHTML.indexOf(intowhat.innerHTML + "");
}
ispot=creepback(ispot);
lastbit=document.body.innerHTML.substring(ispot);
//alert(document.body.innerHTML.substring(0,ispot));
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
} else {
if (intowhat.tagName != 'A') {
if (document.getElementById('mode').value == 'Before') { // ???
//alert(875);
lastbit=intowhat.innerHTML;
intowhat.innerHTML=placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
} else {
intowhat.innerHTML+=placedhtml.replace('[action]', '[' + raction + ']');
}
} else if (document.body.innerHTML.indexOf(intowhat.innerHTML + "") != -1) {
document.body.innerHTML=document.body.innerHTML.replace(intowhat.innerHTML + "", intowhat.innerHTML + "" + placedhtml.replace('[action]', '[' + raction + ']'));
document.getElementById('mode').value=bef;
} else if (document.body.innerHTML.indexOf(intowhat.innerHTML + "") != -1) {
document.body.innerHTML=document.body.innerHTML.replace(intowhat.innerHTML + "", intowhat.innerHTML + "" + placedhtml.replace('[action]', '[' + raction + ']'));
document.getElementById('mode').value=bef;
}
}
} else if (document.body.innerHTML.toUpperCase().indexOf("<" + intowhat.tagName.toUpperCase() + ' ID="' + intowhat.id.toUpperCase() + '"') != -1) {
ispot=document.body.innerHTML.toUpperCase().indexOf("<" + intowhat.tagName.toUpperCase() + ' ID="' + intowhat.id.toUpperCase() + '"');
if (document.getElementById('mode').value == 'After') ispot=creepalong(ispot, intowhat.id);
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
}
} else {
//for (var ii=0; ii=0; ii--) {
if (intowhat.item(ii).innerHTML != "") {
if (document.getElementById('mode').value == 'Before' && intowhat.item(ii).tagName == 'A') {
if (document.body.innerHTML.indexOf(intowhat.item(ii).innerHTML + "") != -1) {
ispot=document.body.innerHTML.indexOf(intowhat.item(ii).innerHTML + "");
} else {
ispot=document.body.innerHTML.indexOf(intowhat.item(ii).innerHTML + "");
}
ispot=creepback(ispot);
lastbit=document.body.innerHTML.substring(ispot);
//alert(document.body.innerHTML.substring(0,ispot));
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
} else {
if (intowhat.item(ii).tagName != 'A') {
if (document.getElementById('mode').value == 'Before') { // ???
//alert(872);
lastbit=intowhat.item(ii).innerHTML;
intowhat.item(ii).innerHTML=placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
} else {
intowhat.item(ii).innerHTML+=placedhtml.replace('[action]', '[' + raction + ']');
}
} else if (document.body.innerHTML.indexOf(intowhat.item(ii).innerHTML + "") != -1) {
document.body.innerHTML=document.body.innerHTML.replace(intowhat.item(ii).innerHTML + "", intowhat.item(ii).innerHTML + "" + placedhtml.replace('[action]', '[' + raction + ']'));
document.getElementById('mode').value=bef;
} else if (document.body.innerHTML.indexOf(intowhat.item(ii).innerHTML + "") != -1) {
document.body.innerHTML=document.body.innerHTML.replace(intowhat.item(ii).innerHTML + "", intowhat.item(ii).innerHTML + "" + placedhtml.replace('[action]', '[' + raction + ']'));
document.getElementById('mode').value=bef;
}
}
} else if (intowhat.item(ii).id) {
if (intowhat.item(ii).id != '') {
if (document.body.innerHTML.toUpperCase().indexOf("<" + intowhat.item(ii).tagName.toUpperCase() + ' ID="' + intowhat.item(ii).id.toUpperCase() + '"') != -1) {
ispot=document.body.innerHTML.toUpperCase().indexOf("<" + intowhat.item(ii).tagName.toUpperCase() + ' ID="' + intowhat.item(ii).id.toUpperCase() + '"');
if (document.getElementById('mode').value == 'After') {
ispot=creepalong(ispot, intowhat.item(ii).id);
}
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
}
}
}
}
}
} else if (intowhat != "") {
cintowhat="" + eval(intowhat);
//alert(cintowhat);
if (cintowhat.substring(0,1) == '-') {
//alert(8);
if (elemid[eval(-1 - intowhat)] != "" && eval(elemcontent[eval(-1 - intowhat)].length) > 50) {
//alert(88);
tih=document.getElementById(elemid[eval(-1 - intowhat)]).innerHTML;
//alert(888);
if (tih != "") {
//alert(8888);
ispot=document.body.innerHTML.indexOf(tih);
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
} else {
ispot=document.body.innerHTML.toUpperCase().indexOf("<" + document.getElementById(elemid[eval(-1 - intowhat)]).tagName.toUpperCase() + ' ID="' + document.getElementById(elemid[eval(-1 - intowhat)]).id.toUpperCase() + '"');
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
tih="x";
}
}
//alert(88888);
if (tih == "") {
//alert(888888);
ispot=elempos[eval(-intowhat - 1)];
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
}
} else if (cintowhat.substring(0,1) >= '0' && cintowhat.substring(0,1) <= '9') {
//alert(elempos[eval(-1 + intowhat)] + ": " + elemcontent[eval(-1 + intowhat)]);
if (elemid[eval(-1 + intowhat)] != "" && eval(elemcontent[eval(-1 + intowhat)].length) > 50) {
//alert(elemid[eval(-1 + intowhat)]);
//alert(6);
if (document.getElementById(elemid[eval(-1 + intowhat)]).innerHTML == null) {
//alert(66);
if (document.body.innerHTML.toUpperCase().indexOf("<" + document.getElementById(elemid[eval(-1 + intowhat)]).tagName.toUpperCase() + ' ID="' + document.getElementById(elemid[eval(-1 + intowhat)]).id.toUpperCase() + '"') != -1) {
//alert(666);
ispot=document.body.innerHTML.toUpperCase().indexOf("<" + document.getElementById(elemid[eval(-1 + intowhat)]).tagName.toUpperCase() + ' ID="' + document.getElementById(elemid[eval(-1 + intowhat)]).id.toUpperCase() + '"');
ispot=creepalong(ispot, document.getElementById(elemid[eval(-1 + intowhat)]).id);
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
}
} else {
//alert(6666);
tih=document.getElementById(elemid[eval(-1 + intowhat)]).innerHTML;
if (tih != "" && tih != null) {
//alert(66666);
ispot=document.body.innerHTML.indexOf(tih);
ispot+=tih.length;
ispot+=3;
ispot+=elemtype[eval(-1 + intowhat)].length;
//alert("IsPot=" + eval(elempos[eval(-1 + intowhat)]) + " + " + eval(elemcontent[eval(-1 + intowhat)].length) + " = " + ispot);
} else {
//alert(666666);
if (document.body.innerHTML.toUpperCase().indexOf("<" + document.getElementById(elemid[eval(-1 + intowhat)]).tagName.toUpperCase() + ' ID="' + document.getElementById(elemid[eval(-1 + intowhat)]).id.toUpperCase() + '"') != -1) {
//alert(654);
ispot=document.body.innerHTML.toUpperCase().indexOf("<" + document.getElementById(elemid[eval(-1 + intowhat)]).tagName.toUpperCase() + ' ID="' + document.getElementById(elemid[eval(-1 + intowhat)]).id.toUpperCase() + '"');
ispot=creepalong(ispot, document.getElementById(elemid[eval(-1 + intowhat)]).id);
lastbit=document.body.innerHTML.substring(ispot);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
document.getElementById('mode').value=bef;
}
}
}
}
if (tih == "") {
if (document.body.innerHTML.indexOf(elemcontent[eval(-1 + intowhat)]) != -1) {
ispot=document.body.innerHTML.indexOf(elemcontent[eval(-1 + intowhat)]);
ispot+=eval(elemcontent[eval(-1 + intowhat)].length);
//alert("Ispot=" + eval(elempos[eval(-1 + intowhat)]) + " + " + eval(elemcontent[eval(-1 + intowhat)].length) + " = " + ispot);
} else if (eval(elemepos[eval(-1 + intowhat)]) >= 0) {
ispot=eval(elemepos[eval(-1 + intowhat)]);
//alert("ISpot=" + eval(elempos[eval(-1 + intowhat)]) + " + " + eval(elemcontent[eval(-1 + intowhat)].length) + " = " + ispot);
} else {
ispot=eval(elempos[eval(-1 + intowhat)]) + eval(elemcontent[eval(-1 + intowhat)].length);
}
}
//alert("ispot=" + eval(elempos[eval(-1 + intowhat)]) + " + " + eval(elemcontent[eval(-1 + intowhat)].length) + " = " + ispot);
lastbit=document.body.innerHTML.substring(ispot);
//alert(lastbit);
document.body.innerHTML=document.body.innerHTML.substring(0,ispot) + placedhtml.replace('[action]', '[' + raction + ']') + lastbit;
} else {
//alert(987);
slotthisin(placedhtml.replace('[action]', '[' + raction + ']'), document.getElementById(intowhat));
}
} else {
document.body.innerHTML=placedhtml.replace('[action]', '[' + raction + ']') + document.body.innerHTML;
}
fillarrays('');
document.getElementById('mode').value=bef;
}
function firstoff() { // proof of concept only
slotthisin("", document.getElementsByTagName('a'));
slotthisin("", 'myh1');
slotthisin("");
slotthisin("", document.getElementsByTagName('p'));
slotthisin("", 'mybut');
slotthisin("", document.getElementById('myh2'));
}
function onclickf(proposedhtml, slotthing) {
if (typeof slotthing === 'undefined') {
slotthisin(proposedhtml);
} else if (slotthing == " ") {
slotthisin(proposedhtml, '');
} else if (slotthing == "") {
if (bigthing == "") {
slotthisin(proposedhtml);
} else {
slotthisin(proposedhtml, eval(bigthing));
}
} else {
slotthisin(proposedhtml, eval(slotthing));
}
}
function andthen() {
xf = document.getElementById("myiframe");
yf = (xf.contentWindow || xf.contentDocument);
if (yf.document) { yf = yf.document; }
if (yf.body == null) {
setTimeout(andthen, 2000);
} else {
fillarrays(encodeURIComponent(yf.body.innerHTML));
}
}
function changedhtml(inv) {
if (inv.indexOf("<") != -1 || inv.indexOf("lt;") != -1) {
inv=inv;
} else if (inv != "") {
document.getElementById("myiframe").src=decodeURIComponent(inv);
document.getElementById('leftfromselect').innerHTML=document.getElementById('leftfromselect').innerHTML.replace("select element to slot in", "select " + decodeURIComponent(inv) + " element to slot in");
document.getElementById('rightfromselect').innerHTML=document.getElementById('rightfromselect').innerHTML.replace("select element to slot in", "select " + decodeURIComponent(inv) + " element to slot in");
setTimeout(andthen, 2000);
if (1 == 2) {
xf = document.getElementById("myiframe");
yf = (xf.contentWindow || xf.contentDocument);
if (yf.document) { yf = yf.document; }
fillarrays(encodeURIComponent(yf.body.innerHTML));
}
} else {
var ubits=document.URL.split("?");
var egis=ubits[0].replace("/HTMLCSS/slotin.html", "/").replace("/slotin.html", "/").replace("slotin.html", "").replace("/HTMLCSS/slotin.htm", "/").replace("/slotin.htm", "/").replace("slotin.htm", "");
var preinv=prompt("Optionally supply URL whose HTML Elements you would like to be able to place eg. " + egis, egis);
if (preinv == null) preinv="";
if (preinv != "") {
url=preinv;
changedhtml(preinv);
}
}
}
function placeit(ois,oid,oval) {
var okay=true;
var tbid=oid=oid.replace('fromselect', 'intext');
var tbido=document.getElementById(tbid);
if (oval.indexOf("<") != -1) {
okay=false;
tbido.value=oval;
} else if (decodeURIComponent(oval).indexOf("<") != -1) {
okay=false;
tbido.value=decodeURIComponent(oval);
} else {
tbido.value=elemucontent[eval(oval)]; //.replace(//g, ">");
}
if (okay) {
if (lastw != null) {
lastw.close();
lastw=null;
}
lastw=window.open("", "_blank", "top=100,left=100,width=400,height=400");
lastw.document.write("Slotting In HTML Elements - RJM Programming - September, 2015" + tbido.value + "");
} else {
ois.style.backgroundColor='purple';
window.scrollTo(0, 0);
}
} |