|
Post by rhondairv on Dec 8, 2010 17:22:30 GMT -8
thanks wormo!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
Post by Wormopolis on Aug 1, 2011 20:16:48 GMT -8
version update 1.12: added id='actBar' to div for fetching
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Aug 2, 2011 20:05:50 GMT -8
If there is more than one div on the page sharing the same exact ID then would that not defeat the original purpose of adding an ID? In cases like that the outcome is undefined, most browsers will grab the first element with the specified ID while others (older IE, Opera) will grab the last, in either case only one will be returned.
NAME instead of ID might be a better choice since getElementsByName can return a collection of elements but if memory serves IE's implementation of getElementsByName ignores NAME properties on divs. Another solution might be to use CLASS instead since getElementsByClassName is implemented by all modern browsers (even IE9, but not without a proper doctype) but there again older browsers throw a monkey wrench since they did not support this method.
A compromise might then be to add a incremented number to the end of that ID (e.g. "actBar1", actBar2", etc.) with codes wishing to grab the div using : while(actBar=document.getElementById('actBar'+inc++)) //process actBar here
|
|
|
Post by Wormopolis on Aug 2, 2011 22:06:33 GMT -8
yeah I wasnt thinking too well when I wrote that in. it was mainly to help sub get a MP remodel to find it.
I was going to change it to class after I saw sub comment on it. I also thought of just creating my own tag so that getElementsByTagName can still work on it.
|
|
|
Post by Wormopolis on Aug 2, 2011 22:08:28 GMT -8
version update 1.13: changed that id="actBar" to be className="actBar". can still be fetched and wont cause any errors looking for uniqueness.
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Aug 2, 2011 23:08:39 GMT -8
I also thought of just creating my own tag so that getElementsByTagName can still work on it. I'd stay away from that approach, there's a bug in IE's implementation where it will get one less that what is actually in the DOM when custom tagnames are involved. The className approach still leaves IE out in the cold, because although version 9 supports getElementsByClassName it won't support it on a proboards forum since proboards defines no doctype. That effectively leaves an IE code branch of having to cycle through every div looking for identifying properties, same way it would if nothing was changed, the incremented id approach or an id appended by the post's numeric id would have been more helpful. Those browsers that supported the getElementsByClassName would use that to grab by class and IE could use the cycled getElementById.
|
|
|
Post by Wormopolis on Aug 3, 2011 9:26:41 GMT -8
the mp remodel is already focusing on the mp cell, so doing a div search and checking its classname to see if its an activity bar shouldnt be too bad. there shouldnt be too many divs already inside a mp cell.
|
|
Bones
Code Helper
Posts: 131
Bones said 0 great things
|
Post by Bones on Aug 3, 2011 18:02:38 GMT -8
the mp remodel is already focusing on the mp cell, so doing a div search and checking its classname to see if its an activity bar shouldnt be too bad. there shouldnt be too many divs already inside a mp cell. Greater interoperability was I believe the goal, the change is fine for that specific code but I was looking for a change that would benefit any code, not just one with reference to the cell. A nice example would be the forum jump which never used to have an ID so any code wishing to grab it had to jump through loops, now with an ID quick and consistent access is available to any code.
|
|
|
Post by Wormopolis on Aug 3, 2011 20:25:50 GMT -8
oh I hear what you are saying. granting unique id's to each bar would be optimal.
|
|
|
Post by Wormopolis on Oct 15, 2011 19:35:29 GMT -8
version upgrade 1.14: small change for compatibility
|
|
crystal
Not New Member
Posts: 10
crystal said 0 great things
|
Post by crystal on Dec 18, 2011 6:17:14 GMT -8
I have a problem with the posting activity bar in windows 7 (but it works in HP). The bar is always at 0, and it's pretty big no matter the height i set. But checking the bar of this forum in windows 7, it works (though it's still a lot thicker). Any solution? I can give you the url of the forum or a copy of the text I have on the footer for this code. Thanks.
P.S. I'm also using a longevity bar, and it works though it's still too thick.
|
|
|
Post by Wormopolis on Dec 18, 2011 13:22:44 GMT -8
I dont have windows 7 to make a comparison, but I can look at the site and see if anything looks off.
|
|
crystal
Not New Member
Posts: 10
crystal said 0 great things
|
Post by crystal on Dec 18, 2011 13:38:45 GMT -8
mount-silver.proboards.com/index.cgiAnd this is the code i'm using: <script type="text/javascript"> <!-- // activity meter in MP // v 1.14 // by Wormopolis - www.wormocodes.com// keep header intact - do not repost var postsPerDay=0.5; // number of posts per day you consider very active function getColor(n) { red=parseInt(2.55*(100-n)); green=parseInt(2.55*(n)); return ((red<16?'0':'') + red.toString(16) + (green<16?'0':'') + green.toString(16) + '00'); } tstArray=['jan','feb','mar','apr','may','jun','jul','aug','sept','oct','nov','dec']; for (tds=document.getElementsByTagName('td'), t=0; t<tds.length; t++) { if (tds[t].width=='20%' && tds[t].className.match(/windowbg/) && tds[t].vAlign=='top' && tds[t].innerHTML.match(/posts: (.*?)<br>/i)) { pstcnt=parseInt(RegExp.$1.replace(/,/g,'')); datechk=tds[t].innerHTML.match(/joined: (.*?) (\d+)</i); datechkM=RegExp.$1; datechkY=RegExp.$2; for (m=0; m<tstArray.length; m++) { if (datechkM.toLowerCase()==tstArray[m]) break; } sDate=new Date(); sDate.setDate(1); sDate.setYear(datechkY); sDate.setMonth(m); cDate=new Date(); timeSpan=parseInt((cDate-sDate)/(1000*60*60*24)); ppd=pstcnt/timeSpan; ppdp=parseInt((ppd/postsPerDay)*100); notch=(ppdp>100 ? 100 : ppdp); for (br=tds[t].getElementsByTagName('br'), b=0; b<br.length; b++) { if (br .nextSibling && br.nextSibling.nodeName.match(/text/) && br.nextSibling.nodeValue.match(/posts:/i)) { spot=br.nextSibling.nextSibling; break; } } nwdv=document.createElement('div'); nwdv.className='actBar'; nwdv.title=pstcnt+" posts / "+timeSpan+ " days = "+ppd.toFixed(2)+" (active="+postsPerDay+")"; nwdv.width='100%'; nwdv.vAlign='middle'; nwdv.style.height=20; nwdv.align='center' hdr=nwdv.appendChild(document.createElement('font')); hdr.innerHTML='Posting Activity'; hdr.size=1; nwtbl=nwdv.appendChild(document.createElement('table')); nwtbl.cellSpacing=nwtbl.cellPadding=0; nwtbl.insertRow(0); for (i=0; i<=100; i++) { nwcl=nwtbl.rows[0].insertCell(-1); nwcl.style.width='1'; nwcl.style.height='20'; nwcl.vAlign='middle'; cdiv=nwcl.appendChild(document.createElement('div')); cdiv.style.width='1'; if (i==notch) { cdiv.style.height='15'; cdiv.style.backgroundColor='0040ff'; } else { cdiv.style.height='4'; test=getColor(i); cdiv.style.backgroundColor=getColor(i); } } spot.parentNode.insertBefore(nwdv,spot);
} } // --> </script>
|
|
|
Post by Wormopolis on Dec 18, 2011 15:12:19 GMT -8
do you know how to make a screenshot? I would like to see what you are seeing.
|
|
crystal
Not New Member
Posts: 10
crystal said 0 great things
|
Post by crystal on Dec 19, 2011 9:00:55 GMT -8
|
|