2007-12-04 06:44:39

d.razcalz
» n00b
FTalk Level: zero
67
0
1969-12-31

Re: the code may become obselete.

is there anything wrong about my codes..?can anyone check this out..?i have more than 70 pictures.. here is the code in my css: [quote]#photocontainer { height: 100% } .photothumb { padding-top: 5px; float: left; width: 75px; height: 75px; display: inline; margin: 3px; } .thumbnail { height: 75px; overflow: hidden; display: block; } .thumbnail img { margin: 5px auto 0 0; width: 75px; height: 75px; border: none; filter:alpha(opacity=100); -moz-opacity: 1.0; opacity: 1.0; } .photothumb .thumbnail a:hover img { filter:alpha(opacity=50); -moz-opacity: 0.5; opacity: 0.5; } #photoprev { width: 120px; height: 100px; overflow: hidden; filter:alpha(opacity=100); -moz-opacity: 1.0; opacity: 1.0; } #photoprev img { margin: 1px auto 0 0; width: 120px; height: 100px; filter:alpha(opacity=100); -moz-opacity: 1.0; opacity: 1.0; } #photoprev a:hover img { filter:alpha(opacity=50); -moz-opacity: 1; opacity: 1; }[/quote] and here's the code in my js: [quote]if (!attachOnLoadHandler(function(){randPhotoGallery();})) window.onload = function(){randPhotoGallery();}; function randPhotoGallery() { RANDPHOTOPREV.init(); } if (typeof RANDPHOTOPREV == "undefined") { RANDPHOTOPREV = {}; } RANDPHOTOPREV = { _photos: [], _cached: [], _maxphotos: null, _temp: [], init: function() { for (var x=0;x<document.links.length;x++) { if (document.links[x].href.match(/http\:\/\/profiles\.friendster\.com\/photos\/[\d]+?\/[\d]+?/)) { var _pagelink = /\(([\d]+?)\)/; this._maxphotos = _pagelink.exec(document.links[x])[1]; break; } } var pages = ["2"]; /* 0 for 40 photos */ for (val in pages) { if (pages[val] != null) { this.fetch(pages[val]); } } }, fetch: function(page) { this.getElementsByClassName(null,"DIV",/photos/i)[0].getElementsByTagName("h2")[0].firstChild.nodeValue = "Loading Photos... Please Wait!"; this.ajaxRequest("http://"+window.location.host+"/photos/"+pageOwnerID+"/"+page,"RANDPHOTOPREV.parsephoto",page); }, randPhoto: function() { return (Math.round(Math.random())-0.8); }, clearNode: function(obj) { obj.parentNode.replaceChild(obj.cloneNode(false),obj); }, show: function() { var photoContent = document.createElement("div"); photoContent.normalize(); this.clearNode(document.getElementById("photocontainer")); document.getElementById("photocontainer").appendChild(photoContent); this._photos.sort(this.randPhoto); for (var x=0;x < 10;x++) { document.getElementById("photocontainer").innerHTML += this._photos[x]; } }, more: function() { if (this._cached.length<(Math.floor(this._maxphotos/20)+1)) { var temp; do { temp = Math.ceil(Math.random()*(Math.floor(this._maxphotos/20))); }while(this._cached.toString().indexOf(":"+temp+":") != -1); this.fetch(temp); }else { this.show(); } }, picprev: function(htm) { document.getElementById("photoprev").innerHTML = htm.replace(/m\.jpg/gim,".jpg"); }, parsephoto: function(htm,page) { if (htm.replace(/^\s*|\s*$/gim,"") === null) { RANDPHOTOPREV.fetch(page); return; }else { this._temp = htm.replace(/\s+?/gim," ").match(/<div\s+?class="photothumb">[^@]+?<\/div><\/div>/gim); for (var i=0;i<this._temp.length;i++) { this._temp[i] = this._temp[i].replace(/href="\/photos/gim,"href=\"http://www.friendster.com/photos"); this._temp[i] = this._temp[i].replace(/alt/gim,"title"); this._temp[i] = this._temp[i].replace(/<a /g,"<a target=\"_blank\" "); this._temp[i] = this._temp[i].replace(/<div\s+?class="thumbnail">/gim,"<div class=\"thumbnail\" onMouseOver=\"RANDPHOTOPREV.picprev(this.innerHTML)\">"); if (!this._temp[i].match("nophoto")) RANDPHOTOPREV._photos.push(this._temp[i]); } var preview = this._temp[0].match(/<a[^@]+?<\/a>/)[0].replace(/m\.jpg/gim,".jpg"); var _photo = document.createElement("div"); _photo.id = "randomphoto"; _photo.className = "boxcontent"; _photo.align = "center"; _photo.appendChild(document.createElement("div")); _photo.getElementsByTagName("div")[0].id = "photoprev"; _photo.getElementsByTagName("div")[0].innerHTML = preview; _photo.appendChild(document.createElement("div")); _photo.getElementsByTagName("div")[1].id = "photocontainer"; var _boxcontent = this.getElementsByClassName(document.getElementById("content_1"),"DIV","boxcontent")[0]; if (_boxcontent != null) { _boxcontent.parentNode.replaceChild(_photo,_boxcontent); } var _randLink = document.createElement("a"); _randLink.href = "javascript:void(RANDPHOTOPREV.more())"; _randLink.appendChild(document.createTextNode("More Random Photos")); var _viewall = this.getElementsByClassName(document.getElementById("content_1"),"DIV","viewall")[0].getElementsByTagName("a")[0]; if (_viewall != null) { _viewall.parentNode.replaceChild(_randLink,_viewall); } RANDPHOTOPREV._cached.push(":"+page+":"); this.getElementsByClassName(null,"DIV",/photos/i)[0].getElementsByTagName("h2")[0].firstChild.nodeValue = "Random Photo Gallery with Preview"; RANDPHOTOPREV.show(); } }, getElementsByClassName: function(oElm,sTag,sClass) { var elm = []; if (!oElm)oElm = document; if (!sTag)sTag = "*"; var els = oElm.getElementsByTagName(sTag) || document.all; for (var i=0,j=els.length;i<j;i++) { if (new RegExp(sClass).test(els[i].className))elm.push(els[i]); } return elm; }, ajaxRequest: function(url,func,handler) { if (handler) { handler = ","+handler; }else { handler = ""; } var httprequest= window.XMLHttpRequest? new XMLHttpRequest():new ActiveXObject("Msxml2.XMLHTTP"); if (func) { eval("httprequest.onreadystatechange=function(){if (httprequest.readyState==4) {"+func+"(httprequest.responseText"+handler+");}}"); } httprequest.open("GET", url, true); httprequest.send(null); } };[/quote]

You are viewing a post by d.razcalz. View all 268 posts in the code may become obselete..

Board footer

© 2024 F Talk

Current time is 00:34

[ 12 queries - 0.017 second ]
Privacy Policy