if(typeof CONSYN_WIDGET_ID == "undefined"){
CONSYN_WIDGET_ID = 1;
CONSYN_WIDGETS = {};
}
ComConsynXss = new function() {
var widgets = CONSYN_WIDGETS;
this.widgets= CONSYN_WIDGETS;
var BASE_URL = 'http://picturepush.com/';
var CONTENT_URL = BASE_URL + 'api.php?data_format=json&module=slide&mode=album&clid=15685&alid=34380&tagname=&q=&repeats=-1&time=1500';
var STYLESHEET_URL = 'http://picturepush.com/widgets/slide.css';
var REQUEST = {"ml_tpl_path":"\/external.js.php","module":"slide","mode":"album","clid":"15685","alid":"34380","tagname":"","q":"","repeats":"-1","time":"1500"};
function getWidgetId(){
return (CONSYN_WIDGET_ID++);
}
function findWidget(id){
return document.getElementById("com_consyn_widget_"+id);
}
function requestStylesheet(stylesheet_url) {
stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
stylesheet.type = "text/css";
stylesheet.href = stylesheet_url;
stylesheet.media = "all";
document.lastChild.firstChild.appendChild(stylesheet);
}
Widget = {
apply: function(htmlElement){
for(var key in this){
if(key!="apply"){
htmlElement[key] = this[key];
}
}
htmlElement.init();
},
extend: function(obj){
for(var key in this){
if(typeof obj[key]=="undefined" || key=="extend"){
obj[key] = this[key];
}
}
obj.$super = this;
return obj;
},
receive: function(data){
alert("received data for widget"+this.$consynWidgetId);
},
request: function(data){
if(typeof data=="undefined") data={};
data['callback'] = 'ComConsynXss.widgets['+this.$consynWidgetId+'].receive';
//data['__cookies'] = document.cookie;
var script = document.createElement('script');
// How you'd pass the current URL into the request
strBuff = [];
for(var key in data){
val = data[key];
if(typeof val != "function" && val!=null && key.length>0){
strBuff.push("&");
strBuff.push(key);
strBuff.push("=");
strBuff.push(encodeURIComponent(val));
}
}
script.src = CONTENT_URL+strBuff.join("");
document.getElementsByTagName("head")[0].appendChild(script);
},
write: function(){
var id = getWidgetId();
document.write("
loading...
");
var w = findWidget(id);
this.$consynWidgetId = id;
this.apply(w);
widgets[id] = w;
return w;
}
}
requestStylesheet(STYLESHEET_URL);
function img_url(row, format){
return row["server"]+ "/photo/" + format + "/" + ((row["FileType"]=="0" || format=="movie")?row["imagefullname"]:(row["Id"]+".jpg"));
}Slide = Widget.extend({
$data: null,
$current: 0,
$interval: null,
$href: null,
$time: 1500,
$repeats: -1,
$rep: 0,
$paused: false,
init: function(){
this.className="picturepushSlide";
this.onclick = function(){
if(this.$href) location.href = this.$href;
}
if(typeof REQUEST.repeats !="undefined"){
this.$repeats = parseInt(REQUEST.repeats);
}
if(typeof REQUEST.time !="undefined"){
this.$time = parseInt(REQUEST.time);
}
this.request({pageSize:1000});
},
fadeTo: function(i, opacity){
var object = document.getElementById(this.id+"_"+i).style;
object.opacity = (opacity);
object.MozOpacity = (opacity);
object.KhtmlOpacity = (opacity);
object.filter = "alpha(opacity=" + opacity*100 + ")";
},
$tick: 0,
$stage: 1,
$STEP: 40,
animate: function(){
if(this.$paused) return;
var o = document.getElementById(this.id+"_1");
var o2 = document.getElementById(this.id+"_2");
if(this.$stage==0){
if(this.$tick < 800){
var p = this.$tick/800;
if(p>1) p =1;
if(p<0) p=0;
this.fadeTo(1, 1-(p*p));
this.fadeTo(2, p*p);
}else{
this.fadeTo(1, 1);
this.fadeTo(2, 0);
this.next();
this.$stage=1;
this.$tick=0;
}
}if(this.$stage==1){
if((this.$tick > this.$time && o2.loaded)||this.$tick>12000){
this.$tick=0;
this.$stage=0;
}
}
var w = o.width;
var h = o.height;
o.style.marginLeft = (-w/2)+"px";
o.style.marginTop = (-h/2)+"px";
w = o2.width;
h = o2.height;
o2.style.marginLeft = (-w/2)+"px";
o2.style.marginTop = (-h/2)+"px";
this.$tick+=this.$STEP;
},
receive: function(data){
this.innerHTML = "![]()
";
if(data.UserName){
this.innerHTML += "From "+data.UserName+"'s Gallery @ PicturePush";
}else{
this.innerHTML += "From PicturePush";
}
this.$data = data;
this.next();
var self = this;
setInterval(function(){
self.animate();
},this.$STEP);
this.fadeTo(1, 1);
this.fadeTo(2, 0);
},
next: function(){
if(this.$paused) return;
var img1 = this.$data.rows[this.$current];
var o = document.getElementById(this.id+"_1");
this.setImage(o, img1);
var url = (this.$data.UserPage)?(this.$data.UserPage+"/"):BASE_URL;
url += "album/"+img1['albumid']+"/"+img1['Id'];
this.$href = url;
this.$current++;
if(this.$current == this.$data.rows.length){
this.$current = 0;
this.$rep++;
if(this.$repeats > 0 && this.$rep>=this.$repeats){
this.$paused = true;
}
}
var img2 = this.$data.rows[this.$current];
o = document.getElementById(this.id+"_2");
o.loaded=false;
this.setImage(o,img2);
},
setImage: function(img, row){
img.src = img_url(row,'480');
}
});
Slide.write();
}