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)
Last edited by lima (2008-05-23 08:37:59)
Last edited by lima (2008-05-23 08:59:50)
wetz lupa...
satu lagi neh
gmn klo visitor albumnya
potonya dibuat getar juga......
#edit
klo pripiuna bro nopz....
pertama aku liat visitor albumnya ada 3 kolom
trus liat kedua berubah menjadi 2 kolom...
dan beberapa kali aku view pasti aku kena hang......
Last edited by lima (2008-05-23 09:34:41)


ampe komennya jg komen punya gw..dasar..
[quote=Colin_McRally]Abang2 skalian,mo minta ijin pakai kodenya......

[/quote]
silaken ..
[quote=KhErMiNaToR]judul prepiu FS nya : FS mu FS ku Juga!
ampe komennya jg komen punya gw..dasar..
kalau yg ini ada gak bang..
[b]uang mu,uang ku juga.[/b]
be te we,tang por saring bang nopatz...
+1 4 u .. 
kalau yg ini ada gak bang..
uang mu,uang ku juga.
be te we,tang por saring bang nopatz...
+1 4 u .. 
)
[/quote]
muke gile lu...

bused dah..bawa bawa muke,,
gw lempar pake cendol ijo..!!
tuing................................... [img]http://theftalk.com/img/warn_add.gif[/img]
[/quote]
jalan ke sana kemari. =d
wuekekek. bang.
pake script temenmu temenku juga. =d
pasti pada bingung nih yang datang.
bang nopatz mang keren
[b]lima[/b]
coba refresh dulu,uda?
[spoiler] +1 repu :rose: [/spoiler]
Last edited by teguh0203 (2008-05-23 11:25:48)
aku dah logout
aku dah restart
tapi tetap gak bertambah........
[b]lima[/b] mang url efes lima mana? coba liat