|
Post by Wormopolis on Dec 19, 2008 14:22:25 GMT -8
Browser tested: IE and FF Placement: Global Footer puts a drop down list next to the "To:" box in the new PM page that contains a list of all the members it has found. Display names are shown in the drop down, but when you select one, it puts their username in the to box. Every name has an expiration to help keep the list cleaner by deleting members from the list you have seen in x many days. other variables include switches to turn on/off where names get captured from. an Additional feature is included that allows you to check a "Include recipients in message" box, that will let everyone see that the PM was sent to multiple people. If a PM is received that was sent to multiple people, a new "reply to all" button appears that will automatically fill the "to" box will everyone's names for you. <script type="text/javascript"> <!-- // PM member list drop down // Keep header intact - Do not repost // By Wormopolis // version 2.0
var captureFromIC=true; //capture names from the info center var captureFromMemberlist=true; var captureFromPosts=true; var captureFromPMs=true; var purge = 30; //days before members are purged from list unless recaptured var newReplyAllButtonImage="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/replyToAll.gif";
if (pb_username!='Guest') {
function XBrowserAddHandler(target,eventName,handlerName) { //eventhandler addition found on web by Andy Smith // [url]http://weblogs.asp.net/asmith/archive/2003/10/06/30744.aspx[/url] if ( target.addEventListener ) { target.addEventListener(eventName, function(e){target[handlerName](e);}, false); } else if ( target.attachEvent ) { target.attachEvent("on" + eventName, function(e){target[handlerName](e);}); } else { var originalHandler = target["on" + eventName]; if ( originalHandler ) { target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);}; } else { target["on" + eventName] = target[handlerName]; } } } var pb_DOMstorage; //global storage function open Source (but strongly bonesish) function getDOMStore(){ pb_DOMstorage='global'; if(window.globalStorage)return globalStorage[location.hostname]; pb_DOMstorage='local'; if(window.localStorage) return window.localStorage; pb_DOMstorage='element';
if(document.body.addBehavior){ var a=document.getElementById('persistie'), b; if(!a){ a=document.createElement('input'); a.className='userData'; a.style.display='none'; a.type="hidden"; a.value=""; a.id="persistie"; a.addBehavior("#default#userData"); document.links[0].appendChild(a); } b={storage:a, setItem:function(key,data){this.storage.setAttribute(key,data);this.storage.save(pb_forum);}, getItem:function(key){this.storage.load(pb_forum);return this.storage.getAttribute(key);}} return b; } pb_DOMstorage='cookie'; if (document.cookie) { var b={storage:document.cookie, setItem: function(key, val) {tmpDt=new Date(); document.cookie=val+'; expires='+tmpDt.setFullYear(tmpDt.getFullYear()+1);}, getItem: function(key) {if (document.cookie.match(new RegExp(key+'=(.*?)(;|$)'))) {res=RegExp.$1; return res;} return null;}} return b; } return null; }
var todayDate=new Date(); var purgeDate=new Date(); purgeDate.setDate(todayDate.getDate()+purge); var master_mem_list = new Array(); var master_mem_list_DN = new Array(); var master_mem_list_EXP = new Array(); var keeper=getDOMStore();
if (keeper) {
var tmpML=unescape(keeper.getItem('memb_list')); var tmpMLDN=unescape(keeper.getItem('memb_list_DN')); var tmpMLEXP=unescape(keeper.getItem('memb_list_EXP'));
master_mem_list=tmpML.split(','); master_mem_list_DN=tmpMLDN.split(','); master_mem_list_EXP=tmpMLEXP.split(',');
var mem_list1=new Array(); var mem_list1_DN=new Array(); var mem_list1_EXP=new Array();
// look for previously unsaved members in info center: if (pb_action=='home' && captureFromIC) { for (tds=document.getElementsByTagName('td'), zi=tds.length-1; zi>0; zi--) { if (tds[zi].innerHTML.match(/Users In The Past 24 Hours/) && tds[zi].className=='catbg'){ iTlnks=tds[zi].parentNode.nextSibling.firstChild.nextSibling.getElementsByTagName('a'); for (j=1; j<iTlnks.length; j++) { if (iTlnks[j].className.match(/group/)) { u_name=(iTlnks[j].href.match(/user=(.*?)$/) ? RegExp.$1 : null); d_name=(iTlnks[j].innerHTML.match(/font/i))? iTlnks[j].innerHTML.replace(/<\/?font(.*?)>/ig,'') : iTlnks[j].innerHTML; mem_list1.push(u_name); mem_list1_DN.push(d_name); mem_list1_EXP.push(purgeDate.getFullYear()+"-"+purgeDate.getMonth()+"-"+purgeDate.getDate()); } } } } }
// look for previously unsaved members in member list: if (pb_action=='members' && captureFromMemberlist) { var mems=document.getElementsByTagName('tr'); for (mi=0; mi<mems.length; mi++) { if (mems[mi].cells[0].getElementsByTagName('a')[0] && mems[mi].cells[0].getElementsByTagName('a')[0].href.match(/viewprofile\&user/i)) { clay=mems[mi].cells[0].getElementsByTagName('a')[0]; u_name=(clay.href.match(/user=(.*?)$/) ? RegExp.$1 : null); d_name=(clay.getElementsByTagName('font')[0] ? clay.innerHTML.replace(/<\/?font(.*?)>/ig,'') : clay.innerHTML); mem_list1.push(u_name); mem_list1_DN.push(d_name); mem_list1_EXP.push(purgeDate.getFullYear()+"-"+purgeDate.getMonth()+"-"+purgeDate.getDate()); } } }
// look for previously unsaved members in inbox/outbox: if (pb_action=='pm' && captureFromPMs) { var pRows=document.pmForm.parentNode.getElementsByTagName('table')[0].rows; for (p=1; p<pRows.length-1; p++) { var nCell=pRows[p].cells[3]; if (nCell.getElementsByTagName('a')[0] && nCell.getElementsByTagName('a')[0].href.match(/action=viewprofile&user=(.*?)$/)) { u_name=RegExp.$1; mud=nCell.getElementsByTagName('a')[0]; d_name=(mud.getElementsByTagName('font')[0] ? mud.innerHTML.replace(/<\/?font(.*?)>/ig,'') : mud.innerHTML); mem_list1.push(u_name); mem_list1_DN.push(d_name); mem_list1_EXP.push(purgeDate.getFullYear()+"-"+purgeDate.getMonth()+"-"+purgeDate.getDate()); } } }
// look for previously unsaved members in post authors: if (pb_action=='display' && captureFromPosts) { for (tds=document.getElementsByTagName('td'),po=0; po<tds.length; po++) { if (tds[po].width=='20%' && tds[po].className.match(/windowbg/) && tds[po].vAlign=='top') { var nlnk=tds[po].getElementsByTagName('a'); if (nlnk[2] && nlnk[2].className.match(/group/) && nlnk[2].href.match(/viewprofile&user=(.*?)$/)) { u_name=RegExp.$1; dirt=nlnk[2]; d_name=(dirt.getElementsByTagName('font')[0] ? dirt.innerHTML.replace(/<\/?font(.*?)>/ig,'') : dirt.innerHTML); mem_list1.push(u_name); mem_list1_DN.push(d_name); mem_list1_EXP.push(purgeDate.getFullYear()+"-"+purgeDate.getMonth()+"-"+purgeDate.getDate()); } } } }
//if (pb_username=='admin') alert(master_mem_list); //if (pb_username=='admin') alert(mem_list1);
// replace old entries with updated and add new entries if (master_mem_list.length==0) { master_mem_list=mem_list1; master_mem_list_DN=mem_list1_DN; master_mem_list_EXP=mem_list1_EXP; } else { for (r=0; r<mem_list1.length; r++) { for (s=0; s<master_mem_list.length; s++) { if (master_mem_list[s]==mem_list1[r]) { master_mem_list_DN[s]=mem_list1_DN[r]; master_mem_list_EXP[s]=mem_list1_EXP[r]; mem_list1.splice(r,1); mem_list1_DN.splice(r,1); mem_list1_EXP.splice(r,1); r--; } } } } if (mem_list1.length>0) { master_mem_list=master_mem_list.concat(mem_list1); master_mem_list_DN=master_mem_list_DN.concat(mem_list1_DN); master_mem_list_EXP=master_mem_list_EXP.concat(mem_list1_EXP); }
// cleanup duplicate entries in master list // and purge members not seen in a while for (a=0; a<master_mem_list.length; a++) { if (master_mem_list_EXP[a]) { temp=master_mem_list_EXP[a].split("-"); chkDate=new Date(temp[0],temp[1],temp[2]); } if (!master_mem_list_EXP[a] || todayDate>chkDate || master_mem_list[a]=='' || master_mem_list[a]=='null' || master_mem_list[a]==null || (master_mem_list[a+1] && master_mem_list[a]==master_mem_list[a+1])) { master_mem_list.splice(a,1); master_mem_list_DN.splice(a,1); master_mem_list_EXP.splice(a,1); a--; } }
// sort member list by Display Name for (v=0; v<master_mem_list_DN.length-1; v++) { for (w=v+1; w<master_mem_list_DN.length; w++) { if (master_mem_list_DN[w].toUpperCase()<master_mem_list_DN[v].toUpperCase()) { var tempa = master_mem_list_DN[w]; master_mem_list_DN[w] = master_mem_list_DN[v]; master_mem_list_DN[v] = tempa; var tempb = master_mem_list[w]; master_mem_list[w] = master_mem_list[v]; master_mem_list[v] = tempb; var tempc = master_mem_list_EXP[w]; master_mem_list_EXP[w] = master_mem_list_EXP[v]; master_mem_list_EXP[v] = tempc; } } }
// store master member list in DOM storage keeper.setItem('memb_list',escape(master_mem_list)); keeper.setItem('memb_list_DN',escape(master_mem_list_DN)); keeper.setItem('memb_list_EXP',escape(master_mem_list_EXP));
// modify PM form to include a dropdown if (location.href.match(/=pmsend/i) && !document.postForm.to.disabled) {
destCell=document.postForm.to.parentNode.previousSibling; nDiv=document.createElement("div"); nDiv.id="seldiv"; nDiv.align="right"; txtNd= document.createTextNode("Member List "); chkBx= document.createElement('input'); chkBx.type="checkbox"; chkBx.id = "addRecips"; chkBx.name = "addRecips"; txtNd2 = document.createTextNode("Include Recipients in Message"); nSel=document.createElement("select"); nSel.id="memlist"; recipCell2=destCell.nextSibling.getElementsByTagName('input')[0]; recipCell=document.createElement("textarea"); recipCell2.tabIndex="8"; recipCell2.style.display='none'; recipCell2.parentNode.insertBefore(recipCell, recipCell2); iBr=document.createElement('br'); recipCell.parentNode.insertBefore(iBr,recipCell.nextSibling); recipCell.value=recipCell2.value; recipCell.style.height=50; recipCell.style.width=500; recipCell.wrap="soft"; recipCell.tabIndex="2";
// populate drop down with display name/username value var tmpopt=document.createElement('option'); tmpopt.value=''; tmpopt.innerHTML="Captured Members"; nSel.appendChild(tmpopt); for (jsm=0;jsm<master_mem_list.length;jsm++) { d_name=master_mem_list_DN[jsm]; u_name=master_mem_list[jsm]; ne_opt=document.createElement("option"); nSel.appendChild(ne_opt); ne_opt.value=u_name; ne_opt.innerHTML=d_name; }
function changeRecips(e) { vlu=(this.options[this.selectedIndex].value); txtbx=this.parentNode.parentNode.nextSibling.getElementsByTagName('textarea')[0]; txtbx2=this.parentNode.parentNode.nextSibling.getElementsByTagName('input')[0]; txtbx.value+= (txtbx.value!="" && vlu!='' ? ', ' : '')+vlu; txtbx2.value=txtbx.value; }
function finalizeRecips(e) { vlu=this.parentNode.getElementsByTagName('input')[0]; vlu.value=this.value; }
function addRecipsIntoMessage(e) { rec="RECIPIENTS: ["+ document.postForm.to.value + "]\n\n"; addRecip=document.getElementById('addRecips'); if (addRecip.checked) document.postForm.message.value = rec + document.postForm.message.value; }
var theRecipList= nSel; theRecipList.ClickHandler = changeRecips; var theRealRecipList = recipCell; theRealRecipList.ClickHandler = finalizeRecips; postForm.ClickHandler = addRecipsIntoMessage;
XBrowserAddHandler(theRecipList,"change","ClickHandler"); XBrowserAddHandler(theRealRecipList,"mouseout","ClickHandler"); XBrowserAddHandler(theRealRecipList,"blur","ClickHandler"); XBrowserAddHandler(postForm,"submit","ClickHandler");
nDiv.appendChild(txtNd); nDiv.appendChild(nSel); nDiv.appendChild(iBr.cloneNode(true)); nDiv.appendChild(chkBx); nDiv.appendChild(txtNd2);
destCell.appendChild(nDiv);
}
// add reply to all button if recipient list is present if (location.href.match(/=pmview/i)) { replyButton=document.getElementsByTagName('a'); for (d=0; d<replyButton.length; d++) { if (replyButton[d].href.match(/action=pmsend/i)&&replyButton[d].href.match(/view=/i)) { buttonHolder=replyButton[d]; buttonTray=buttonHolder.parentNode; msg=replyButton[d].parentNode.parentNode.parentNode.nextSibling; break; } } if (msg.innerHTML.match(/RECIPIENTS: \[(.*?)\]/)) { recips=RegExp.$1; newReplyAllButton=buttonHolder.cloneNode(true); temp=newReplyAllButton.href; temp2=temp.split("to=")[0]; newReplyAllButton.href=temp2+"to="+recips+"&noquote"; NRBimg=newReplyAllButton.getElementsByTagName('img'); if (NRBimg[0]){ NRBimg[0].src=newReplyAllButtonImage; NRBimg[0].alt="[Reply All]"; } buttonTray.insertBefore(newReplyAllButton, buttonHolder); } }
}
}
// --> </script>
Preview: Drop down list appears next to recipients box. selecting a name will put the username into to recipients box for you. clicking the "include recipients in message" box will add a line at the top of the message showing everyone who receieved the message This is what the PM will look like to the recipients. Recipients are shown at the top. a "Reply All" button will appear if box was checked when sending. "Reply All" button will automatically insert all the same recipients into the "To" box for you.
PM dropdown anywhere: This will put the same dropdown anywhere you want on your page, but keep in mind it needs the above script to work, and it will only list the users it finds. <script type="text/javascript"> <!-- // PM memberlist drop down - anywhere // by Wormopolis - www.wormocodes.com // requires code above this // requires an element with id="pm_memlist" for placement
nw_nSel=document.createElement('select'); var tmpopt=document.createElement('option'); tmpopt.value=''; tmpopt.innerHTML="Send Member PM"; nw_nSel.appendChild(tmpopt); nw_nSel.onchange=function() {location.href="/index.cgi?action=pmsend&to="+this.options[this.selectedIndex].value;} for (jsm=0;jsm<master_mem_list.length;jsm++) { d_name=master_mem_list_DN[jsm]; u_name=master_mem_list[jsm]; ne_opt=document.createElement("option"); nw_nSel.appendChild(ne_opt); ne_opt.value=u_name; ne_opt.innerHTML=d_name; } if (document.getElementById('pm_memlist')) document.getElementById('pm_memlist').appendChild(nw_nSel);
// --> </script>
|
|
NemØ
Not New Member
Posts: 4
NemØ said 0 great things
|
Post by NemØ on Dec 26, 2008 6:01:33 GMT -8
Permission to use this code for PI site? And will I need to edit anything in the code, like to add the usernames of the members on the site?
|
|
|
Post by Wormopolis on Dec 26, 2008 11:15:29 GMT -8
you dont have to ask permission. These are public codes as long as the headers remain intact.
the only variables you need to edit are the 2 at the top. "purge" is how many days a username remains in the drop down before it is removed (if someone deletes their acct the drop down wont know it). replybuttonimage is the URL of the new "reply all" button that you will see when you get a PM that is addressed to multiple people.
This code will pick up new usernames for the drop down as you see names appear on main page as well as viewing member list.
|
|
NemØ
Not New Member
Posts: 4
NemØ said 0 great things
|
Post by NemØ on Dec 27, 2008 6:41:26 GMT -8
Alright, thanks.
|
|
bunny
Not New Member
Posts: 4
bunny said 0 great things
|
Post by bunny on Jan 26, 2009 3:09:03 GMT -8
ty and writing these must be boring <.<
|
|
|
Post by Wormopolis on Jan 26, 2009 3:45:40 GMT -8
not at all... They provode a mental taxation at times however...
|
|
|
Post by dave on Apr 27, 2009 11:30:27 GMT -8
pbadvertisement.proboards.comIve put this on my advertising forum and when i go to send a PM the drop down box is empty does it need to be purged for it too work ?Ok maybe it updated or something but still there are only a few members in the drop down list not all my members or even all my active members
|
|
|
Post by Wormopolis on Apr 27, 2009 23:52:47 GMT -8
view your member list and then look again. it cant get your members from your board unless it sees them on a page somewhere. what you saw was probably who it saw in the "Users online last 24 hours".
keep in mind that cookies can only store so much information. if you have 100+ users, some people wont get stored. cookies are the only place I could put them. I usually just let it pick up the active users since those are the ones I most likely will send a PM to.
I will add this code to this site so you can see it as well.
|
|
macflurry
Not New Member
Posts: 4
macflurry said 0 great things
|
Post by macflurry on Aug 9, 2010 12:56:40 GMT -8
I know nothing about coding but is it not possible to have the mod just scan the memberlist when you press the New PM or Reply button??
That way it would always be up to date and have every member.
|
|
|
Post by Wormopolis on Aug 9, 2010 15:33:10 GMT -8
where would you get the memberlist from while on the PM page?
|
|
|
Post by Wormopolis on Sept 16, 2010 13:59:21 GMT -8
CODE UPDATE v2.0: Changed storage to try global/local storage before resorting to cookies in order to keep cookie file size down and still remain persistant (Thank you Eton). cleaned up the coding a bit since I wrote this over a year ago added ability to capture from PM list and Post authors added in switches to allow control of where names are captured from cleaned up the name sorting function to exclude font tags from multi-colored names
Enjoy!
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Sept 16, 2010 15:28:22 GMT -8
Dude all I did was toss some links at you but you're welcome. I do however have a suggestion since you're now looking at 5-10MB storage capacity, maybe sub-groups could be added and stored for easy selection (obviously exempt from automatic purging): - » Disciplinary Staff (4 members)
- » Graphics Helpers (3 members)
- » All Staff (11 members)
- » All Hogwarts Students (369 members)
- ----------------------
- user1
- user2
- user3
- userX
perhaps a text input allowing for a group name to be created for the current list of recipients that this PM is about to be sent to so it can be saved for future use (and shows up as a selectable sub-group in the drop down) Edit: That thing I requested in PM you seem to have forgotten about (sticks and stones)
|
|
|
Post by Wormopolis on Sept 16, 2010 15:42:51 GMT -8
oh right! code amended!
and The idea for usergroups has been brought up before but I never thought of adding them in because I was already storing so much. indeed now that my storage capacity has been increased hundred-fold, I can store a members usergroup in a 4th array and make the PM drop down add in all names associated with that usergroup.
the custom group idea is new, however, and intriguing...
and I cant help myself about giving credit to sources. you helped me more then any other coder on PBS so I am complled to show my gratitude.
|
|
|
Post by Wormopolis on Apr 3, 2012 21:05:38 GMT -8
added in "PM dropdown anywhere" accessory code.
|
|