// meld_styles.js // Allow for style mimicing // RJM Programming // October, 2016 var from_o=[]; var from_id=[]; var from_class=[]; var from_type=[]; var from_ih=[]; var complex_types_list="|"; function ms_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) divelem=divs[0]; //alert('class to found'); } if (!divelem && totype != '') { divs=document.getElementsByTagName(totype); onecnt=divs.length; if (onecnt >= 1) divelem=divs[0]; //alert('type to found'); } if (divelem && output) { // thanks to ideas off http://stackoverflow.com/questions/12266320/copy-div-content-to-textarea-or-text-with-the-same-font-family-style //alert('found'); divelem.style.fontFamily = window.getComputedStyle(output,null).fontFamily || output.style.fontFamily || output.currentStyle.getCurrentProperty('font-family'); divelem.style.fontSize = window.getComputedStyle(output,null).fontSize || output.style.fontSize || output.currentStyle.getCurrentProperty('font-size'); divelem.style.border = window.getComputedStyle(output,null).border || output.style.border || output.currentStyle.getCurrentProperty('border'); divelem.style.borderColor = window.getComputedStyle(output,null).borderColor || output.style.borderColor || output.currentStyle.getCurrentProperty('border-color'); divelem.style.borderWidth = window.getComputedStyle(output,null).borderWidth || output.style.borderWidth || output.currentStyle.getCurrentProperty('border-width'); divelem.style.borderStyle = window.getComputedStyle(output,null).borderStyle || output.style.borderStyle || output.currentStyle.getCurrentProperty('border-style'); divelem.style.padding = window.getComputedStyle(output,null).padding || output.style.padding || output.currentStyle.getCurrentProperty('padding'); divelem.style.margin = window.getComputedStyle(output,null).margin || output.style.margin || output.currentStyle.getCurrentProperty('margin'); divelem.style.overflow = window.getComputedStyle(output,null).overflow || output.style.overflow || output.currentStyle.getCurrentProperty('overflow'); //alert('found code done ' + output.id + ' ... ' + window.getComputedStyle(output,null).borderWidth); } if (onecnt > 1) { for (ione=1; ione',' ').split(' ')[0]; var afterstype=inih.split(''); if (afterstype.length > 1) { pf=afterstype[1].split('<')[0].replace(String.fromCharCode(10),'').replace(String.fromCharCode(13),''); if (pf != "") { return pf + '<'; } } } return inih; } function complexity() { var cretval=""; if (('' + from_class[eval(-1 + from_class.length)]).trim() != "") { cretval += ("." + from_class[eval(-1 + from_class.length)]).replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.').replace(' ','.'); } if (('' + from_id[eval(-1 + from_id.length)]).trim() != "") { cretval += ("#" + from_id[eval(-1 + from_id.length)]).trim(); } return cretval; } function butmaybecomplex(ctypes_list,cobj,ctype,ctrue) { var outctypes_list = ctypes_list; var versus=ctype; versus += ":" + window.getComputedStyle(cobj,null).fontFamily || cobj.style.fontFamily || cobj.currentStyle.getCurrentProperty('font-family'); versus += ":" + window.getComputedStyle(cobj,null).fontSize || cobj.style.fontSize || cobj.currentStyle.getCurrentProperty('font-size'); versus += ":" + window.getComputedStyle(cobj,null).border || cobj.style.border || cobj.currentStyle.getCurrentProperty('border'); versus += ":" + window.getComputedStyle(cobj,null).borderColor || cobj.style.borderColor || cobj.currentStyle.getCurrentProperty('border-color'); versus += ":" + window.getComputedStyle(cobj,null).borderWidth || cobj.style.borderWidth || cobj.currentStyle.getCurrentProperty('border-width'); versus += ":" + window.getComputedStyle(cobj,null).borderStyle || cobj.style.borderStyle || cobj.currentStyle.getCurrentProperty('border-style'); versus += ":" + window.getComputedStyle(cobj,null).padding || cobj.style.padding || cobj.currentStyle.getCurrentProperty('padding'); versus += ":" + window.getComputedStyle(cobj,null).margin || cobj.style.margin || cobj.currentStyle.getCurrentProperty('margin'); versus += ":" + window.getComputedStyle(cobj,null).overflow || cobj.style.overflow || cobj.currentStyle.getCurrentProperty('overflow'); if (complex_types_list.indexOf("|" + versus + "|") == -1) { complex_types_list+=versus + "|"; if (!ctrue) outctypes_list=" "; } if (ctrue) return ctypes_list; return outctypes_list; } function lookforvariety() { var htmluptop='
'; var ourih, m_cnt=0, c_i, c_list=[], types_list=";", this_type="", this_typec=""; document.body.innerHTML+=htmluptop; var the_elems=document.getElementsByTagName('*'); for (var jone=0; jone', ' ').split(' ')[0].toLowerCase(); if (the_elems[jone].innerHTML != '' && ourih != '') { if (butmaybecomplex(types_list, the_elems[jone], this_type, false).indexOf(';' + this_type + ';') == -1) { //alert(types_list); from_o.push(the_elems[jone]); from_type.push(this_type); from_ih.push(ourih); document.getElementById('s_wywt').innerHTML+=''; if (the_elems[jone].id) { if (the_elems[jone].id != "") { document.getElementById('s_wywi').innerHTML+=''; from_id.push(the_elems[jone].id); //from_o[eval(-1 + from_o.length)]=the_elems[jone].id; } else { from_id.push(''); } } else { from_id.push(''); } if (the_elems[jone].className) { if (the_elems[jone].className != "") { from_class.push(the_elems[jone].className); c_list=the_elems[jone].className.split(' '); for (c_i=0; c_i' + c_list[c_i] + ''; } } else { from_class.push(''); } } else { from_class.push(''); } this_typec="" + this_type; this_typec+=complexity(); m_cnt=eval(-1 + from_o.length); document.getElementById('s_wyl').innerHTML+=''; m_cnt++; if (butmaybecomplex(types_list,the_elems[jone],this_type,true).indexOf(';' + this_typec + ';') == -1) types_list+=this_typec + ';'; } } else if (types_list.indexOf(';' + this_type + ';') == -1) { document.getElementById('s_wywt').innerHTML+=''; if (the_elems[jone].id) { if (the_elems[jone].id != "") { document.getElementById('s_wywi').innerHTML+=''; from_id.push(the_elems[jone].id); //from_o[eval(-1 + from_o.length)]=the_elems[jone].id; } else { from_id.push(''); } } else { from_id.push(''); } if (the_elems[jone].className) { if (the_elems[jone].className != "") { from_class.push(the_elems[jone].className); c_list=the_elems[jone].className.split(' '); for (c_i=0; c_i' + c_list[c_i] + ''; } } else { from_class.push(''); } } else { from_class.push(''); } this_typec="" + this_type; this_typec+=complexity(); if (types_list.indexOf(';' + this_typec + ';') == -1) types_list+=this_type + ';'; } } } } setTimeout(lookforvariety, 1000);