Might be time to think about better use of javascript

Register an Account
Pligg Chat Room
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-20-2007, 09:05 AM
New Pligger
 
Join Date: Jul 2007
Posts: 4
First off, I'm new to this community, and don't know any of you all, so please trust me I'm trying to contribute and not just criticize with this post. I understand it can be frustrating when some new guy who hasn't written a line of code on a project as large as this comes in and starts pointing out what he thinks is problems, and its really stuff that the design team has already discussed and made decisions on. If that's the case, and I should hush, just tell me

With version 2.0 just starting, it might be time to evaluate the use of javascript, and how it affects the design of the product. I'm basing this off of the fact that I see jQuery is included with Pligg, though, as a suggestion, you may want to check out Ext JS - JavaScript Library

In either case, the points below should apply to either library (or even ExtJS running on top of jQuery).

Design the browser to server communication with the idea that there is no javascript available. This would require moving away from the use of links with onClicks, and rather, built with hrefs that pass information directly to the server. Normally this would be done with GET requests, however, since you're looking at CI, you'd want to use it's URI functionality. So, for example..

To vote on story 5, the vote link before any javascript loads might have an href that looks like "/vote/5", and the A could have a class of "voteLink".

Then, have your javascript load. It can use the functionality that your javascript framework to use css selectors to grab all A elements with the class of voteLink, override the href, and add on onClick even for an xmlhttprequest to the same link, with the addition of a POST variable "aR = true".

On the backend, your script parses the URI, sending it to the vote controller, and using the first variable as the id the vote is being added to. Do your normal routine to validate and add a vote. Then at the display time, check to see if the POST variable aR exists.

If there is no aR, send the user back to the page the request came from, which will show them the new vote count. If the aR does exist, then load up a JSON format response, stating the vote was a success, and applying the new vote count.

I hope this makes sense, I'm still working on my first cup of coffee and going through server logs here at work.
Reply With Quote
  #2 (permalink)  
Old 07-20-2007, 09:19 AM
New Pligger
 
Join Date: Jul 2007
Posts: 4
Ok, I guess this isn't going to be all javascript related, so the title of this thread is misleading.

Sessions. Well, you're going with CI, so you have a few headstarts available to you on improving this part of the site. The basic idea is, go with database based session handling. This way, if someone is running a large Pligg site and needs to have multiple load balanced front ends to a database backend, you can still manage sessions between the multiple servers.

As a suggestion for a starting point, I'd look at Wiki | CodeIgniter
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extra fields not appearing johnfromberkeley Questions and Comments 5 10-21-2008 10:12 AM
a lot of Javascript , I mean a looooooot !! neo2cold Questions and Comments 1 10-04-2008 08:48 PM
Time Stamp problem in my site http://wetogether.info netfreak Questions and Comments 13 09-08-2008 01:33 PM
AJAX and Javascript not working on Firefox 2 lcct83 Questions and Comments 5 04-02-2007 01:31 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development