logo

Latest Shouts In The Shoutbox -- View The Shoutbox · Rules
chakka -- proboards?
Test -- GAH NEED MORE STUFF IN TEH STORE
Test -- ew proboards
Test -- http://adminnetwork.ipbfree.com its cool
GGG -- Hey

[ Smilies | BBCodes ]



Profile
Personal Photo

No Photo
Rep [details >>] 5 pts

Options
Custom Title
Administrator
Personal Info
Location: No Information
Born: No Information
Website: No Information
Interests
No Information
Other Information
Statistics
Joined: January 06, 2008
Status: (Offline)
Last Seen: September 11, 2009 11:13 pm
Local Time: No Information
102 posts (0.1 per day)
( 71.83% of total forum posts )
Contact Information
AIM No Information
Yahoo No Information
ICQ No Information
MSN No Information
SKYPE No Information
Unread Msg Message: Click here
Unread Msg Email: Click Here
Signature
View Signature

chakka

chakka

Topics
Posts
Comments
Friends
My Content
September 01, 2009 01:13 pm
A few people now have asked me whether using JQuery for a JFB modification code would be a good idea; my answer to this will always be yes however not many people do use it. Reasons vary but largely it's either because they don't know why they should use JQuery or simply don't know the language. So I thought I would write this little article-esque introduction tutorial, which I might add to with more project specific tutorials as and when I find the time.

Why should you use JQuery?

After all, it's just Javascript, right? No, not really. There are many benefits to JQuery over Javascript, first and foremost it's a whole lot easier to understand and write. It's also more light-weight so loads faster and is cross browser compatible so you don't have to worry about Internet Explorer all the time! It's great for animations, meaning Flash is relegated to the "last resort" pile as it should always have been, and there is a wealth of tutorials out there (like this one) as well as great documentation, unlike traditional javascript.

As far as Jcink Forum Boards are concerned though, the main reason to use JQuery is because of its selectors. Whereas in Javascript it's a struggle to select something based on class rather than ID and even harder then to filter them down (say you only want the first element with class of "maintitle" on a page) with JQuery it's a breeze and an awful lot faster to load as a result!

Do I need to know javascript first?

No, you really, really don't. All you should understand is that javascript is a client side script; it renders within the browser, normally after or whilst the HTML and CSS is rendering and it never touches the server. So you can't use JQuery (or javascript) to modify anything stored server side i.e. the PHP, MySQL, database entries etc. However anything client side - HTML, CSS, javacript itself - that can all be messed around with smile.gif

An Introduction

OK so you're interested in learning JQuery, where do you start? Well this topic is good for the basics but here's a list of much better written, more detailed or just plain awesome JQuery tutorials:
JQuery Docs - the official Documentation and site, full of really great information!
Learning JQuery - a great store of tutorials with some very clever techniques (how I learned smile.gif) In particular check out This article.
JQuery Tutorials (Official) - the official tutorials posted on the JQuery site.
Web Designer Wall - just generally worth a look, full of great tips, tricks and workshops.

If you have any more suggestions feel free to post below and I'll link them if I fell they're good enough smile.gif

The Set Up

First of all you need to install JQuery to your development environment. I would use this link:
CODE
http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js

And pop it into some <script> tags. I won't go into that level of detail, so if you don't know how to call an external .js file...well I would go look at any of the large codes for JFB wink.gif
The reason for that link is simple: it's hosted by Google, it isn't going anywhere, it's the latest version (as of the time of writing) of JQuery and because of all this it may already be cached by your viewers browser (big sites like Dell and even Google themselves link to this file) so further increasing page load times smile.gif

If you really want piece of mind feel free to upload the actual source file from JQuery.com and uploading it to your hosting or use IrisSC to link in JQuery that way smile.gif

The Basics

Now we have our environment setup we can start coding. Anything made using JQuery is Javascript, so you need to wrap it in the correct tags. To start, let's tell the browser we're using Javascript:
CODE
<script type="text/javascript">

</script>


OK well that's fine, the browser now knows that any code between those tags is Javascript and will render it accordingly. But how do we differentiate between regular vanilla Javascript and the new JQuery? Well, we use the dollar ($) symbol, like this:

CODE
<script type="text/javascript">
$(document).ready(function(){

});
</script>


At this point we need to explain what that all means. The <script> tags start Javascript rendering, the $ sign informs the browser to start JQuery rendering and the rest of the line simply tells the script to only execute once the whole page has loaded fully.

But before we look at that statement in more detail, it's best to understand that JQuery will nearly always take the form of the above being broken down like this:
QUOTE
$(document).ready(function(){

So that the blue is always a $ sign showing the start of a line of JQuery;
the red then tells the script what element is being manipulated. So here we're targeting the whole "document" i.e. everything in the web page made from HTML and CSS. You could just as easily target only <div> tags by using ("div"). Notice the "" quotation marks? You'll nearly always use them as they tell the script your targeting an HTML or CSS element i.e. a tag (div, td, span, a etc.) or a class/ID (.maintitle, .navbar, #submenu etc.). If you want to target a Javascript element, such as a variable or document, you don't need the "" quotation marks wink.gif;
the green is the process you want to apply to the red element. Here we check to see if the document is fully loaded i.e. ready, but you could give the element a class with .addClass() or make it disappear with .hide(). Normally, as you can see, the green part will end with a closing bracket;
the purple part is always contained within these brackets following the green function because it is setting the attributes of the green part. For example, with .addClass() you can specify what that class is to be by doing this .addClass("maintitle"). This will now add the class of maintitle to whatever HTML/CSS element you have chosen smile.gif Note as well that because we're setting a CSS property (class) the attribute is wrapped in "" quotation marks wink.gif

Hopefully that makes some sense. Here however the purple attribute is simply function(){ which allows us to build a script that will only execute when the page is loaded smile.gif                                                                                                                                                                                                                                                                                                                                                                                               
August 20, 2009 12:59 pm
QUOTE
test
                                                                                                                                                                                                                                                                                                                                                                                              
August 18, 2009 05:25 pm
Just click on my name, post below if you want to test the online/offline legend, it works I promise smile.gif                                                                                                                                                                                                                                                                                                                                                                                               
December 12, 2008 10:40 am
Code Name: Index Only Shoutbox
Date Created: 12th December 2008
Preview: Here??
Placement: Board Wrappers beneath <% STATS %>

Explanation:
Basically turns the Shoutbox off if you aren't viewing the Index (main) page on your forum. Helps save on space really is all.

The Code:

CODE
<script>
/* Shoutbox only on Index */

var disc = document.getElementById("navstrip");
var dune = disc.innerHTML.match("<{F_NAV_SEP}>");
var kaboodle = document.getElementsByTagName("div");

if(dune){
for (i=0;i<kaboodle.length;i++)
if(kaboodle[i].className == "tableborder" && kaboodle[i].innerHTML.match(/latest shouts in the shoutbox/i)){
kaboodle[i].style.display="none";

}
}
</script>


Installation

1. Just copy and paste into your Board Wrappers (AdminCP --> Skins & Settings --> Board Wrappers --> your skin).

And you are done.

FAQ

Q. I want to redistribute/edit this code? Can I?
A. You may changed it to whatever you want for use on your forum. It's polite to retain the copyright but I cannot force it on you. Please don't redistribute it without telling me, for some reason people don't like that. Seriously though if you ask first you can't get into trouble later and unless it's a site I'm a member of chances are the answer will be Yes.

Q. It's broken! FIX IT NOW!
A. Not exactly a question but okay. Send me a PM on this site or post in the relevant topic. I swing by regularly so just keep checking back smile.gif 99% of the time bugs are found and destroyed during my own testing but occasionally one slips through so please do report if found wink.gif Oh and if you can fix it, I really don't mind simply being sent a fixed code tongue.gif

Enjoy!

Please Visit Jcink.com for Support.                                                                                                                                                                                                                                                                                                                                                                                               
November 29, 2008 10:19 pm
Code Name: vBulletin Navigation for JFB
Date Created: 29th November 2008
Preview: Here?? (warning: Preview uses the version for Coders)
Placement: Board Wrappers beneath <% STATS %>

Version History:

vBulletin Navigation for JFB v.2.a

Current main release with full customisation options, added features and no longer a Macro! Also hosted code so less board wrapper confusion and a whole lot better in every way conceivably possible. Current features introduced:
* Quick Login for Guests or Welcome Back stats for members *
* Better board integration of the Navigation line *
* vBulletin header that's actually better than what it mimics *
* Predictive content using JFB's special magic *
* Code hosting/auto updating and no longer a Macro *
* Easy "true/false" settings for displayed navigation links *

vBulletin Navigation for Coders v.2.b

Yes it's meant to be italics. The first iteration of the dual-boot style options for this mod. Basically I made what people wanted but felt it actually limited those who knew basic coding so this "resource" (pft) was created to plug that gap (and because I wanted it tongue.gif).

vBulletin Navigation for JFB v.1.2

Somehow losing v1.1 this never saw the light of day because javascript and Macros don't play nicely. It changed the name a bit though tongue.gif

Vbulletin Style Navigation v.1

R.I.P because frankly this was awful and yet was the main version for almost a year :S Had zero customisation, used the LOGO Macro and didn't even change display when you logged in leading to eons of confusion. Finally limped to it's grave, thank goodness. Current features introduced:
* General concept and structure *

The Code:

QUOTE
<script>
/* vBulletin Style Navigation by Chakka */

/* Set to true to turn on or false to turn off */

affiliate = true;
help = true;
rules = true;
search = true;
members = true;
calender = true;
store = true;
downloads = true;
shoutbox = true;
army = true;
lottery = true;
bookie = true;
usergroups = true;
reputation = true;
irc = true;
home = true;
arcade = true;

/* Do not edit below this line */

var name = "<!-- |name| -->";
var posts = "<!-- |posts| -->";
var numsg = "<!-- |new_msg| -->";
var myid = "<!-- |id| --> ";
</script>
<script src="http://re.jcink.com/filehosting/chakka/vbnav.js"></script>


Installation

1. Just copy and paste into your Board Wrappers (AdminCP --> Skins & Settings --> Board Wrappers --> your skin).

2. Turn off any links you don't use. So for example, if I wanted just Downloads, Home, Members and Store on I would edit the variables so only those read "true". You can technically replace "true" with anything you like from "banana" to "gophercheesemonkey" but frankly it's a lot less open to bugs if you just use "false". So please do that wink.gif

And you are done. Zero customisation in this form I'm afraid. By all means take the source code and mess around with it yourself if you know what you're doing, or check out the version for Coders below smile.gif

FAQ

Q. It doesn't look like the one in the Preview? WTF!?!
A. OK two things. First of all it's made to blend with your skin so it will use elements from whatever skin you place it on. Obvious answer out of the way, chances are if you're still reading it's the navigation that's causing you issues. Yeh I run the version for Coders (below) on this site because I needed a more customised appearance. Hope that doesn't annoy ya'll too much. I did warn you when you clicked the Preview smile.gif

Q. I want to redistribute/edit this code? Can I?
A. You may changed it to whatever you want for use on your forum. It's polite to retain the copyright but I cannot force it on you. Please don't redistribute it without telling me, for some reason people don't like that. Seriously though if you ask first you can't get into trouble later and unless it's a site I'm a member of chances are the answer will be Yes.

Q. It's broken! FIX IT NOW!
A. Not exactly a question but okay. Send me a PM on this site or post in the relevant topic. I swing by regularly so just keep checking back smile.gif 99% of the time bugs are found and destroyed during my own testing but occasionally one slips through so please do report if found wink.gif Oh and if you can fix it, I really don't mind simply being sent a fixed code tongue.gif

Enjoy!

Please Visit Jcink.com for Support.

-------------

Pst, coders look here! Do you want full control over the contents of the actual navigation? Allowing you to add images, change font styles, re-order links et al? Check out the vBulletin Navigation for Coders below then wink.gif

The Code

QUOTE
<script>
/* vBulletin Style Navigation by Chakka */

/* Edit lego variable with whatever you want */
lego = "your stuff here";


/* Do not edit below this line */
var name = "<!-- |name| -->";
var posts = "<!-- |posts| -->";
var numsg = "<!-- |new_msg| -->";
var myid = "<!-- |id| --> ";
</script>
<script src="http://re.jcink.com/filehosting/chakka/vbnavfc.js"></script>


Just copy and paste into Board Wrappers then edit the "lego" variable which is basically the innerHTML for the submenu in the Mod. If that last sentence didn't make sense, use the full version of the code above wink.gif Oh and PS I use the version for coders on my test site so you can get an idea of what you can do with this (although so much more is possible really tongue.gif).

Please Visit Jcink.com for Support.                                                                                                                                                                                                                                                                                                                                                                                               
Last Visitors


August 24, 2009 09:21 pm




August 21, 2009 03:19 pm




August 21, 2009 05:58 am



Comments
No comments posted.
Add Comment

Friends

2 posts
Active: October 30, 2009 07:53 pm


102 posts
Active: September 11, 2009 11:13 pm


5 posts
Active: May 30, 2009 10:55 pm



[ Script Execution time: 0.5568 ]   [ 26 queries used ]   [ GZIP Disabled ]   [ Server Load: 0.41 ]