Page 1 of 1

Page views, gallery, image count for morphed profile page

PostPosted: Sat Jun 02, 2007 6:17 pm
by srijith
Do not use this 'hack' unless stated otherwise at a later stage more details...


For people who have morphed their profile page (eg: mine), a problem used to be the inability to present the current image views, gallery count and image counts due to its dynamic nature.

Fret not :) Using the following Javascript code will get the work done. Note that this works with non-IE browsers only. See below how to handle IE.

Code: Select all
function getElementsByAttribute(attr,val,container)
{
        container = container||document
        var all = document.getElementsByTagName('*')
        var arr = []
        for(var k=0;k<all.length;k++)
        if(all[k].getAttribute(attr) == val)
        arr[arr.length] = all[k]
        return arr
}

function showTotal() {

        if (getElementsByAttribute("class","wb","document")[6].childNodes[5].firstChild.nodeValue) {
                views=getElementsByAttribute("class","wb","document")[6].childNodes[5].firstChild.nodeValue;
                temp=getElementsByAttribute("class","wb","document")[6].childNodes[2].nodeValue;
                galleriesImages = temp.split(' ');
                galleries=galleriesImages[6];
                images=galleriesImages[9];
                document.getElementById('totalview').firstChild.nodeValue=views;
                document.getElementById('totalgalleries').firstChild.nodeValue=galleries;
                document.getElementById('totalimages').firstChild.nodeValue=images;
        }
        else alert('Your browser doesn\'t support the Level 1 DOM');

}



Use it as follows in HTML of profile:

Code: Select all
<!--[if !IE]>--><script type="text/javascript" src="http://host.com/location/profile.js" /><!--<![endif]-->
Over <b id="totalview">rough_no_for_IE</b> views
Galleries:<b id="totalgalleries">rough_no_for_IE</b>
Images:<b id="totalimages">rough_no_for_IE</b>
<!--[if !IE]>--><body onload="showTotal()"><!--<![endif]-->


rought_no_for_IE has to be substituted for a rough number that will be shown to IE users. Firefox and Opera users will see the correct dynamic numbers.

Of course you need to save the Javascript as profile.js and change the location of host.com in the html above. Note that the details you get when you logged in as yourself may looked messed up, but for anyone else (other pbase users and non-logged in visitors) it will display correctly.

Code released under GPL 2.0

PostPosted: Sun Jun 03, 2007 1:38 am
by arjunrc
Good stuff srijith. this certainly helps with the dynamic information part.
You may want to check it in IE7 - the current script locks in "calculating" phase on your profile and only half the profile page shows up as a result.

PostPosted: Sun Jun 03, 2007 6:25 am
by srijith
arjunrc wrote:Good stuff srijith. this certainly helps with the dynamic information part.
You may want to check it in IE7 - the current script locks in "calculating" phase on your profile and only half the profile page shows up as a result.

Thanks for catching that Arjun. I hardly use IE these days and hence forgot that it exists :)

Well, due to the trick I use (to do you know what), looks like IE will not work well. So instead, let us put a rough enough number for IE instead of 'calculating' and warp the 'offending' part in 'IF'. Have updated the original entry to reflect the changes needed.

PostPosted: Sun Jun 03, 2007 6:51 am
by srijith
If you want it working correctly for yourself also, play with if else statement using value in galleriesImages[5] and change numbers in
Code: Select all

galleries=galleriesImages[6];
images=galleriesImages[9];

How?

PostPosted: Sun Oct 14, 2007 5:55 pm
by gaild
Is it easy to design a profile page like yours... or only for the experts (which I am not!)?

Thanks
Gail

PostPosted: Wed Oct 17, 2007 5:48 pm
by lumbardh
Yeah, how did you do that? I like the look!

PostPosted: Mon Oct 22, 2007 3:31 pm
by srijith
Sorry for the late reply. The trick to morph the profile page is easy. I could share it with you if you send me a private forum PM.

However, you still need to design your own HTML to make it look the way you want it. After applying the trick you will be left with an empty page which you can edit like any other normal HTML page.

PostPosted: Fri Nov 23, 2007 10:12 am
by srijith
Upcoming Firefox 3 is more strict regarding javascript tag syntax and that combined with PBase policy of stripping all Javascripts will leave this script useless and will mess up the profile page.

Please discontinue its use until stated otherwise at a later stage.