Pages: 123456..6

  2008-05-23 08:29:05

nopathz
» FTalkGeek
FTalk Level: zero
1256
0
1969-12-31

[quote][align=center][color=red][b]Maaf ... script ini sudah tidak sepenuhnya jalan (reason:FS Update), mohon untuk Mod agar menutup thread ini, Makasih[/b][/color][/align][/quote] [hr][hr][hr][hr] I

[quote][align=center][color=red][b]Maaf ... script ini sudah tidak sepenuhnya jalan (reason:FS Update), mohon untuk Mod agar menutup thread ini, Makasih[/b][/color][/align][/quote] [hr][hr][hr][hr] Ini merupakan kelanjutan dari thread [url=http://theftalk.com/t32356-%5BTUTORIAL%5D-Temanmu-Temanku-Juga-%3Alol%3A.html][b]Temanmu Temanku Juga[/b][/url] :lol: Tujuannya juga untuk ngisengin visitor sambil belajar AJAX. Ngisengin visitor yang gimana lagi nih? Jadi nantinya di FS kita ada box yang isinya foto2 dari visitor. Seperti biasa, yang pertama musti ada dalam js kalian adalah fungsi Ajax Request (credit to [b]Feruzz[/b]). Letakkan di Bagian C (kalo udah punya lewatin aja): [spoiler]function ajaxRequest(type, url, async, param, func, handlerparam) { /** * ajaxRequest - You may not remove or change this notice. * version: 2.4 * Copyright 2008 by FeRuZZ © http://profiles.friendster.com/feruzz. * * @type: "GET" | "POST" * @async: true | false * @param: string | null * @func: string | null * @handlerparam: string | null **/ var httprequest = null; var requestDone = false; var data = null; var responseType = "text"; var timeout = 0; var ival = null; var onreadystatechange = {}; var msxml = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"]; for (var x = 0, len = msxml.length; x < len; x++) { try { httprequest = window.ActiveXObject ? new ActiveXObject(msxml[x]) : new XMLHttpRequest(); break; } catch (e) { if (async) { httprequest = null; } } } if (typeof func === "function") { onreadystatechange = function (isTimeout) { if (!requestDone && httprequest && (httprequest.readyState === 4 || isTimeout === "timeout")) { requestDone = true; if (ival) { window.clearInterval(ival); ival = null; } if (!httprequest.status && location.protocol === "file:" || (httprequest.status >= 200 && httprequest.status < 300) || httprequest.status === 304 || httprequest.status === 1223) { var resPonse = (/xml/i.test(responseType))? httprequest.responseXML : httprequest.responseText; func(resPonse.replace(new RegExp("<script[^>]*>.*?<\/script>", "gi"), ""), handlerparam); } } }; } if (async) { ival = window.setInterval(onreadystatechange, 13); if (timeout > 0) { window.setTimeout(function () { if (httprequest) { httprequest.abort(); if (!requestDone) { onreadystatechange("timeout"); } } }, timeout); } } if (type === "GET" && (/GET/i.test(type))) { var ts = (new Date()).getTime(); var ret = url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); url = ret + ((ret === url) ? (url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); } if (data && type === "GET" && (/GET/i.test(type))) { url += (url.match(/\?/) ? "&" : "?") + data; data = null; } if (type === "POST" && (/POST/i.test(type))) { var headers = "application/x-www-form-urlencoded" + ("UTF-8" ? "; charset=" + "UTF-8" : ""); var contentLength = param ? param.length: 0; try { httprequest.setRequestHeader("Content-type", headers); httprequest.setRequestHeader("Content-length", contentLength); if (httprequest.overrideMimeType && (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0, 2005])[1] < 2005) { httprequest.setRequestHeader("Connection", "close"); } } catch (err) {} } httprequest.open(type, url, async); httprequest.setRequestHeader("ajaxRequest", "true"); httprequest.setRequestHeader("X-Requested-With", "XMLHttpRequest"); httprequest.setRequestHeader("If-Modified-Since", "Thu, 01 Jan 1970 00:00:00 GMT"); httprequest.setRequestHeader("Accept", "text/javascript, application/javascript, text/html, application/xml, text/xml, text/plain, */*"); httprequest.send(param); if (!async) { onreadystatechange(); } }[/spoiler] Disini kita juga butuh fungsi addBox. Letakkan di Bagian C (kalo udah punya lewatin aja): [spoiler]function addBox (type,head,htm,id,sibling) { //by marfillaster //type "LEFT" | "RIGHT" //head header string //htm innerHTML string //id css_id string //sibling css_id_insertbefore string | null /* Available default Siblings Default "sibling_ID" Boxes for Reference (10/19/07) LEFT RIGHT "0" = controlpanel "15" = meettrail "1" = photos "2" = friends "13" = blogs "14" = googleads "12" = reviews "7" = fan "6" = moreabout "8" = groups "18" = publiccomments null = appends to last(without "") "10" = scrapbook */ try { var li=document.createElement("li"); } catch(e) { var li=document.createElement("<li>"); } if(type=="LEFT") { var ul=document.getElementById("0").parentNode.parentNode; htm="<div class='boxcontent'>"+htm+"</div>"; } else {var ul=document.getElementById("2").parentNode.parentNode; } li.innerHTML="<div id='"+id+"' class='commonbox "+id+"'>"+ "<h2>"+head+"</h2>"+ "<div id='content_"+id+"'>"+ htm+ "</div>"+ "</div>"; if(sibling==null) ul.appendChild(li); else { sibling=document.getElementById(sibling).parentNode; ul.insertBefore(li,sibling); } }[/spoiler] Kemudian masukkan kode ini juga di Bagian C : [spoiler]// VISITOR'S ALBUM VA = {}; (function() { VA = { info: { album: null }, regexp: { album: /id="photogallery">([\S\s]*?)<\/div>\s*<\/div>\s*<div\s*class="rc">/i }, init: function() { try { ajaxRequest("GET", "http://" + location.hostname + "/viewphotos.php?a=0&uid=" + pageViewerID , true, null, VA.viewer, null); } catch(e) {} }, viewer: function(myfriend) { if (myfriend.replace(/^\s*|\s*$/g, "") === "") { alert("Error: Unable to parse user details!"); return; } else if (myfriend) { for (var val in VA.info) { try { VA.info[val] = new RegExp(VA.regexp[val]).exec(myfriend)[1].replace(/^(\d)$/, "0$1"); } catch(e) { VA.info[val] = ""; } } visitoralbum="<div class='flogrid75'>"+VA.info.album.replace(/photothumb/gi,"flogriditem").replace(/m.jpg/gi,"t.jpg"); addBox("LEFT","Foto-Foto Hasil Nyolong",visitoralbum,"visitoralbum","0"); } } }; })(); if(pageViewerID!=pageOwnerID) if(pageViewerID!="") VA.init();[/spoiler] Selamat mencoba ... Ayo iseng terus ... ups ... maksudnya ayo belajar terus ...

Last edited by nopathz (2008-10-29 10:49:11)

Pages: 123456..6

Board footer

© 2024 F Talk

Current time is 06:12

[ 12 queries - 0.035 second ]
Privacy Policy