|
Post by Wormopolis on Sept 1, 2010 16:20:59 GMT -8
Browser Tested: IE and FF placement: Global Footer
Allows you to put multiple HTML objects (defined in array) that are selectable from a drop down in the modify profile page. Similar to what crossfury does, but this code stores data in the customtitle/personaltext area. selections are encrypted to conserve space.
if you add in new items, add them to the end of the list or you will mess up what users already have. The same goes for deleting items from the list.
<style type="text/css"> .AOtable { border: 1px solid #000000} .AOtableTitle {text-align: center; font-size:12px; font-weight:bold; background-color:#DDDDDD;} .AOtableContent {background-color:#EEEEEE;} </style>
<script type="text/javascript"> <!-- // Additional HTML objects in MP // v2.1 // by Wormopolis - [url]www.wormocodes.com[/url] // Originally coded for mementomori site - request by Rhune // Keep header intact - do not rip
var MPObjectarray=[ ['title1','<font color="FF0000">SUPER</font>',true], //title in dropdown, HTML, true/false FORCE newline after ['title2','<font color="FFFF00">DOOPER</font>',true], ['title3','<font color="00FF00">mini</font>',true], ['title4','<font color="00FFFF">MAJOR</font>',true], ['title5','<font color="0000FF">Wormo!</font>',true], ['picture1','<img src="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/ladybug.jpg" />', false], ['picture2','<img src="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/trophy.jpg" />', false], ['picture3','<img src="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/megaphone.jpg" />', false], ['picture4','<img src="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/piggy.jpg" />', false] //no comma last line ];
var noteToDropdown="(hold ctrl to select multiple objects)"; var modifyprofileSectionTitle="Current Things:";
var useTableAroundDisplay=true; //set true if you want objects to be in a table in MP var displayTableTitle="Current Things";
var AOstaffOnly=true; //set false if you want members to edit their own.
var objectPlacement=2; //0=CT spot, 1=PT spot, 2=very bottom var objectRowMax=1; //how many objects across before new line
// no need to edit below unless you know what you are doing
if (document.modifyForm) {
var rowfind=(AOstaffOnly ? document.modifyForm.customtitle : document.modifyForm.personaltext);
nwrw1=rowfind.parentNode.parentNode.parentNode.cloneNode(true);
nwrw1.firstChild.firstChild.innerHTML=modifyprofileSectionTitle; opts=""; for (ii=0; ii<MPObjectarray.length; ii++) { opts+='<option>'+MPObjectarray[ii][0]+'</option>'; } function seeThings() { getdrop=document.getElementById('MMdrop'); ret=""; for (a=0; a<getdrop.options.length; a++) { if (getdrop.options[a].selected) ret+= (ret ? ',' : '') + a; } ret=ret.split(','); stg=document.getElementById('stage'); stg.style.whiteSpace='nowrap'; stg.innerHTML=""; var obcount=0, nwstuff=''; for (b=0; b<ret.length; b++) { if (ret[b]) nwstuff+=MPObjectarray[parseInt(ret[b])][1]+(MPObjectarray[parseInt(ret[b])][2] ? "<br>" : ""); if (++obcount>objectRowMax && !MPObjectarray[parseInt(ret[b])][2]) {nwstuff+="<br>"; obcount=0;} } stg.innerHTML=nwstuff; } nwrw1.firstChild.nextSibling.nextSibling.innerHTML="<select id='MMdrop' multiple='true' style='height: 100'>"+opts+"</select> "+noteToDropdown + "<br><input type='button' value='Apply' onclick='seeThings()'></input>"; nwrw1.firstChild.nextSibling.firstChild.innerHTML=""; nwrw1.firstChild.nextSibling.firstChild.id="stage";
spot=rowfind.parentNode.parentNode.parentNode; spot.parentNode.insertBefore(nwrw1, spot.nextSibling);
function SGinsertStuff() { getdrop=document.getElementById('MMdrop'); ret=""; rettemp=""; for (a=getdrop.options.length-1; a>=0; a--) { if (getdrop.options[a].selected) rettemp+='1'; else rettemp+='0'; if (rettemp.length==32) { ret+=(parseInt(rettemp, 2)).toString(36) + '.'; rettemp=""; } } ret+=(parseInt(rettemp, 2)).toString(36); rowfind.value=rowfind.value+" [SG:"+ret+"]"; }
if (rowfind.value.match(/\s?\[SG:(.*?|\.)\]/)) { keepit=RegExp.$1; rowfind.value=rowfind.value.replace(/\s?\[SG:(.*?|\.)\]/,''); keepit=keepit.split('.'); holdtemp=""; for (kk=0; kk<keepit.length-1; kk++) { holdtemp+= ('00000000000000000000000000000000' + (parseInt(keepit[kk],36)).toString(2) ).slice(-32); } holdtemp+= ('00000000000000000000000000000000' + (parseInt(keepit[kk],36)).toString(2)).slice(-(MPObjectarray.length - 32*kk)); getdrop=document.getElementById('MMdrop'); pos=0; for (c=holdtemp.length-1; c>=0; c--) { getdrop.options[pos++].selected=parseInt(holdtemp.charAt(c)); } seeThings(); }
if (document.modifyForm.addEventListener) { document.modifyForm.addEventListener('submit',SGinsertStuff,true); } else { document.modifyForm.attachEvent('onsubmit',SGinsertStuff); }
} if (pb_action.match(/display|viewprofile|search2|recent/)) { for (tds=document.getElementsByTagName('td'), sg=0; sg<tds.length; sg++) { if (tds[sg].width=='20%' && tds[sg].className.match(/windowbg/) && tds[sg].vAlign=='top') { if (tds[sg].innerHTML.match(/\s?\[SG:(.*?|\.)\]/)) { keepit=RegExp.$1; keepit=keepit.split('.'); holdtemp=""; for (kk=0; kk<keepit.length-1; kk++) { holdtemp+= ('00000000000000000000000000000000' + (parseInt(keepit[kk],36)).toString(2) ).slice(-32); } holdtemp+= ('00000000000000000000000000000000' + (parseInt(keepit[kk],36)).toString(2)).slice(-(MPObjectarray.length - 32*kk)); //holdtemp=holdtemp.slice(0,MPObjectarray.length); tds[sg].style.whiteSpace='nowrap'; var pos=0, nwstuff="", obcount=0; for (c=holdtemp.length-1; c>=0; c--) { if (holdtemp.charAt(c)=='1') nwstuff+=MPObjectarray[pos][1]+(MPObjectarray[pos][2] ? "<br>" : ""); if (++obcount>objectRowMax && !MPObjectarray[pos][2]) {nwstuff+="<br>"; obcount=0;} pos++; }
if (useTableAroundDisplay) { nwstuff='<table class="AOtable"><tr><td class="AOtableTitle">' + displayTableTitle + '</td></tr><tr><td class="AOtableContent">' + nwstuff + '</td></tr></table'; }
if (objectPlacement==0) { //replace CT tds[sg].innerHTML=tds[sg].innerHTML.replace(/\s?\[SG:(.*?|\.)\]/,nwstuff); } else if (objectPlacement==1) { //before PT tds[sg].innerHTML=tds[sg].innerHTML.replace(/\s?\[SG:(.*?|\.)\]/,''); avArea=tds[sg].getElementsByTagName('center')[0]; nwdv=document.createElement('div'); nwdv.innerHTML=nwstuff; avArea.insertBefore(nwdv, avArea.firstChild.nextSibling); } else { //bottom of MP tds[sg].innerHTML=tds[sg].innerHTML.replace(/\s?\[SG:(.*?|\.)\]/,''); nwdv=document.createElement('div'); nwdv.innerHTML=nwstuff; tds[sg].appendChild(nwdv); } } } } } // --> </script>
Preview: working on it...
|
|
|
Post by Wormopolis on Mar 3, 2011 0:11:05 GMT -8
version update 1.5: added in ability to put objects at bottom of MP. added in variable to have images next to each other until a certain number is reached, then it gets a newline.
|
|
|
Post by Wormopolis on Mar 21, 2012 21:39:36 GMT -8
version update 1.7: added ability to let members choose thier own stuff, but it uses personal text space.
|
|
|
Post by Wormopolis on Mar 27, 2012 18:11:12 GMT -8
version update 2.0: larger arrays now work (basically every 32 items adds 6 more characters to CT length). also added ability to have items show up in a table instead of just by themselves. tables have classes (included CSS).
|
|
|
Post by Wormopolis on Mar 28, 2012 13:17:57 GMT -8
version update 2.1: bug fixes for items selected around cutoff spots
|
|
lockedindreams
Not New Member
Posts: 5
lockedindreams said 0 great things
|
Post by lockedindreams on Jan 13, 2013 17:00:02 GMT -8
Can you please explain in better detail what this does?
|
|
lockedindreams
Not New Member
Posts: 5
lockedindreams said 0 great things
|
Post by lockedindreams on Jan 13, 2013 17:00:29 GMT -8
Or less detail... It's a little too adept for small minds like mine.
|
|
|
Post by Wormopolis on Jan 14, 2013 0:30:10 GMT -8
sure.
it basically lets you setup and array of items, either images or text, that get added to the miniprofile. similar to an awards code but it was written long before todges and not as complete and interfacable.
the array once created is static, meaning it cant be changed other then to add new stuff at the end of it, because the way it sores data in the CT placement matters. if you move or delete something, it changes what will show up in everyone's MP. adding new items doesnt affect things because of just how it stores data.
only members with ability to edit custom title can add things to a member. it presents as a dropdown list in the edit profile, and allows you to select multiple items in the list. once you save, data is stored in CT and displaying the MP shows the items. alternatively, you can allow members to choose their own items, but it uses personal text space for it (meaning they lose that space for actual personal text).
|
|