|
Post by Wormopolis on Jan 11, 2010 2:11:28 GMT -8
browser tested: IE and FF placement: global footer
Adds an encrypted string into custom title that stores the start date and the amount to reduce each day. will update the actual warning level if a staff member modifies the profile. when reduction reaches 0, puts a "clear warning" button for specific users (everyone else just sees the warning cleared).
Your forum must have warning levels turned on and displayed.
<script type="text/javascript"> <!-- // auto-reducing warning bar v1.1 // by Wormopolis - www.wormocodes.com // concept by Topeka // Keep header intact - do not repost
var usersWhoCanClearWarnings=/admin|wormo|user3|user4/;
for (tds=document.getElementsByTagName('td'), w=0; w<tds.length; w++) { if (tds[w].width=='20%' && tds[w].className.match(/windowbg/) && tds[w].innerHTML.match(/Warning Level - (\d+)%/)) { stPerc=RegExp.$1; if (tds[w].innerHTML.match(/\[Ø(.*?):(\d+)\]/)) { stDate=RegExp.$1; decVal=RegExp.$2; tds[w].innerHTML=tds[w].innerHTML.replace(/\[Ø(.*?):(\d+)\]/,''); stDate=(parseInt(stDate,36)).toString(); tmpDate1=new Date(); tmpDate1.setFullYear(stDate.substr(0,4)); tmpDate1.setMonth(stDate.substr(4,2)); tmpDate1.setDate(stDate.substr(6,2)); tmpDate1.setHours(0); tmpDate1.setSeconds(0); tmpDate1.setMinutes(0); tmpDate2=new Date(); tmpDate2.setHours(0); tmpDate2.setSeconds(0); tmpDate2.setMinutes(0); dayStretch=parseInt((tmpDate2-tmpDate1)/(1000*60*60*24)); // bar width is 1.1 pixels x perc subPerc=stPerc-(dayStretch*decVal); for (pic=tds[w].getElementsByTagName('img'), p=0; p<pic.length; p++) { if (pic[p].src.match(/warn_left.gif/)) { midbar=pic[p].nextSibling; textSave=pic[p].previousSibling.previousSibling; if (subPerc>0) { midbar.width=subPerc*1.1; textSave.nodeValue=textSave.nodeValue.replace(/(\d+)%/,subPerc+'%'); } else { if (pb_username.match(usersWhoCanClearWarnings)) { tmp=tds[w].getElementsByTagName('b')[0].firstChild.href.split('user=')[1]; nwDiv=document.createElement('div'); nwDiv.width="100%"; fntstuff='<center><font style="background-color:CC0000; color:FFFFFF; font-size:14px; cursor:pointer;" onclick="location.href=\'/index.cgi?action=modifyprofile&user='+tmp+'&banclear\'" > CLEAR WARNING </font></center>' nwDiv.innerHTML=fntstuff; midbar.previousSibling.style.display= midbar.style.display= midbar.nextSibling.style.display="none"; textSave.nodeValue=""; textSave.parentNode.insertBefore(nwDiv, textSave); } else { midbar.previousSibling.style.display= midbar.style.display= midbar.nextSibling.style.display="none"; textSave.nodeValue=""; textSave.previousSibling.style.display= textSave.nextSibling.style.display ="none"; } } break; } } } } }
function setupWarnDec() { if (modifyForm.warnDec.checked==true && modifyForm.decVal.value>0) { dt=new Date; dt.setHours(0); dt.setMinutes(0); dt.setSeconds(0); timetemp=dt.getFullYear().toString() + '' + (dt.getMonth().toString().length<2 ? '0' : '') + dt.getMonth().toString() + '' + (dt.getDate().toString().length<2 ? '0' : '') + dt.getDate().toString(); wdstring=parseInt(timetemp).toString(36); modifyForm.customtitle.value='[Ø'+wdstring+':'+modifyForm.decVal.value+']'+modifyForm.customtitle.value; } }
if (document.modifyForm) { if (location.href.match(/banclear/)) { modifyForm.warninglevel.value=0; modifyForm.customtitle.value=modifyForm.customtitle.value.replace(/\[Ø(.*?):(\d+)\]/,''); alert("User's Ban has been cleared!"); modifyForm.submit(); } else { if (modifyForm.warninglevel) { wlrow=modifyForm.warninglevel.parentNode.parentNode.parentNode; nwrw=wlrow.parentNode.insertRow(wlrow.rowIndex+1); nwrw.insertCell(0);nwrw.insertCell(0);nwrw.insertCell(0); nwrw.cells[1].align="center"; tmp=document.createElement('font'); tmp.innerHTML='<input type="checkbox" name="warnDec"> <input size=5 name="decVal" value="0">%'; nwrw.cells[1].appendChild(tmp); tmp=document.createElement('font'); tmp.innerHTML=' decrease percentage each day. auto-decrement will start from midnight.'; nwrw.cells[2].appendChild(tmp); if (modifyForm.customtitle.value.match(/\[Ø(.*?):(\d+)\]/)) { stPerc=modifyForm.warninglevel.value; stDate=RegExp.$1; decVal=RegExp.$2; modifyForm.customtitle.value=modifyForm.customtitle.value.replace(/\[Ø(.*?):(\d+)\]/,''); stDate=(parseInt(stDate,36)).toString(); tmpDate1=new Date(); tmpDate1.setFullYear(stDate.substr(0,4)); tmpDate1.setMonth(stDate.substr(4,2)); tmpDate1.setDate(stDate.substr(6,2)); tmpDate1.setHours(0); tmpDate1.setSeconds(0); tmpDate1.setMinutes(0); tmpDate2=new Date(); tmpDate2.setHours(0); tmpDate2.setSeconds(0); tmpDate2.setMinutes(0); dayStretch=parseInt((tmpDate2-tmpDate1)/(1000*60*60*24)); // bar width is 1.1 pixels x perc subPerc=stPerc-(dayStretch*decVal); modifyForm.warninglevel.value=(subPerc < 0 ? 0 : subPerc); if (subPerc > 0) { modifyForm.warnDec.checked=true; modifyForm.decVal.value=decVal; } }
if (document.addEventListener) { document.modifyForm.addEventListener("submit", setupWarnDec , false); } else { document.modifyForm.attachEvent("onsubmit", setupWarnDec); }
} } }
// --> </script>
preview: using it on this site, but you wont see anything different
|
|
Nightwalker
Full Member
Everything Happens at Night
Posts: 138
Nightwalker said 0 great things
|
Post by Nightwalker on Jul 2, 2010 16:17:03 GMT -8
|
|
|
Post by Wormopolis on Jul 2, 2010 20:19:00 GMT -8
The new warning system accessible through the report post feature doesnt have access to the custom title field on that page itself. you can set a warning, but you would still need to go to that user's profile and add in the decrement value afterwards. putting something in there that redirected to the modifyprofile would mostlikely get this code put on the TOS offender list. Craig said there might be future accessibility to something like that, so I am waiting to see what they come up with.
|
|
Nightwalker
Full Member
Everything Happens at Night
Posts: 138
Nightwalker said 0 great things
|
Post by Nightwalker on Jul 3, 2010 16:33:32 GMT -8
ok thanks...i guess i just can't use the code
|
|
|
Post by Wormopolis on Jul 3, 2010 21:50:30 GMT -8
or you could just go to the user's profile after issuing the warning and put in the decrement there...
|
|
Nightwalker
Full Member
Everything Happens at Night
Posts: 138
Nightwalker said 0 great things
|
Post by Nightwalker on Jul 4, 2010 4:31:03 GMT -8
i could...
|
|
Nightwalker
Full Member
Everything Happens at Night
Posts: 138
Nightwalker said 0 great things
|
Post by Nightwalker on Feb 6, 2013 19:46:50 GMT -8
Hey, how can you get the code to work removing the warning by less than 1% a day. Setting it to 0.1% or .1% doesn't seem to work...
|
|