× Joomla Facebook Connect support forum

Topic-icon [feature request] Select all button

Active Subscriptions:

None
15 years 6 months ago #6121 by coolweb
I'm not a developer so please be kind if this is a stupid idea, would it be possible to include this greasemonkey code in your facebook invites module?
	function addbutton(){
	var slist=document.getElementById('_view_all')?document.getElementById('_view_all').parentNode:undefined;
		if(slist!==undefined){
			// This creates the button.
			var anchor=document.createElement('li');
			anchor.className='PillFilter_filter   ';
			anchor.id='_select_all';
			
			var link=document.createElement('a');
			link.id='_select_all_anchor';
			link.setAttribute('onclick','txtc=this.firstChild.firstChild.firstChild.firstChild;if(txtc.textContent=="Select all"){txtc.textContent="Unselect all";}else{txtc.textContent="Select all";}var friends=document.getElementById("all_friends").getElementsByTagName("li");for(x=0;x<friends.length;x++){if(typeof friends[x]==="object"&&friends[x].className!="disabled"){fs.click(friends[x]);}}return false;');
			link.setAttribute('href','#');
			
			var tctl=document.createElement('div');
			tctl.className='tl';
			var tctr=document.createElement('div');
			tctr.className='tr';
			var tcbr=document.createElement('div');
			tcbr.className='br';
			var tcbl=document.createElement('div');
			tcbl.className='bl';
			
			var txt=document.createTextNode('Seleziona tutti');
			
			tcbl.appendChild(txt);
			tcbr.appendChild(tcbl);
			tctr.appendChild(tcbr);
			tctl.appendChild(tctr);
			link.appendChild(tctl);
			anchor.appendChild(link);
			
			// This injects the button.
			slist.insertBefore(anchor,document.getElementById('_view_all'));
			
			// This clears the timer used by the second part of this script.
			if(window.timer){
				window.timer=window.clearInterval(window.timer);
			}
		}
}


// First part: This executes the code for when the invite friends box is in it's own tab.
addbutton();



// Second part: This executes the code for when the invite friends box is a popup in an already existing window.
var fslinks=[];

function search(){
	try{
		//Tries searching for the links to the invite friends box using XPath.
		var iterator=document.evaluate(
			"//a[@ajaxify]",
			document,
			null,
			XPathResult.UNORDERED_NODE_ITERATOR_TYPE,
			null);
	
		var thisNode=iterator.iterateNext();
	
		while(thisNode){
			var x=0;
			if(thisNode.getAttribute('ajaxify').indexOf("invite_dialog.php")!=-1){
				fslinks[x]=thisNode;
				x++;
			}
			thisNode=iterator.iterateNext();
		}
	}
	catch(err){
		//Backupfunction for searching for the links to the invite friends box using plain JavaScript.
		GM_log("\nThere was an error using XPath.\nErrorcode:\n\n"+err);
		var links=document.getElementsByTagName('a');
		for(var i=0;i<links.length;i++){
			if(links[i].getAttribute("ajaxify")){
				if(links[i].getAttribute("ajaxify").indexOf("invite_dialog.php")!=-1){
					fslinks[i]=links[i];
				}
			}
		}
	}
}


function addtrigger(){
	if(fslinks.length!=0){
		for(var x=0;x<fslinks.length;x++){
			fslinks[x].addEventListener("click",new Function("window.timer=window.setInterval("+addbutton+",500);"),true);
		}
	}
}


window.addEventListener("load",function(){search();addtrigger();},false);
The topic has been locked.
Support Specialist
15 years 6 months ago #6122 by alzander
The invite module, unfortunately, is done through an iFrame to Facebook's site. This means that most of what you 'see' is actually hosted on Facebook's site, and we have little control over it. Facebook does it this way to prevent 'bad' people from auto-inviting friends of the user to the site, or other things that can be done behind the user's back. This all adds up to making it hard for us to change or add behavior to the invite module outside of what Facebook will allow us to do.

With that said, what are you looking for, specifically? A button to select all the users friends so that they can more easily send a friend invite? I don't think that's possible, but if the code your supplying from Grease Monkey above is some method to work with the Facebook inviter, that may help. If it's a generic "How to select multiple things at once", it probably won't due to the restrictions that Facebook places on us.

I'll profess to not having read over all the code to understand it's functionality, so forgive my ignorance. If you can post a link to where you got it, the explanation may help us understand better.

Thanks! We always love hearing feedback, even if we can't always act immediately upon it.
The topic has been locked.
Active Subscriptions:

None
15 years 6 months ago #6126 by coolweb
i found it here
userscripts.org/scripts/show/89653
I've already tested with greasemonkey and it works like a charm
The topic has been locked.
Support Specialist
15 years 5 months ago #6138 by alzander
Awesome! Thanks for let us know, and even testing it out. We're really focused on JFBConnect 3.1 right now, but the Invite module needs a few changes. We've added this to our tracker and will definitely investigate further for an upcoming release!
The topic has been locked.