Selectors for various FM pages..
Posted February 15th 2012, 1:49pm
the topic is started to address the need for having specific javascripts for specific pages on FM, from this I mean that provided we can't edit templates the javascript is to somehow check whether this is the page that the function is to ne initiated or not....
I therefore request to some provide me with js selectors to know which pages user currently is visiting...

1] User profile Pages
if (document.URL.indexOf('/u') != -1) {....}


2] Topic pages (no need default functionality provided by FM)

3] PM pages
if (document.URL.indexOf('/privmsg') != -1) {....}


4] New Topic & Post reply pages
the above pages I need assisstance because the url changes for mode=newtopic or mode=postreply to /post when user presses preview button :(

5] After replying to post or posting newtopic
    var x = $('.page-title').text();
if (x.length == 12) {.....} //the above code references this:
<h1 class="page-title">Post a reply</h1>



comments plz;;
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
1
#2
Selectors for various FM pages..
Posted February 15th 2012, 2:31pm
My answers apply to phpBB3 and IPB2/Invision boards. In many cases, it's simpler and faster to look for IDs that are unique to that page. Here are two examples. On pages where lists of topics are displayed, you can use this:

if (document.getElementById('info_open')) {...}

On pages with the eToxic "full" editor:

if (document.getElementById('px')) {...}
φ
Posts: 1551
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 354
Selectors for various FM pages..
Posted February 15th 2012, 2:41pm
Provided that you have given me a check for Full editor this makes no differentiation among postreply/newtopic/privmsg. Can you provide a way to differentiate b/w these. Thnx for your much needed response
φ
Posts: 163
Joined: August 5th 2011, 11:00pm
Location: Pakistan
Likes Given: 34
Likes Received: 3
Selectors for various FM pages..
Posted February 15th 2012, 4:54pm
The following would tell you if you're on a PM compose/reply page:

if (document.getElementById('px') && document.getElementById('find_user')) {...}

Once you select out that page, you can check the URL to select out the signature compose/edit page. What's left would be the post reply/edit/quote/newtopic pages, and I see no importantce whatsoever in selecting between those pages. If you do, use the URL to select between the three.
φ
Posts: 1551
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 354

Who is online

Users browsing this forum: No registered users and 1 guest