PageSourceSearch

https://bm-k.ru/javascripts/jquery.juitter.js?1340609520

js bm-k.ru collected 2026-10-07 01:54:56 UTC 7,684 bytes, 191 lines download raw bytes

1/*
2JUITTER 1.0.0 - 22/07/2009 - http://juitter.com
3BY RODRIGO FANTE - http://rodrigofante.com
4
5** jQuery 1.2.* or higher required
6
7Juitter is distributed under the MIT License
8Read more about the MIT License --> http://www.opensource.org/licenses/mit-license.php
9
10This script is just a beta test version, download and use it at your own risk.
11The Juitter developer shall have no responsability for data loss or damage of any kind by using this script.
12*/
13(function($) {
14	var conf = {},
15		// JUITTER DEFAULT CONFIGURATION ========================
16		// YOU CAN CHANGE THE DYNAMIC VARS ON CALLING THE start method, see the system.js for more information about it.
17
18		numMSG = 20; // set the number of messages to be show
19		containerDiv="juitterContainer", // //Set a place holder DIV which will receive the list of tweets example <div id="juitterContainer"></div>
20		loadMSG="Loading messages...", // Loading message, if you want to show an image, fill it with "image/gif" and go to the next variable to set which image you want to use on 
21		imgName="loader.gif", // Loading image, to enable it, go to the loadMSG var above and change it to "image/gif"
22		readMore="Read it on Twitter", // read more message to be show after the tweet content
23		nameUser="image" // insert "image" to show avatar of "text" to show the name of the user that sent the tweet 
24		live:"live-20", //optional, disabled by default, the number after "live-" indicates the time in seconds to wait before request the Twitter API for updates, I do not recommend to use less than 60 seconds.
25		// end of configuration
26	
27		// some global vars
28		aURL="";msgNb=1;
29		var mode,param,time,lang,contDiv,loadMSG,gifName,numMSG,readMore,fromID,ultID,filterWords;
30		var running=false;
31		// Twitter API Urls
32		apifMultipleUSER = "http://search.twitter.com/search.json?from%3A";
33		apifUSER = "http://search.twitter.com/search.json?q=from%3A";
34		apitMultipleUSER = "http://search.twitter.com/search.json?to%3A";
35		apitUSER = "http://search.twitter.com/search.json?q=to%3A";
36		apiSEARCH = "http://search.twitter.com/search.json?q=";
37	$.Juitter = {
38		registerVar: function(opt){
39			mode=opt.searchType;
40			param=opt.searchObject;
41			timer=opt.live;
42			lang=opt.lang?opt.lang:"";
43			contDiv=opt.placeHolder?opt.placeHolder:containerDiv;
44			loadMSG=opt.loadMSG?opt.loadMSG:loadMSG;
45			gifName=opt.imgName?opt.imgName:imgName;
46			numMSG=opt.total?opt.total:numMSG;
47			readMore=opt.readMore?opt.readMore:readMore;
48			fromID=opt.nameUser?opt.nameUser:nameUser;
49			filterWords=opt.filter;
50			openLink=opt.openExternalLinks?"target='_blank'":"";
51		},
52		start: function(opt) {		
53			ultID=0;
54			if($("#"+contDiv)){	
55				this.registerVar(opt);
56				// show the load message
57				this.loading();
58				// create the URL  to be request at the Twitter API
59				aURL = this.createURL();
60				// query the twitter API and create the tweets list
61				this.conectaTwitter(1);		
62				// if live mode is enabled, schedule the next twitter API query
63				if(timer!=undefined&&!running) this.temporizador();
64			}   
65		},
66		update: function(){
67			this.conectaTwitter(2);		
68			if(timer!=undefined) this.temporizador();
69		},
70		loading: function(){
71			if(loadMSG=="image/gif"){
72				$("<img></img>")
73					.attr('src', gifName)
74					.appendTo("#"+contDiv); 
75			} else $("#"+contDiv).html(loadMSG);
76		},
77		createURL: function(){
78			var url = "";
79			jlg=lang.length>0?"&lang="+lang:jlg=""; 
80			var seachMult = param.search(/,/);
81			if(seachMult>0) param = "&ors="+param.replace(/,/g,"+");
82			if(mode=="fromUser" && seachMult<=0) url=apifUSER+param;
83			else if(mode=="fromUser" && seachMult>=0) url=apifMultipleUSER+param;
84			else if(mode=="toUser" && seachMult<=0) url=apitUSER+param;
85			else if(mode=="toUser" && seachMult>=0) url=apitMultipleUSER+param;
86			else if(mode=="searchWord") url=apiSEARCH+param+jlg;
87			url += "&rpp="+numMSG;		
88			return url;
89		},
90		delRegister: function(){
91			// remove the oldest entry on the tweets list
92			if(msgNb>=numMSG){
93				$(".twittLI").each(
94					function(o,elemLI){
95						if(o>=numMSG) $(this).hide("slow");													  
96					}
97				);
98			}	
99		},
100		conectaTwitter: function(e){
101			// query the twitter api and create the tweets list
102			$.ajax({
103				url: aURL,
104				type: 'GET',
105				dataType: 'jsonp',
106				timeout: 1000,
107				error: function(){ $("#"+contDiv).html("fail#"); },
108				success: function(json){
109					if(e==1) $("#"+contDiv).html("");				
110					$.each(json.results,function(i,item) {
111						if(e==1 || (i<numMSG && item.id>ultID)){
112							if(i==0){
113								tultID = item.id;
114								$("<ul></ul>")
115									.attr('id', 'twittList'+ultID)
116									.attr('class','twittList')
117									.prependTo("#"+contDiv);  
118							}
119							if (item.text != "undefined") {
120								var link =  "http://twitter.com/"+item.from_user+"/status/"+item.id;  
121								
122								var tweet = $.Juitter.filter(item.text);
123								
124								if(fromID=="image") mHTML="<a href='http://www.twitter.com/"+item.from_user+"'><img src='"+item.profile_image_url+"' alt='"+item.from_user+"' class='juitterAvatar' /></a> "+$.Juitter.textFormat(tweet)+" -| <span class='time'>"+item.created_at+"</span> |- <a href='" + link + "' class='JRM' "+openLink+">"+readMore+"</a>";
125								else mHTML="<a href='http://www.twitter.com/"+item.from_user+"'>@"+item.from_user+":</a> "+$.Juitter.textFormat(tweet)+" -| <span class='time'>"+item.created_at+"</span> |-  <a href='" + link + "' "+openLink+">"+readMore+"</a>";
126								
127								$("<li></li>") 
128									.html(mHTML)  
129									.attr('id', 'twittLI'+msgNb)
130									.attr('class', 'twittLI')
131									.appendTo("#twittList"+ultID);
132
133								$('#twittLI'+msgNb).hide();
134								$('#twittLI'+msgNb).show("slow");
135								
136								// remove old entries
137								$.Juitter.delRegister();
138								msgNb++;								
139							}
140						}
141					});	
142					ultID=tultID;
143				}
144			});
145		},	
146		filter: function(s){
147			if(filterWords){
148				searchWords = filterWords.split(",");				
149				if(searchWords.length>0){
150					cleanHTML=s;
151					$.each(searchWords,function(i,item){	
152						sW = item.split("->").length>0 ? item.split("->")[0] : item;
153						rW = item.split("->").length>0 ? item.split("->")[1] : "";					
154						regExp=eval('/'+sW+'/gi');					
155						cleanHTML = cleanHTML.replace(regExp, rW);							
156					});
157				} else cleanHTML = s;			
158				return cleanHTML;
159			} else return s;
160		},
161		textFormat: function(texto){
162			//make links
163			var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
164			texto = texto.replace(exp,"<a href='$1' class='extLink' "+openLink+">$1</a>"); 
165			var exp = /[\@]+([A-Za-z0-9-_]+)/ig;
166			texto = texto.replace(exp,"<a href='http://twitter.com/$1' class='profileLink'>@$1</a>"); 
167			var exp = /[\#]+([A-Za-z0-9-_]+)/ig;
168			texto = texto.replace(exp,"<a href='http://juitter.com/#$1' onclick='$.Juitter.start({searchType:\"searchWord\",searchObject:\"$1\"});return false;' class='hashLink'>#$1</a>"); 
169			// make it bold
170			if(mode=="searchWord"){
171				tempParam = param.replace(/&ors=/,"");
172				arrParam = tempParam.split("+");
173				$.each(arrParam,function(i,item){					
174					regExp=eval('/'+item+'/gi');
175					newString = new String(' <b>'+item+'</b> ');
176					texto = texto.replace(regExp, newString);					  
177				});				
178			}
179			return texto;
180		},
181		temporizador: function(){
182			// live mode timer
183			running=true;
184			aTim = timer.split("-");
185			if(aTim[0]=="live" && aTim[1].length>0){
186				tempo = aTim[1]*1000;
187				setTimeout("$.Juitter.update()",tempo);
188			}
189		}
190	};	
191})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.