We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
IF JavaScript Library; What do you think?
Topic Started: Mar 21 2011, 06:32 PM (596 Views)
Fable.
Member Avatar
Member
[ *  * ]
I started to post a bit about this idea, to have an IF Library, a group of methods to make the life of the IF coder a little easier.

Is this something that interests you? Is this something you would contribute towards?
Ideally it would be a community project that people can add to/improve/debug etc.

Here is a couple of methods I stuck together:
Hosted version
Code:
 
/*
* InvisionFree Library v1.0
* This library aims to help IF mod developers by
* defining some commonly used functions.
*/

var iflib = {

/*
* Returns the logged in username or Guest
*/
getUsername: function(){
var link = document.getElementById("userlinks").getElementsByTagName("a");
if(link[0].innerHTML == "Log In"){
return "Guest";
} else {
return link[0].innerHTML;
}
}

/*
* Returns number of posts in the topic being viewed or 0
*/
numOfPosts: function(){
var span = document.getElementsByTagName("span");
var total = 0;
for(var x=0; x<span.length; x++){
if(span[x].className == "normalname"){
total ++;
}
}
return total;
}

/*
* Returns number of posts by a user in the topic being viewed or 0
*/
numOfPostsBy: function(user){
var span = document.getElementsByTagName("span");
var total = 0;
for(var x=0; x<span.length; x++){
if(span[x].className == "normalname" && span[x].innerHTML.match(user)){
total ++;
}
}
return total;
}

/*
* Returns true if the logged in user is the admin or false if not
*/
isAdmin: function(){
var bar = document.getElementById("userlinks");
if(bar.innerHTML.match(/admin cp/i)){
return true;
} else {
return false;
}
}

}
Offline Profile Quote Post Goto Top
 
Paper
Member Avatar
Member
[ *  *  *  *  *  * ]
This has been suggested many times, but never really done, and to this date it still remains a good idea. I think it should be integrated with the jQuery library.
Offline Profile Quote Post Goto Top
 
Zefer
Member Avatar
Member
[ *  * ]
It seems like a very good idea. I can imagine it would be possible to get people to contribute. I would.
Offline Profile Quote Post Goto Top
 
Fable.
Member Avatar
Member
[ *  * ]
Paper: Yeah, jQuery sounds like a good idea.

Well I'll keep thinking up some ideas and see where it leads. Feel free to add some methods to the existing code.
Offline Profile Quote Post Goto Top
 
Paper
Member Avatar
Member
[ *  *  *  *  *  * ]
I'm developing one or two codes ATM and actually I don't bother with jQuery. It's great but a real pain to debug as nothing ever throws any errors
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply