yoga1290

Android TwtBlog [Incomp]

Aug 13th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.62 KB | None | 0 0
  1. package yoga1290.twtblog;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.BufferedOutputStream;
  5. import java.io.BufferedReader;
  6. import java.io.ByteArrayInputStream;
  7. import java.io.DataInputStream;
  8. import java.io.DataOutputStream;
  9. import java.io.FileInputStream;
  10. import java.io.FileNotFoundException;
  11. import java.io.FileOutputStream;
  12. import java.io.IOException;
  13. import java.io.InputStreamReader;
  14. import java.net.HttpURLConnection;
  15. import java.net.InetAddress;
  16. import java.net.MalformedURLException;
  17. import java.net.ServerSocket;
  18. import java.net.Socket;
  19. import java.net.URL;
  20. import java.net.URLConnection;
  21. import java.net.UnknownHostException;
  22. import java.util.HashSet;
  23. import java.util.Scanner;
  24. import java.util.StringTokenizer;
  25. import java.util.TreeMap;
  26. import java.util.Vector;
  27.  
  28. import android.app.Activity;
  29. import android.content.Context;
  30. import android.graphics.Color;
  31. import android.os.Bundle;
  32. import android.provider.OpenableColumns;
  33. import android.util.Log;
  34. import android.view.Gravity;
  35. import android.view.MotionEvent;
  36. import android.view.View;
  37. import android.view.View.*;
  38. import android.view.ViewGroup.LayoutParams;
  39. import android.widget.Button;
  40. import android.widget.EditText;
  41. import android.widget.GridView;
  42. import android.widget.LinearLayout;
  43. import android.widget.ScrollView;
  44. import android.widget.TextView;
  45. import android.content.*;
  46.  
  47.  
  48. public class Twtblog extends Activity implements android.view.View.OnClickListener {
  49. // TextView query;
  50. EditText query;
  51. LinearLayout ll,dll;
  52. Button ok,refresh;
  53. private data d;
  54.  
  55. private int n=0;
  56.  
  57. private TextView hostv;
  58. /** Called when the activity is first created. */
  59. @Override
  60. public void onCreate(Bundle savedInstanceState) {
  61. super.onCreate(savedInstanceState);
  62. ll=new LinearLayout(this);
  63.  
  64. ll.setOrientation(LinearLayout.VERTICAL);
  65. ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
  66.  
  67. query=new EditText(ll.getContext());
  68. query.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  69.  
  70.  
  71. ok=new Button(ll.getContext());
  72. ok.setText("+");
  73. ok.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
  74. ok.setOnClickListener(this);
  75.  
  76. ll.addView(query);
  77. ll.addView(ok);
  78.  
  79.  
  80. d=new data();
  81. setContentView(ll);
  82.  
  83.  
  84. new HTTPServer(d).start();
  85. // new Thread(this).start();
  86. hostv=new TextView(this);
  87. try{
  88. hostv.setText("http://"+InetAddress.getLocalHost().getHostAddress()+":1290");
  89. }catch(Exception e){}
  90. ll.addView(hostv);
  91. }
  92.  
  93. public void onClick(View v) {
  94. if(v.equals(ok))
  95. {
  96. String twt,re,entries[],inputLine,res="",tags[];
  97. BufferedReader in;
  98. int i,j;
  99. String er="";
  100. try {
  101. in = new BufferedReader(
  102. new InputStreamReader(
  103. new URL("http://search.twitter.com/search.atom?q="+(""+query.getText()).replace("#", "%23").replace("@","@")).openConnection().getInputStream() ));
  104. hostv.setText("Strat reading..");
  105. while ((inputLine = in.readLine()) != null)
  106. res+=inputLine;
  107. in.close();
  108. entries=res.split("</entry>");
  109. er=entries.length+"";
  110. for(i=0;i<entries.length-1;i++)
  111. {
  112. tags=new String[]{};
  113. twt=entries[i].substring(entries[i].lastIndexOf("<title>")+"<title>".length(),entries[i].lastIndexOf("</title>") );
  114. twt=twt.replace("\r\n","<br>");
  115. twt=twt.replace("\n","<br>");
  116. System.out.println(">>>"+twt);
  117. re=entries[i].substring(0,entries[i].lastIndexOf("\" rel=\"alternate\"/>"));
  118. re=re.substring(re.lastIndexOf("href=\"")+"href=\"".length());
  119. tags=SplitTags(twt);
  120. // twt=twt.replace("'","\'");
  121. // twt=twt.replace("\"","\\"+"\"");
  122. for(j=0;j<tags.length;j++)
  123. d.add(tags[j].toLowerCase(), re+"\n"+twt);
  124. }
  125.  
  126. hostv.setTextColor(Color.WHITE);
  127. hostv.setText("http://"+InetAddress.getLocalHost().getHostAddress()+":1290");
  128. }catch(Exception e){er+=e.getMessage();}
  129. hostv.setText(er+d.getTagNames());
  130.  
  131. }
  132. }
  133.  
  134. public static String[] SplitTags(String txt)
  135. {
  136. int eInd;
  137. String t;
  138. HashSet<String> hs=new HashSet<String>();
  139. Vector<String> v=new Vector<String>();
  140. while( ( eInd = txt.indexOf('#') ) >-1)
  141. {
  142. eInd++;
  143. if(
  144. (eInd-2>=0 && !( 'a'<=txt.charAt(eInd-2)&&txt.charAt(eInd-2)<='z' )
  145. && !( 'A'<=txt.charAt(eInd-2)&&txt.charAt(eInd-2)<='Z' )
  146. && !( '0'<=txt.charAt(eInd-2)&&txt.charAt(eInd-2)<='9' )
  147. && txt.charAt(eInd-2)!='&' )
  148. || eInd<=1 )
  149. {
  150. while(eInd<txt.length()&&
  151. (
  152. ('a'<=txt.charAt(eInd)&&txt.charAt(eInd)<='z' )
  153. || ('A'<=txt.charAt(eInd)&&txt.charAt(eInd)<='Z' )
  154. || ('0'<=txt.charAt(eInd)&&txt.charAt(eInd)<='9' )
  155. )
  156. )
  157. eInd++;
  158.  
  159. t=txt.substring(txt.indexOf('#')+1,eInd);
  160. if(eInd-txt.indexOf('#')+1>0 && !hs.contains(t))
  161. {
  162. hs.add(t);
  163. v.add(t);
  164. }
  165. }
  166. txt=txt.substring( eInd );
  167. }
  168. String res[]=new String[v.size()];
  169. v.toArray(res);
  170. return res;
  171. }
  172.  
  173. }
  174.  
  175.  
  176.  
  177. class data
  178. {
  179. private TreeMap<String,tagTweets> map;
  180. private Vector<String> tagnames;
  181. public static long sleepTime=30*60*1000;
  182. public data()
  183. {
  184. map=new TreeMap<String, tagTweets>();
  185. tagnames=new Vector<String>();
  186. }
  187. public int getSizeOf(String tagName)
  188. {
  189. if(map.containsKey(tagName.toLowerCase()))
  190. return map.get(tagName.toLowerCase()).getSize();
  191. return 0;
  192. }
  193. public int getSize()
  194. {
  195. int res=0;
  196. for(String t:tagnames)
  197. if(map.containsKey(t))
  198. res+=map.get(t).getSize();
  199. return res;
  200. }
  201. public void add(String tag,String txt)
  202. {
  203. if(!map.containsKey(tag.toLowerCase()))
  204. {
  205. tagnames.add(tag.toLowerCase());
  206. map.put(tag.toLowerCase(), new tagTweets(tag.toLowerCase()));
  207. }
  208. map.get(tag.toLowerCase()).add(txt);
  209. }
  210. public String getTagText(String tag)
  211. {
  212. if(!map.containsKey(tag.toLowerCase()))
  213. return "";
  214. String res="",a[]=map.get(tag.toLowerCase()).getTwts();
  215. for(String t:a)
  216. res+=t+"\n"; //TODO check the new line
  217. return res;
  218. }
  219. public String getTagNames()
  220. {
  221. String res="",ar[]=new String[tagnames.size()];
  222. tagnames.toArray(ar);
  223. for(String t:ar)
  224. res+=t+"\n"; //TODO Check the new line
  225. return res;
  226. }
  227. // public void save(Context con)
  228. // {
  229. // try{
  230. // FileInputStream fin;
  231. // FileOutputStream fout;
  232. // String twt[],re[],all="";
  233. // DataInputStream dis;
  234. // int i,j;
  235. // HashSet<String> oldRe=new HashSet<String>();
  236. // String allFiles[]=con.fileList();
  237. // for(i=0;i<tagnames.size();i++)
  238. // {
  239. // all="";
  240. // System.err.println("ok loop");
  241. // re=new String[]{};
  242. //
  243. // for(String file:allFiles)
  244. // if(file.equals(tagnames.get(i).toLowerCase()))
  245. // {
  246. // fin=con.openFileInput(tagnames.get(i).toLowerCase());
  247. // byte res[]=new byte[fin.available()];
  248. // all="";
  249. // String t;
  250. // dis=new DataInputStream(fin);
  251. // while( (t=dis.readLine()) !=null)
  252. // all+=t+"\n";
  253. // dis.close();
  254. // // fin.read(res);
  255. // // all=new String(res);
  256. // fin.close();
  257. // re=all.split("\n");
  258. // }
  259. // System.err.println("ok file read");
  260. // // Memorize URLs of old tweets in this single file
  261. // for(j=0;j<re.length;j+=2)
  262. // oldRe.add(re[j].toLowerCase());
  263. // twt=map.get(tagnames.get(i).toLowerCase()).getTwts();
  264. //
  265. //
  266. // for(j=0;j<twt.length;j++)
  267. // if(!oldRe.contains(twt[j].split("\n")[0])) // If this Tweet is New!
  268. // {
  269. // System.err.println(">>"+tagnames.get(i).toLowerCase()+":\n"+twt[j]+"\n\n");
  270. // all+=twt[j]+"\n";
  271. // }
  272. // fout=con.openFileOutput(tagnames.get(i).toLowerCase(), Context.MODE_PRIVATE);//new FileOutputStream(tagnames.get(i).toLowerCase());
  273. // fout.write(all.getBytes());
  274. // fout.close();
  275. // }
  276. //
  277. // // String old[]=new String[]{};
  278. // HashSet<String> oldTagNames=new HashSet<String>();
  279. // for(String file:allFiles)
  280. // if(file.equals("_tags"))
  281. // {
  282. // fin=con.openFileInput("_tags");
  283. // //Add oldTags with the latest 1s
  284. // all="";
  285. // String t;
  286. // dis=new DataInputStream(fin);
  287. // while( (t=dis.readLine()) !=null)
  288. // {
  289. // if(!map.containsKey(t.toLowerCase()))
  290. // tagnames.add(t.toLowerCase());
  291. // }
  292. // fin.close();
  293. // }
  294. // //Add oldTags with the latest 1s
  295. // String res="";
  296. // for(i=0;i<tagnames.size();i++)
  297. // res+=tagnames.get(i).toLowerCase()+"\n";
  298. // // new FileOutputStream("_tags").write(res.getBytes());
  299. // fout=con.openFileOutput("_tags", Context.MODE_PRIVATE);
  300. // fout.write(res.getBytes());
  301. // fout.close();
  302. // }catch(Exception e){System.err.println("Save:"+e);}
  303. // ///
  304. // }
  305. }
  306.  
  307.  
  308.  
  309.  
  310.  
  311. class tagTweets
  312. {
  313. private String name;
  314. private Vector<String> twts;
  315. public tagTweets(String tagName)
  316. {
  317. this.name=tagName;
  318. twts=new Vector<String>();
  319. }
  320. public void add(String txt)
  321. {
  322. twts.add(txt);
  323. }
  324. public String[] getTwts()
  325. {
  326. String res[]=new String[twts.size()];
  327. twts.toArray(res);
  328. return res;
  329. }
  330. public int getSize()
  331. {
  332. return twts.size();
  333. }
  334. }
  335.  
  336.  
  337. //Sever -Starter
  338. class HTTPServer extends Thread
  339. {
  340. private data d;
  341. public HTTPServer(data d)
  342. {
  343. this.d=d;
  344. }
  345. @Override
  346. public void run() {
  347. try{
  348. ServerSocket ss = new ServerSocket(1290);
  349. while(true){
  350. Socket s = ss.accept();
  351. new Thread(new FileRequest(s,d)).start();
  352. }
  353. }catch(Exception ex){System.err.println(ex);}
  354. }
  355. }
  356. //Handling Client Requests:
  357. class FileRequest implements Runnable{
  358. public boolean send=false;
  359. private data d;
  360. FileRequest(Socket s,data d){
  361. // this.app=app;
  362. this.d=d;
  363. client = s;
  364. } //*/
  365. public void run() {
  366.  
  367. if(requestRead()){
  368. if(fileOpened()){
  369. constructHeader();
  370. if(fileSent()){
  371. // app.display("*File: "+fileName+" File Transfer Complete*Bytes Sent:"+bytesSent+"\n");
  372. }
  373. }
  374. }
  375. try{
  376. dis.close();
  377. client.close();
  378. }catch(Exception e){System.err.println(e);}
  379.  
  380. }
  381.  
  382.  
  383. private boolean fileSent()
  384. {
  385. try{
  386. DataOutputStream clientStream = new DataOutputStream
  387. (new BufferedOutputStream(client.getOutputStream()));
  388. clientStream.writeBytes(header);
  389. // app.display("******** File Request *********\n"+
  390. // "******* "+ fileName +"*********\n"+header);
  391. int i;
  392. bytesSent = 0;
  393. while((i=requestedFile.read()) != -1){
  394. clientStream.writeByte(i);
  395. bytesSent++;
  396. }
  397. clientStream.flush();
  398. clientStream.close();
  399. }catch(IOException e){System.err.println("SEND>"+e);return false;}
  400. return true;
  401.  
  402. }
  403. private boolean fileOpened()
  404. {
  405. // ByteInputStream bis=new ByteInputStream("".getBytes(), 0);
  406. // DataInputStream dis=new DataInputStream(bis);
  407. if(send)
  408. {
  409. try{
  410. //TODO setIO
  411. requestedFile =new DataInputStream(new ByteArrayInputStream("Hisashi buri-yoga1290".getBytes()));// new DataInputStream(new BufferedInputStream(new FileInputStream(fileName)));
  412. fileLength = requestedFile.available();
  413. // requestedFile = new DataInputStream(new BufferedInputStream
  414. /// ((this.getClass().getResourceAsStream("/"+fileName))));
  415. // fileLength = requestedFile.available();
  416.  
  417. }catch(FileNotFoundException e){
  418. if(fileName.equals("filenfound.html")){return false;}
  419. fileName="filenfound.html";
  420. if(!fileOpened()){return false;}
  421. }catch(Exception e){System.err.println("Open>"+e);return false;}
  422.  
  423. }
  424. else
  425. {
  426. String res="";
  427. if(fileName.equals("_tags"))
  428. res=d.getTagNames();
  429. else if(fileName.equals("index.html"))
  430. res=getHomePage();
  431. else //if(fileName.indexOf(".png")<0)
  432. res=d.getTagText(fileName);
  433.  
  434. try{
  435. requestedFile = new DataInputStream(new ByteArrayInputStream(res.getBytes()));
  436. fileLength = requestedFile.available();
  437. }catch(Exception e){
  438. System.err.println("Open>>"+e);
  439. return false;}
  440. }
  441. return true;
  442.  
  443. }
  444. private boolean requestRead()
  445. {
  446. try{
  447. //Open inputStream and read(parse) the request
  448. dis = new DataInputStream(client.getInputStream());
  449. String line;
  450. send=false;
  451. while((line=dis.readLine())!=null){
  452.  
  453. StringTokenizer tokenizer = new StringTokenizer(line," ");
  454. if(!tokenizer.hasMoreTokens()){ break;}
  455.  
  456. if(tokenizer.nextToken().equals("GET")){
  457.  
  458. fileName = tokenizer.nextToken();
  459. if(fileName.equals("/")){
  460. fileName = "index.html";
  461. }else{
  462. fileName = fileName.substring(1);
  463. if(fileName.indexOf('?')!=-1)
  464. {
  465. send=false; //DISABLE SENDING ANY FILES
  466. /* if(!fileName.substring(0,fileName.indexOf('?')).equals(keyy)) return false;
  467.  
  468. try{
  469. if(rob==null) rob=new Robot();
  470. if(fileName.indexOf('=')!=-1) rob.mouseMove(Integer.parseInt(fileName.substring(fileName.indexOf('=')+1,fileName.indexOf(',')) )
  471. ,Integer.parseInt(fileName.substring(fileName.lastIndexOf('=')+1,fileName.length()) ) );
  472. else if(fileName.indexOf("lc")!=-1){ rob.mousePress(InputEvent.BUTTON1_MASK);rob.mouseRelease(InputEvent.BUTTON1_MASK);}
  473. else
  474. { rob.mousePress(InputEvent.BUTTON3_MASK);rob.mouseRelease(InputEvent.BUTTON3_MASK);}
  475. }catch(Exception e){System.err.println(e);}
  476.  
  477. */
  478. fileName=fileName.substring(0,fileName.indexOf('?'));
  479. }
  480. }
  481.  
  482. }
  483.  
  484. }
  485.  
  486. }catch(Exception e){
  487. System.err.println("Read Request:"+e);
  488. return false;
  489. }
  490. // app.display("finished file request");
  491.  
  492. return true;
  493. }
  494.  
  495.  
  496. private void constructHeader(){
  497. String contentType;
  498. if((fileName.toLowerCase().endsWith(".jpg"))||(fileName.toLowerCase().endsWith(".jpeg"))
  499. ||(fileName.toLowerCase().endsWith(".jpe"))){contentType = "image/jpg";}
  500. else if((fileName.toLowerCase().endsWith(".gif"))){contentType = "image/gif";}
  501. else if((fileName.toLowerCase().endsWith(".htm"))||
  502. (fileName.toLowerCase().endsWith(".html"))){contentType = "text/html";}
  503. else if((fileName.toLowerCase().endsWith(".qt"))||
  504. (fileName.toLowerCase().endsWith(".mov"))){contentType = "video/quicktime";}
  505. else if((fileName.toLowerCase().endsWith(".class"))){contentType = "application/octet-stream";}
  506. else if((fileName.toLowerCase().endsWith(".mpg"))||
  507. (fileName.toLowerCase().endsWith(".mpeg"))||(fileName.toLowerCase().endsWith(".mpe")))
  508. {contentType = "video/mpeg";}
  509. else if((fileName.toLowerCase().endsWith(".au"))||(fileName.toLowerCase().endsWith(".snd")))
  510. {contentType = "audio/basic";}
  511. else if((fileName.toLowerCase().endsWith(".wav")))
  512. {contentType = "audio/x-wave";}
  513. else {contentType = "text/plain";} //default
  514.  
  515. header = "HTTP/1.0 200 OK\n"+
  516. "Allow: GET\n"+
  517. "MIME-Version: 1.0\n"+
  518. "Server : HMJ Basic HTTP Server\n"+
  519. "Content-Type: "+contentType + "\n"+
  520. "Content-Length: "+ fileLength +
  521. "\n\n";
  522. }
  523.  
  524. // private Serve app;
  525. private Socket client;
  526. private String fileName,header;
  527. private DataInputStream requestedFile, dis;
  528. private int fileLength, bytesSent;
  529.  
  530. private String getHomePage()
  531. {
  532. return "<html> <head> <title></title> <meta http-equiv=\"Content-Type\" content=\"text/html;\n charset=UTF-8\"> <style> .togglebutton {\n cursor: pointer;\n border: 1px solid #000;\n margin: 10px;\n padding: 10px;\n display: inline-block;\n background: -webkit-gradient( linear, left top, left bottom, from(#fff), to(#ccc));\n }\n .togglebutton.toggled {\n color: #fff;\n background: -webkit-gradient( linear, left top, left bottom, from(#333), to(#999));\n }\n </style> </head> <body> <p align=\"center\"> <button tabindex=\"0\" id=\"submit\" onClick=\"popup();\n\" ><b><font size=\"100\">#</font></b></button></p> <div id=\"pop\" style=\"position: absolute;\n margin: 0 auto;\n width: 100%;\n display: none;\n \" > <table width=\"100%\" onmouseout=\"canClose=true;\n\" onmouseover=\"canclose=false;\n\"><tr><td align=\"center\"> <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"> <tr> <td align=\"right\" valign=\"bottom\" background=\"http://a.yfrog.com/img615/1907/jnvk.png\"><img src=\"http://a.yfrog.com/img740/2695/ppx.png\"/></td> <td align=\"center\" valign=\"bottom\" background=\"http://a.yfrog.com/img734/7428/hd1v.png\"><img src=\"http://a.yfrog.com/img614/543/4cgs.png\"/></td> <td align=\"left\" valign=\"bottom\" background=\"http://a.yfrog.com/img610/196/6arw.png\"><img src=\"http://a.yfrog.com/img739/2241/wzrj.png\"/></td> </tr> <tr> <td align=\"right\" background=\"http://a.yfrog.com/img615/1907/jnvk.png\"></td> <td align=\"center\" background=\"http://a.yfrog.com/img614/8743/bmdo.png\"> <div id=\"tags_div\">\n <div id=\"tb\" class=\"togglebutton\" onclick=\"toggle('tb')\">Toggle</div> \n <div id=\"tb2\" class=\"togglebutton\" onclick=\"toggle('tb2')\">Toggle</div> \n </div></td><td align=\"left\" background=\"http://a.yfrog.com/img610/196/6arw.png\"></td> </tr> <tr> <td align=\"right\" valign=\"bottom\"> <img src=\"http://a.yfrog.com/img620/6344/6gkl.png\"/> </td> <td align=\"center\" valign=\"bottom\" background=\"http://a.yfrog.com/img640/5922/wxzk.png\"></td> <td align=\"left\" valign=\"bottom\" > <img src=\"http://a.yfrog.com/img610/3355/vdf.png\"/> </td> </tr> </table></td></tr></table> </div> <br> <div id=\"result\">Loading...</div> <script> var firstLoad=true;\n var tags=new Array();\n var res=new Array();\n var twt=new Array();\n function loadTagsAJAX() {\n document.getElementById(\"result\").innerHTML=\"Loading Tags...\";\n var xmlhttp;\n if (window.XMLHttpRequest) {\n xmlhttp=new XMLHttpRequest();\n }\n else {\n xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n xmlhttp.onreadystatechange=function() {\n if ( xmlhttp.readyState==4 &&xmlhttp.status==200) {\n var txt=\"\";\n tags=xmlhttp.responseText.split(\"\\n\");\n tags.splice(tags.length-1,1);\n for(i=0;\ni<tags.length;\ni++) txt+='<div id=\"'+tags[i]+'\" class=\"togglebutton\" onclick=\"toggle(\\''+tags[i]+'\\')\">'+tags[i]+'</div>';\n document.getElementById(\"tags_div\").innerHTML=txt;\ndocument.getElementById(\"result\").innerHTML=\"Done:Loading Tags...\";\n }\n }\n xmlhttp.open(\"GET\",\"_tags\",true);\n xmlhttp.send();\n }\n function loadTag(tag) {\n document.getElementById(\"result\").innerHTML=\"Loading Tweets...\";\n var xmlhttp;\n if (window.XMLHttpRequest) {\nxmlhttp=new XMLHttpRequest();\n }\n else {\nxmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n }\n xmlhttp.onreadystatechange=function() {\n if (xmlhttp.readyState==4 && xmlhttp.status==200) {\n var tmp=xmlhttp.responseText.split(\"\\n\");\n tmp.splice(tmp.length-1,1); \n twt=new Array();\n for(i=0;i<tmp.length/2;i++) res[i]=tmp[i*2];\n for(i=0;i<tmp.length/2;i++) twt[i]=tmp[1+i*2];\n draw();\n }\n }\n var Found;\n var i,j=0,k=0;\n for(i=0;\ni<tags.length;\ni++) if(document.getElementById(tags[i]).classList.contains('toggled')) {\nk++;\n}\n if(k>1) {\n document.getElementById(\"result\").innerHTML=\"Searching...\";\n for(i=0;\ni<twt.length;\ni++) {\n Found=true;\n for(j=0;\nj<tags.length;\nj++) if(document.getElementById(tags[j]).classList.contains('toggled')) Found=Found && (twt[i].toLowerCase().indexOf(\"#\"+tags[j])>-1);\n if(!Found) {\nres.splice(i,1);\ntwt.splice(i,1);\n}\n }\n draw();\n }\n else{\n document.getElementById(\"result\").innerHTML=\"sending request...\";\n xmlhttp.open(\"GET\",tag,true);\n xmlhttp.send();\n }\n }\n function draw(){\n var txt=\"\";\nfor(i=0;\ni<twt.length;\ni++) txt+=getFrame(twt[i],res[i])+\"<br>\";\ndocument.getElementById(\"result\").innerHTML=txt;\nif(txt.length==0) document.getElementById(\"result\").innerHTML=\"Not yet!\";\n}\n function getFrame(txt,re) {\n txt=txt+'<br><div id=\"fb-root\" ></div><script src=\"http://connect.facebook.net/en_US/all.js#appId=194978063887428&amp;xfbml=1\"><'+'/script><fb:like href=\"'+re+'\" send=\"true\" layout=\"button_count\" width=\"450\" show_faces=\"true\" font=\"\"></fb:like>';\n txt+='<a href=\"http://twitter.com/home?status=RE : '+re+'\"target=\"_blank\">?</a></td>';\n return '<table width=\"100%\"><tr><td align=\"center\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"right\" valign=\"bottom\" background=\"http://a.yfrog.com/img615/1907/jnvk.png\"><img src=\"http://a.yfrog.com/img740/2695/ppx.png\"/></td><td align=\"center\" valign=\"bottom\" background=\"http://a.yfrog.com/img734/7428/hd1v.png\"></td><td align=\"left\" valign=\"bottom\" background=\"http://a.yfrog.com/img610/196/6arw.png\"><img src=\"http://a.yfrog.com/img739/2241/wzrj.png\"/></td></tr><tr><td align=\"right\" background=\"http://a.yfrog.com/img615/1907/jnvk.png\"></td><td align=\"center\" background=\"http://a.yfrog.com/img614/8743/bmdo.png\"><font color=\"white\">'+txt+'</font></td><td align=\"left\" background=\"http://a.yfrog.com/img610/196/6arw.png\"></td></tr><tr><td align=\"right\" valign=\"bottom\"> <img src=\"http://a.yfrog.com/img620/6344/6gkl.png\"/></td><td align=\"center\" valign=\"bottom\" background=\"http://a.yfrog.com/img640/5922/wxzk.png\"></td><td align=\"left\" valign=\"bottom\" > <img src=\"http://a.yfrog.com/img610/3355/vdf.png\"/> </td></tr></table></td></tr></table>';\n }\n function toggle(id) {\n canClose=false;\n var b = document.getElementById(id);\n if (b.classList.contains('toggled')) b.classList.remove('toggled');\n else b.classList.add('toggled');\n loadTag(id);\n }\n var canClose=false;\n function closepop() {\n if(canClose) popup();\n }\n function popup() {\n var nn=document.getElementById(\"pop\").style.display==\"none\";\n if(nn) canClose=false;\n document.getElementById(\"submit\").innerHTML=nn ? '<b><font size=\"100\">&#149;</font></b>':'<b><font size=\"100\">#</font></b>';\n document.getElementById(\"pop\").style.display= document.getElementById(\"pop\").style.display==\"none\" ? \"\":\"none\";\n }\n loadTagsAJAX();\n </script> </body></html>";
  533. }
  534.  
  535. }
Advertisement
Add Comment
Please, Sign In to add comment