|
Post by Wormopolis on Mar 11, 2011 3:10:47 GMT -8
Browser Tested: IE and FF placement: BOARD footer (preferably), can go into global footer but its a big code and might cause some slowing This code will let you create a custom calendar from data stored inside a thread. Has multiple variables for control: nwcalBtnImg deleteCalBtn housekeepingBtn these are just button images in case you want to use your own allowThreads set true if you want to allow regular threads created in board as well as new calendars usersAllowedHousekeep these are users who can access the raw data of the first post usersAllowedDeleteCal these are users who are allowed to delete a calendar. they must have the power to delete threads allowRegularMembersToAddEvents set true if you want regular members to submit events. they get a message saying it must be approved. when a moderator that has power to modify posts looks at the calendar, they will see a message at the top letting him know there are pending submissions. clicking it will show them the first submission and if accepted, to the modify event page where they can make changes or add it as is. approveMsg The message the members see when they submit events. moderators wont see this message. There is also a whole bunch of CSS at the top so you can customize the look of your calendars. code: <style type="text/css"> .calTable {background-color: #000000} .dayLabels {color: #FF0000; background-color: #222222; text-align: center;} /* the days labeled across the top */ .calDays {color: #00FF00; background-color: #000022} .curDay {color: #FFFF00; font-weight: bold; background-color: #000022; border: #FFFF00 1px solid;} .calDiv {width: 100%; align: center;} /* container for calendar */ .emphasize {background-color: #002255;} /*color for number highlight on hover*/ font.event {color: #FF0000;} /*text color for events*/ a.event {color: #FF4400;} /*text color for events*/ .calTable span {color: #ffffff;} /*month and << >> colors*/ .alertmsg {background-color: #FF4400; color: #FFFFFF; text-align: center;} /* alert message for pending submissions */ </style>
<script type="text/javascript"> <!-- // calendar+ code v1.4 // add a calendar into a board that pulls data from posts // by Wormopolis - www.wormocodes.com // keep header intact - do not repost
// for the love of all that is decent do NOT put this code in global footer
var nwcalBtnImg="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/nwcal.gif"; var deleteCalBtn="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/delcal.gif"; var housekeepingBtn="http://i197.photobucket.com/albums/aa250/WORMOPOLIS/housekeeping.gif";
var allowThreads=true; //set true if you want to allow regular threads created in board as well
var usersAllowedHousekeep='admin|user1|user2'; //seperate by | var usersAllowedDeleteCal='admin|user1|user2'; //seperate by | - must have delete thread power
var allowRegularMembersToAddEvents=true; //set true if you want them to submit events var approveMsg="A Moderator Must Approve This Event Before Its Added";
// no need to edit below, unless you wanna do something weird
var weekLabels=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; var monthLabels=['January','February','March','April','May','June','July','August','September','October','November','December'];
// definitely no need to edit below
function createCalendar(m, y) { // create Calendar grid var calTable=document.createElement('table'); with (calTable) { cellPadding=1; cellSpacing=2; className="calTable"; width="100%"; } var dayRow=calTable.insertRow(0);
for (w=0; w<weekLabels.length; w++) { tmpday=dayRow.insertCell(-1); tmpday.className="dayLabels"; tmpday.appendChild(document.createElement('font')); tmpday.firstChild.size=2; tmpday.firstChild.innerHTML=weekLabels[w]; } var curDate=new Date(), chosenDate=new Date(); var curYear=curDate.getFullYear(); var curMonth=curDate.getMonth(); var curDateKeep=curDate.getDate(); chosenDate.setFullYear(y); chosenDate.setDate(1); chosenDate.setMonth(m); var chosenStartWeekDay=chosenDate.getDay(); var daymark=1-chosenStartWeekDay; var topRow=calTable.insertRow(0); var topRowCell=topRow.insertCell(0); topRowCell.colSpan=7; topRowCell.align="center"; var tmpFnt=document.createElement('font'); tmpFnt.size=3; tmpFnt.style.fontWeight='bold'; var pm=(m==0 ? 11 : m-1), py=(m==0 ? y-1 : y); var nm=(m==11 ? 0 : m+1), ny=(m==11 ? y+1 : y); tmpFnt.innerHTML='<span style="cursor:pointer" onclick="updateCal('+pm+','+py+');"> &l'+'t;&l'+'t; </span><span style="cursor:pointer; width: 200px; display: inline-block" width="200px" onclick="updateCal('+curMonth+','+curYear+');">'+ monthLabels[m]+' '+y+'</span><span style="cursor:pointer" onclick="updateCal('+nm+','+ny+');"> &g'+'t;&g'+'t; </span>'; topRowCell.appendChild(tmpFnt);
function getMonthDays(tmpdate) { //function to find the last day of the month tmpdate.setDate(1); tmpdate.setMonth(tmpdate.getMonth()+1); tmpdate.setHours(tmpdate.getHours()-24); return tmpdate.getDate(); }
var curMonthDays=getMonthDays(chosenDate); var rowTotal=Math.ceil((curMonthDays+chosenStartWeekDay)/7); for (rr=0; rr<rowTotal; rr++) { var nwrw=calTable.insertRow(-1); for (dd=0; dd<7; dd++) { var itsToday=(m==curMonth && y==curYear && daymark==curDateKeep); nwcl=nwrw.insertCell(-1); nwcl.className=(itsToday ? "curDay" : "calDays"); nwcl.vAlign='top'; nwcl.width="14%"; nwcl.style.height="100px"; nwcl.id="calTable_"+daymark; if (daymark>0 && daymark<=curMonthDays) nwcl.innerHTML='<div style="width:20px; height:15px; cursor:pointer" onclick="createNewEntry('+m+','+daymark+','+y+');" title="'+(modkeeper || allowRegularMembersToAddEvents ? 'click to add event' : '')+'" align="center">'+daymark+'</div><table width="100%"><tr><td style="height: 90px; overflow-y: auto; vertical-align: middle; text-align: center;"></td></tr></table>'; nwcl.onmouseover=function() {if (this.firstChild) this.firstChild.className="emphasize";}; nwcl.onmouseout=function() {if (this.firstChild) this.firstChild.className="";}; daymark++; } } return calTable; }
function fillEvents(m,y) { var keepData; for (tbls=document.getElementsByTagName('table'), tt=0; tt<tbls.length; tt++) { if (tbls[tt].className=='bordercolor' && tbls[tt].innerHTML.match(/\[calendar data\](.*?)\[\/calendar data\]/) ) { for (fnts=tbls[tt].getElementsByTagName('font'), ff=0; ff<fnts.length; ff++) { if (fnts[ff].innerHTML.match(/\[calendar data\](.*?)\[\/calendar data\]/) ) { keepData=fnts[ff]; break; } } break; } } var postNum=keepData.parentNode.parentNode.parentNode.parentNode.parentNode.previousSibling.firstChild; keepData=keepData.innerHTML.match(/\[calendar data\](.*?)\[\/calendar data\]/) ? RegExp.$1 : ''; postNum.id='postNum'; while (keepData.match(/\[calEntry\](.*?)\[\/calEntry\]/)) { var entryStuff=RegExp.$1.split(','); if (entryStuff[0]==m && (entryStuff[2]==y || entryStuff[2]=='repeat')) { var nwlnk=(entryStuff[4].match(/http:\/\//) ? document.createElement('a') : document.createElement('font')); nwlnk.innerHTML=entryStuff[3]; nwlnk.className='event'; nwlnk.nodeName=='A' ? nwlnk.href=entryStuff[4] : nwlnk.title=entryStuff[4]; if (document.getElementById('calTable_'+entryStuff[1]).firstChild.nextSibling.rows[0].cells[0].firstChild) { document.getElementById('calTable_' + entryStuff[1]).firstChild.nextSibling.rows[0].cells[0].appendChild( document.createElement('br')); } document.getElementById('calTable_'+entryStuff[1]).firstChild.nextSibling.rows[0].cells[0].appendChild(nwlnk); if (modkeeper) document.getElementById('calTable_'+entryStuff[1]).firstChild.title="click to add event, or change current ones"; } keepData=keepData.replace(/\[calEntry\](.*?)\[\/calEntry\]/,'') } }
function updateCal(m,y) { document.getElementById('calSpot').replaceChild(createCalendar(m,y), document.getElementById('calSpot').firstChild); fillEvents(m,y); }
function addEntry() { //add new entry to calendar var dropdwn=document.postForm.cal_prevEvent; if (dropdwn && dropdwn.value) delEntry(); //check if modifying and delete existing
if (document.postForm.message.value=='') { //member posting a submission
var nwEntry='[sub_calEntry]'+ postForm.cal_entryMonth.value +','+ postForm.cal_entryDay.value +','+ (postForm.cal_repeatYear.checked ? 'repeat' : postForm.cal_entryYear.value) +','; var nwEntryTitle= (document.getElementById('cal_entry_color').value ? '[color=' + document.getElementById('cal_entry_color').value + ']' + postForm.cal_entryTitle.value + '[/color]' : postForm.cal_entryTitle.value); nwEntry+= nwEntryTitle + ',' + postForm.cal_entryData.value +'[/sub_calEntry]'; document.postForm.message.value = nwEntry;
} else { //moderator adding/modifying
var rawData= document.postForm.message.value= document.postForm.message.value.replace(/\n/g,''); var innards= (rawData.match(/\[calendar data\](.*?)\[\/calendar data\]/m) ? RegExp.$1 : 'error'); if (innards!='error') { var nwEntry='[calEntry]'+ postForm.cal_entryMonth.value +','+ postForm.cal_entryDay.value +','+ (postForm.cal_repeatYear.checked ? 'repeat' : postForm.cal_entryYear.value) +','; var nwEntryTitle= (document.getElementById('cal_entry_color').value ? '[color=' + document.getElementById('cal_entry_color').value + ']' + postForm.cal_entryTitle.value + '[/color]' : postForm.cal_entryTitle.value); nwEntry+= nwEntryTitle + ',' + postForm.cal_entryData.value +'[/calEntry]';
innards+='\n'+nwEntry; innards=innards.replace(/\]\[/g,']\n['); document.postForm.message.value = '[calendar data]'+innards+'[/calendar data]';
} } }
function delEntry() { //delete existing event based on dropdown data store var rawData= document.postForm.message.value= document.postForm.message.value.replace(/\n/g,''); var innards= (rawData.match(/\[calendar data\](.*?)\[\/calendar data\]/m) ? RegExp.$1 : 'error'); var dropdwn=document.postForm.cal_prevEvent; var chkPrev=dropdwn.options[dropdwn.selectedIndex].id.split('cal_Event')[1]; if (innards!='error') { var evcount=0, nwinnards=''; while (innards.match(/\[calEntry\](.*?)\[\/calEntry\]/)) { if (evcount!=chkPrev) nwinnards+='[calEntry]'+RegExp.$1+'[/calEntry]'; innards=innards.replace(/\[calEntry\](.*?)\[\/calEntry\]/,''); evcount++; } innards+='\n'+nwinnards.replace(/\]\[/g,']\n['); document.postForm.message.value = '[calendar data]'+innards+'[/calendar data]'; } }
function createNewEntry(m,d,y,pn) { //parse post detail for modify post editor var postNum=(pn ? pn : document.getElementById('postNum').name); var threadPart=(location.href.match(/thread=(\d+?)($|&)/) ? RegExp.$1 : 'error'); var boardPart=(location.href.match(/board=(.*?)&/) ? RegExp.$1 : 'error'); if (modkeeper || allowRegularMembersToAddEvents ) { location.href='/index.cgi?board='+ boardPart +'&action='+(modkeeper ? 'modify' : '')+ 'post&thread='+ threadPart +(modkeeper ? '&post='+ postNum : '') +'&CalEntry_'+ m +'_'+ d +'_' + y + '_' +(modkeeper ? 1 : 0); } }
if (document.postForm && location.href.match(/newCalCreate/)) { var curRow=postForm.subject.parentNode.parentNode; curRow.previousSibling.getElementsByTagName('b')[0].innerHTML="Add New Calendar"; curRow.cells[0].firstChild.innerHTML="Calendar Name:"; curRow=curRow.nextSibling; while (curRow.nextSibling) {curRow.style.display="none"; curRow=curRow.nextSibling;} var btns=curRow.getElementsByTagName('input'); curRow.cells[0].firstChild.style.display='none'; var nwbtn=document.createElement('input'); nwbtn.type='button'; nwbtn.value="Cancel"; var goback=(location.href.match(/board=(.*?)($|&)/) ? '/index.cgi?board='+RegExp.$1 : '/index.cgi?'); nwbtn.onclick=function(){location.href=goback;}; btns[1].value="Create"; btns[2].style.display=btns[3].style.display=btns[4].style.display="none"; btns[1].parentNode.insertBefore(nwbtn, btns[1].nextSibling); btns[1].parentNode.insertBefore(document.createTextNode(' '), btns[1].nextSibling); postForm.message.value='[calendar data]\n[/calendar data]'; }
if (document.postForm && location.href.match(/CalEntry_(\d+?)_(\d+?)_(.*?)_(\d)$/)) { var monthKeep=RegExp.$1; var dayKeep=RegExp.$2; var yearKeep=RegExp.$3; modkeeper=RegExp.$4; var curRow=postForm.subject.parentNode.parentNode; curRow.previousSibling.getElementsByTagName('b')[0].innerHTML="Add Event To Calendar"; while (curRow.nextSibling) {curRow.style.display="none"; curRow=curRow.nextSibling;} var btns=curRow.getElementsByTagName('input'); curRow.cells[0].firstChild.style.display='none'; var nwdelbtn=document.createElement('input'); nwdelbtn.type='button'; nwdelbtn.value="Delete"; nwdelbtn.id='delbtn'; nwdelbtn.style.display="none"; nwdelbtn.onclick=function(){delEntry(); postForm.submit();}; var nwaddbtn=document.createElement('input'); nwaddbtn.type='button'; nwaddbtn.value="Add"; nwaddbtn.id='addbtn'; nwaddbtn.onclick=function(){addEntry(); postForm.submit();}; btns[1].value="Cancel"; btns[2].style.display=btns[3].style.display=btns[4].style.display="none"; btns[1].parentNode.insertBefore(document.createTextNode(' '), btns[1]); btns[1].parentNode.insertBefore(nwaddbtn, btns[1]); btns[1].parentNode.insertBefore(document.createTextNode(' '), nwaddbtn); btns[1].parentNode.insertBefore(nwdelbtn, nwaddbtn); for (tds=document.getElementsByTagName('td'), tt=0; tt<tds.length; tt++) { if (tds[tt].className=='titlebg' && tds[tt].width=='100%' && tds[tt].innerHTML.match(/Topic Summary/)) { var topictable=tds[tt].parentNode.parentNode.parentNode.parentNode; topictable=topictable.parentNode.parentNode.parentNode; topictable.style.display='none'; break; } } // create Entry form var nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Entry Data</font>'; nwrw.cells[1].innerHTML='<input name="cal_entryData" size=50 value="URL for link or description for Text" onclick="if (this.value.match(/(URL for link or description|Entry description)/i)) this.value=\'\'; ">'; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Type of Entry</font>'; nwrw.cells[1].innerHTML='<input name="cal_entryType" type="radio" onclick="document.postForm.cal_entryData.value=\'http://\'"> Link <input name="cal_entryType" type="radio" onclick="document.postForm.cal_entryData.value=\'Entry description\'"> Text'; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Year</font>'; var defaultYear=(new Date()).getFullYear(); nwrw.cells[1].innerHTML='<input name="cal_entryYear" size=10 value='+(yearKeep=='repeat' ? defaultYear : yearKeep)+'> repeat every year <input name="cal_repeatYear" type="checkbox" onclick="postForm.cal_entryYear.disabled=this.checked; postForm.cal_entryYear.style.backgroundColor=(this.checked ? \'#444444\' : \'#FFFFFF\');">'; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; if (yearKeep=='repeat') postForm.cal_repeatYear.click(); nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Month & Day</font>'; var tmpMonthSelect=''; for (mm=0; mm<monthLabels.length; mm++) { tmpMonthSelect+='<option value='+mm+'>'+monthLabels[mm]+'</option>'; } nwrw.cells[1].innerHTML='Month: <select name="cal_entryMonth">'+tmpMonthSelect+'</select> Day: <input name="cal_entryDay" size=10 value='+dayKeep+'>'; postForm.cal_entryMonth.selectedIndex=monthKeep; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Title of Entry</font>'; nwrw.cells[1].innerHTML='<input name="cal_entryTitle" size=50>'; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; var colordrop=document.postForm.color.cloneNode(true); for (cdo=colordrop.options, cd=0; cd<cdo.length; cd++) {cdo[cd].value=cdo[cd].innerHTML;}; cdo[0].value=''; colordrop.removeAttribute('onchange'); colordrop.id="cal_entry_color"; nwrw.cells[1].appendChild(colordrop); //check for that days entries and make a drop down var rawData= document.postForm.message.value= document.postForm.message.value.replace(/\n/g,''); var innards= (rawData.match(/\[calendar data\](.*?)\[\/calendar data\]/m) ? RegExp.$1 : 'error'); if (innards!='error' && modkeeper && !document.cookie.match(/keepCalendarSubmission=(.*?)(;|$)/)) { var nwsel='<select name="cal_prevEvent" onchange="postForm.cal_entryTitle.value=(this.options[this.selectedIndex].innerHTML ? this.options[this.selectedIndex].innerHTML : \'New Event\'); if (this.options[this.selectedIndex].getAttribute(\'color\')) { document.getElementById(\'cal_entry_color\').selectedIndex = this.options[this.selectedIndex].getAttribute(\'color\');} else {document.getElementById(\'cal_entry_color\').selectedIndex =0}; if (postForm.cal_repeatYear.checked !=(this.options[this.selectedIndex].className==\'repeat\')) postForm.cal_repeatYear.click(); postForm.cal_entryData.value=this.value; if (this.value) {document.getElementById(\'addbtn\').value=\'Modify\'; document.getElementById(\'delbtn\').style.display=\'\';} else { document.getElementById(\'delbtn\').style.display=\'none\'; document.getElementById(\'addbtn\').value=\'Add\';}"><option value=""></option>'; var optlist='', optcount=0; while (innards.match(/\[calEntry\](.*?)\[\/calEntry\]/)) { //fill drop down var entryStuff=RegExp.$1.split(','); var colorsave=(entryStuff[3].match(/\[color=(.*?)\]/) ? RegExp.$1 : ''); if (colorsave) { for (colorcheck=document.getElementById('cal_entry_color').options, cc=0; cc<colorcheck.length; cc++) { if (colorsave == colorcheck[cc].value) { colorsave=cc; break; } } } if (entryStuff[0]==monthKeep && (entryStuff[2]==yearKeep || entryStuff[2]=='repeat') && entryStuff[1]==dayKeep) { optlist+='<option id="cal_Event'+optcount+'" value="'+ entryStuff[4] +'" class="'+ entryStuff[2] +'" ' + (colorsave ? 'color="' + colorsave + '"' : '') + '>'+ entryStuff[3].replace(/\[\/?color(=(.*?))?\]/g,'') +'</option>'; } innards=innards.replace(/\[calEntry\](.*?)\[\/calEntry\]/,''); optcount++; } if (optlist) { //insert drop down if previous events exist nwsel+=optlist+'</select>'; nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.insertCell(0); nwrw.cells[0].innerHTML='<font size=2>Previous Events Found:</font>'; nwrw.cells[1].innerHTML=nwsel; nwrw.cells[0].align='center'; nwrw.cells[1].align='left'; nwrw.cells[0].className=nwrw.cells[1].className='windowbg'; } } if (modkeeper==0) { nwrw= curRow.parentNode.parentNode.insertRow(1); nwrw.insertCell(0); nwrw.cells[0].colSpan=2; nwrw.cells[0].innerHTML='<font size=3>'+approveMsg+'</font>'; nwrw.cells[0].align='center'; nwrw.cells[0].className='windowbg2'; } if (document.cookie.match(/keepCalendarSubmission=(.*?)(;|$)/)) { var entryData=unescape(RegExp.$1).split(','); var exptime=new Date(); exptime.setFullYear(exptime.getFullYear()-1); document.cookie='keepCalendarSubmission=""; expires='+exptime; document.postForm.cal_entryTitle.value=entryData[3]; document.postForm.cal_entryData.value=entryData[4]; } }
var modkeeper, delkeeper; if (pb_action=='display') { //if we are returning from accepting a submission, go to the modifypost page if (document.cookie.match(/keepCalendarSubmission=(.*?)(;|$)/)) { modkeeper=true; var savedEntry=unescape(RegExp.$1).split(','); createNewEntry(savedEntry[0],savedEntry[1],savedEntry[2],savedEntry[5]); }
//get calendar for this month var curDate=new Date; var curMonth=curDate.getMonth(), curYear=curDate.getFullYear(); if (location.href.match(/month=(\d+)&year=(\d+)(&|$)/)) { curMonth=RegExp.$1 - 1; curYear=RegExp.$2; //if URL wants a specific month/year } var keepOPpost; nwdv=document.createElement('center'); nwdv.className='calDiv'; nwdv.id='calSpot'; //remove post display for (psts=document.getElementsByTagName('td'), pp=0; pp<psts.length; pp++) { if (psts[pp].className.match(/windowbg/) && psts[pp].width=='80%' && psts[pp].vAlign=='top' && psts[pp].innerHTML.match(/\[calendar data\](.*?)\[\/calendar data\]/) ) { keepOPpost=psts[pp].previousSibling.getElementsByTagName('a')[0].name; var grandtable=psts[pp].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; grandtable.parentNode.insertBefore(nwdv, grandtable.nextSibling); grandtable.style.display = "none"; for (lnks=psts[pp].getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { if (lnks[ll].href.match(/action=modifypost/)) { modkeeper=lnks[ll]; break; } } for (lnks=grandtable.getElementsByTagName('a'), ll=lnks.length-1; ll>0; ll--) { if (lnks[ll].href.match(/action=removethread/)) { delkeeper=lnks[ll]; break; } } break; } } nwdv.appendChild(createCalendar(curMonth, curYear)); // remove Quick Reply if it is there for (tds=document.getElementsByTagName('td'), tt=tds.length-1; tt>0; tt--) { if (tds[tt].className=='titlebg' && tds[tt].width=='100%' && tds[tt].innerHTML.match(/Quick Reply/)) { QRtable=tds[tt].parentNode.parentNode.parentNode; QRtable=QRtable.parentNode.parentNode.parentNode.parentNode; QRtable.style.display='none'; while (QRtable.previousSibling && QRtable.previousSibling.nodeName=='BR') { QRtable.previousSibling.style.display='none'; QRtable=QRtable.previousSibling; } break; } } // add housekeeping button var allowedHousekeepers=new RegExp('^('+usersAllowedHousekeep+')$',''); if (modkeeper && pb_username.match(allowedHousekeepers)) { var hkbtn=document.createElement('img'); hkbtn.src=housekeepingBtn; hkbtn.style.cursor='pointer'; hkbtn.onclick=function() {location.href=modkeeper.href;} fjCell=document.getElementById('forumjump').parentNode; fjCell.parentNode.insertCell(0); fjCell.parentNode.cells[0].align="left"; fjCell.parentNode.cells[0].appendChild(hkbtn); } // add delete calendar button var allowedDeleters=new RegExp('^('+usersAllowedDeleteCal+')$',''); if (delkeeper && pb_username.match(allowedDeleters)) { delkeeper.href=delkeeper.href.replace(/thread/i,'calendar'); var dlbtn=document.createElement('img'); dlbtn.src=deleteCalBtn; dlbtn.style.cursor='pointer'; dlbtn.onclick=function() {location.href=delkeeper.href;} fjCell=document.getElementById('forumjump').parentNode; if (fjCell.parentNode.cells>1) fjCell.parentNode.insertCell(0); fjCell.parentNode.cells[0].align="left"; fjCell.parentNode.cells[0].appendChild(dlbtn); } fillEvents(curMonth, curYear); //check for submissions by regular members and deal with them //the only way I can do this is with cookies if (modkeeper) { for (psts=document.getElementsByTagName('td'), pp=0; pp<psts.length; pp++) { if (psts[pp].className.match(/windowbg/) && psts[pp].width=='80%' && psts[pp].vAlign=='top' && psts[pp].innerHTML.match(/\[sub_calEntry\](.*?)\[\/sub_calEntry\]/) ) { var alertdiv=document.createElement('center'); alertdiv.className='alertmsg'; alertdiv.innerHTML="There are pending submissions from members - click here"; alertdiv.style.cursor='pointer'; alertdiv.onclick=function() {getSubmit(keepOPpost);}; nwdv.parentNode.insertBefore(alertdiv, nwdv); break; } } } }
function getSubmit(OPpost) { for (psts=document.getElementsByTagName('td'), pp=0; pp<psts.length; pp++) { if (psts[pp].className.match(/windowbg/) && psts[pp].width=='80%' && psts[pp].vAlign=='top' && psts[pp].innerHTML.match(/\[sub_calEntry\](.*?)\[\/sub_calEntry\]/) ) { var sub_entry=RegExp.$1; var submitter=psts[pp].previousSibling.getElementsByTagName('b')[0]; var submitter_uname=submitter.firstChild.href.match(/user=(.*?)$/) ? RegExp.$1 : ''; var submitter_name=(submitter ? submitter.firstChild.innerHTML+' ('+ submitter_uname +')' : 'Guest') var submitpostnum=psts[pp].previousSibling.getElementsByTagName('a')[0].name; sub_entry+=','+OPpost; var sub_entry_title=sub_entry.split(',')[3]; var sub_entry_month=monthLabels[sub_entry.split(',')[0]]; var sub_entry_day=sub_entry.split(',')[1]; var sub_entry_year=sub_entry.split(',')[2]; var sub_entry_data=sub_entry.split(',')[4]; var sub_entry2='Title: '+ sub_entry_title +'\ndate: '+ sub_entry_month +' '+ sub_entry_day +' '+ sub_entry_year +'\ndata: '+ sub_entry_data; var result=confirm('Submission from '+submitter_name+'\n\n'+sub_entry2+'\n\n Keep it? (cancel=no)'); break; } } var del_entry=location.href.replace(/action=display/,'action=deletepost')+'&post='+submitpostnum if (result) { document.cookie="keepCalendarSubmission="+escape(sub_entry); } location.href=del_entry; }
if (pb_action=='boardindex') { if (document.cookie.match(/keepCalendarSubmission=(.*?)(;|$)/)) { var exptime=new Date(); exptime.setFullYear(exptime.getFullYear()-1); document.cookie='keepCalendarSubmission=""; expires='+exptime; } for (lnks=document.getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { if (lnks[ll].href.match(/action=post/) && !lnks[ll].href.match(/newCalCreate/)) { //change new thread to new calendar var thebutton=(allowThreads ? lnks[ll].cloneNode(true) : lnks[ll]); thebutton.href+='&newCalCreate'; if (thebutton.firstChild.nodeName=='IMG') { thebutton.firstChild.src=nwcalBtnImg; } else { thebutton.innerHTML='[New Calendar]'; } if (allowThreads) lnks[ll].parentNode.appendChild(thebutton); } if (lnks[ll].href.match(/action=display/)) { //get rid of title hover lnks[ll].parentNode.parentNode.parentNode.title=''; } if (lnks[ll].href.match(/action=createpoll/)) lnks[ll].style.display="none"; } }
// --> </script>
|
|
|
Post by Wormopolis on Mar 31, 2011 10:25:41 GMT -8
version update 1.21: bug fix that changing months introduced when current month had more days then previous or next month had.
|
|
|
Post by Wormopolis on Sept 23, 2012 22:40:54 GMT -8
|
|