Wednesday, September 30, 2009

using the Prototype JavaScript Library its really magic, #php, #cakephp, #opensource, #JavaScript library

As common or rare as it may be for someone to need the ability to select and deselect checkboxes in a form, here is a way to do it using the Prototype JavaScript Library. I recently needed a way to do this for the Private Message functionality of a Web Application I'm working on. The example code below is taken from this Application.
First make the Event observers:

if($('box_list') != null)
{
Event.observe($('checkall'),'click',pm_checkall,true);
Event.observe($('clearall'),'click',pm_clearall,true);
Event.observe($('checkread'),'click',pm_checkread,true);
Event.observe($('checkunread'),'click',pm_checkunread,true);
}
Then make the functions to handle selecting and deselecting the checkboxes. Here I've made a function to loop over all the form elements and operate on the ones we want to change; and 4 functions that tell the main function what to do based on the Event observed:

function pm_checkall(e)
{
pm_check_uncheck(true);
}
function pm_clearall(e)
{
pm_check_uncheck(false);
}
function pm_checkread(e)
{
pm_check_uncheck(false,"unread");
pm_check_uncheck(true,"read");
}
function pm_checkunread(e)
{
pm_check_uncheck(false,"read");
pm_check_uncheck(true,"unread");
}
function pm_check_uncheck(val,group)
{
lst = document.forms['box_list'];
len = lst.elements.length;
var i=0;
for(i=0; i {
if(group)
{
if(lst.elements[i].className == group)
{
lst.elements[i].checked = val;
}
}
else
{
if(lst.elements[i].type == "checkbox")
{
lst.elements[i].checked = val;
}
}
}
}
Now it's time to add the correct markup to the page. I use Smarty for templates so the markup below shows the foreach loop where I generate the checkboxes for each message.



{foreach from=$message_list key=key item=message}





{/foreach}
{$message.subject} {$message.author_name}{$message.created_on|date_format}


Select:
All
None
Read
Unread

Friday, September 18, 2009

Facebook Six fight for right to bag boss

ARJUN RAMACHANDRAN AND ASHER MOSES
September 17, 2009
Six prison workers must wait until next week to find out if they will be sacked for criticising their bosses on Facebook.

The officers have each been sent a letter indicating the Corrective Services Department is considering sacking them for misconduct over comments they made on Facebook, which the department described as "bullying" and "harassment".

But the public sector union - which regards the sacking threat as an attempt to stifle dissent - has taken the matter to the Industrial Relations Commission.

It wants the IRC to put a hold on any sacking attempts and also to consider a change to the award safeguarding the rights of workers to speak freely outside work hours.

The IRC hearing, which opened yesterday, has been adjourned until Tuesday.

Harvard Discovers Six Sources Of Alternative Energy That Don't Suck!


Renewable energy sounds great, but there are a bunch of problems. For example, half the time you can't even use it.

It's hard to get wind power when the wind isn't blowing, for example. Likewise, it's hard to get solar power when it's cloudy.

So researchers are dumping billions of dollars into trying to find alterative energy technologies that provide power as consistently as, say, oil. Or nukes.

And here's the good news: They say they're this close to cracking the code that will lead to unlimited energy for all.

The Harvard Business Review has identified six sources of permanent alternative energy at various stages of development. There is no guarantee they will work, of course. But at least they're trying.
6 Sources Of Alternative Energy That Don't Suck→

Thursday, September 17, 2009

Pakistani's Politics, parlimantarina in Repulsive on live show. #Kal Tak on #tv channel #Express TV


A woman can be recognized by her way communicating. I think (I am sorry to say) she was one those in democratic party which she was defending herself by using abusive word (hera mindi she know well it is actually in Pakistan). she should never called by any Tv channel in future and she should expel out from Party after declaring a show card for her.
SEE Video also