var _gaq = _gaq || [];
_gaq.push(['ScoopshotWidgetMetrics._setAccount', 'UA-21286976-3']);
_gaq.push(['ScoopshotWidgetMetrics._trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
if (typeof ScoopshotWidget == "undefined") {
var ScoopshotTeaserWidget = false;
function ScoopshotWidget(publicKey, params, domId) {
if (!ScoopshotTeaserWidget) ScoopshotTeaserWidget = new Array();
this.index = ScoopshotTeaserWidget.length;
ScoopshotTeaserWidget[this.index] = this;
for (key in params){
this[key] = params[key];
}
this.publicKey = publicKey;
if (this.publicKey == "" || !this.publicKey || this.publicKey == undefined) this.publicKey = false;
this.domId = domId;
if (this.moderated == undefined) this.moderated = false;
if (this.photoList == undefined) this.photoList = false;
if (this.page == undefined) this.page = 1;
if (this.sortOrder == undefined) this.sortOrder = "popularity";
if (this.itemsPerPage == undefined) this.itemsPerPage = 5;
if (this.layout != "vertical") {
this.layout = "horizontal";
if (this.itemsPerRow == undefined) this.itemsPerRow = this.itemsPerPage;
if (this.rowsPerPage == undefined) this.rowsPerPage = 1;
} else {
if (this.itemsPerRow == undefined) this.itemsPerRow = 1;
if (this.rowsPerPage == undefined) this.rowsPerPage = this.itemsPerPage;
}
this.totalPages = 1;
this.itemsPerPage = this.itemsPerRow*this.rowsPerPage;
if (this.criteria == undefined) this.criteria = false;
if (this.pagingControl == undefined) this.pagingControl = false;
if (this.pagingControlExtended == undefined) this.pagingControlExtended = false;
if (this.totalCounter == undefined) this.totalCounter = false;
if (this.onClickThumb == undefined) this.onClickThumb = "deeplink";
if (this.linkTarget == undefined) this.linkTarget = false;
if (this.previewDomId == undefined) this.previewDomId = false;
if (this.previewHeight == undefined) this.previewHeight = 300;
if (this.previewWidth == undefined) this.previewWidth = 400;
if (this.widgetTitle == undefined) this.widgetTitle = "";
if (this.server == undefined) this.server = "https://store.scoopshot.com/";
if (this.stampFormat == undefined) this.stampFormat = "date";
if (this.filterSearch == undefined) this.filterSearch = false;
if (this.filterSearchKeyword == undefined) this.filterSearchKeyword = "";
if (this.filterTagKeyword == undefined) this.filterTagKeyword = "";
if (this.metaProducer == undefined) this.metaProducer = false;
if (this.metaProducerLength == undefined) this.metaProducerLength = 50;
if (this.metaTime == undefined) this.metaTime = false;
if (this.metaDuration == undefined) this.metaDuration = false;
if (this.metaDescription == undefined) this.metaDescription = false;
if (this.metaDescriptionLength == undefined) this.metaDescriptionLength = 100;
if (this.metaViews == undefined) this.metaViews = false;
if (this.metaLikes == undefined) this.metaLikes = false;
if (this.metaEarning == undefined) this.metaEarning = false;
if (this.metaPrice == undefined) this.metaPrice = false;
if (this.metaReward == undefined) this.metaReward = false;
if (this.metaLicensesSold == undefined) this.metaLicensesSold = false;
if (this.cssFile == undefined) {
if (this.layout == "vertical") {
this.cssFile = this.server + 'css/scoopshotWidgetVert.css';
} else {
this.cssFile = this.server + 'css/scoopshotWidgetHori.css';
}
}
if (this.thumbOverlayImage == undefined) this.thumbOverlayImage = false; //this.server + 'img/scoopshotWidgetIMG.png';
if (this.cssClass == undefined) {
if (this.layout == "vertical") this.cssClass = 'scoopshotWidgetVert';
else this.cssClass = 'scoopshotWidgetHori';
}
this.items = false;
this.wording = false;
try {
if (this.wordingObj != undefined) this.wording = new window[this.wordingObj]();
} catch (err) { }
if (this.thumbWidth == undefined) this.thumbWidth = 138;
if (this.thumbHeight == undefined) this.thumbHeight = 138;
if (this.metaWidth == undefined) this.metaWidth = 0;
if (this.metaHeight == undefined) this.metaHeight = 0;
if (this.headerHeight == undefined) this.headerHeight = 0;
if (this.footerHeight == undefined) {
if (this.layout == "vertical") this.footerHeight = 50;
else this.footerHeight = 0;
}
if (this.padding == undefined) this.padding = 0;
if (this.outerPadding == undefined) this.outerPadding = this.padding;
if (this.honorBorder == undefined) this.honorBorder = 2;
this.thumbWidth = parseInt(this.thumbWidth);
this.thumbHeight = parseInt(this.thumbHeight);
this.metaWidth = parseInt(this.metaWidth);
this.metaHeight = parseInt(this.metaHeight);
this.headerHeight = parseInt(this.headerHeight);
this.footerHeight = parseInt(this.footerHeight);
this.padding = parseInt(this.padding);
this.honorBorder = parseInt(this.honorBorder);
this.outerPadding = parseInt(this.outerPadding);
this.itemsPerPage = parseInt(this.itemsPerPage);
this.itemsPerRow = parseInt(this.itemsPerRow);
this.rowsPerPage = parseInt(this.rowsPerPage);
this.page = parseInt(this.page);
if (this.highlightSold == undefined) this.highlightSold = false;
if (this.firstPageAct == undefined) this.firstPageAct = false;
if (this.firstPageDeact == undefined) this.firstPageDeact = false;
if (this.lastPageAct == undefined) this.lastPageAct = false;
if (this.lastPageDeact == undefined) this.lastPageDeact = false;
if (this.prevPageAct == undefined) this.prevPageAct = false;
if (this.prevPageDeact == undefined) this.prevPageDeact = false;
if (this.nextPageAct == undefined) this.nextPageAct = false;
if (this.nextPageDeact == undefined) this.nextPageDeact = false;
if (this.ratingImgAct == undefined) this.ratingImgAct = false;
if (this.ratingImgDeact == undefined) this.ratingImgDeact = false;
if (this.adThumbData == undefined) this.adThumbData = false;
if (this.adThumbFreq == undefined) this.adThumbFreq = 1
if (this.adThumbSponsor == undefined) this.adThumbSponsor = false;
if (this.adSplashData == undefined) this.adSplashData = false;
if (this.adSplashFreq == undefined) this.adSplashFreq = 2
if (this.adSplashOnce == undefined) this.adSplashOnce = false;
this.GetJSON = ScoopshotWidgetGetJSON;
this.Build = ScoopshotWidgetBuild;
this.Browse = ScoopshotWidgetBrowse;
this.GetText = ScoopshotWidgetGetText;
this.FormatStamp = ScoopshotWidgetFormatStamp;
this.CreateLink = ScoopshotWidgetCreateLink;
this.AdClose = ScoopshotWidgetAdClose;
this.Track = ScoopshotWidgetTrack;
this.firstShowItem = false;
this.eventAction = new Array();
this.addEventListener = ScoopshotWidgetAddEventListener;
this.eventFire = ScoopshotWidgetEventFire;
this.removeEventListener = ScoopshotWidgetRemoveEventListener;
this.lightbox = ScoopshotWidgetLighbox;
this.photoPreview = ScoopshotWidgetPhotoPreview;
this.GetJSON();
this.Track("init");
}
function ScoopshotWidgetGetJSON() {
var url;
var cta = new Array();
if (this.criteria) cta = cta.concat(this.criteria);
if (this.filterSearchKeyword != "") {
cta.push('"searchKeys":"'+ this.filterSearchKeyword.split(" ") +'"');
}
if (this.filterTagKeyword != "") {
cta.push('"hashtag":"'+ this.filterTagKeyword.replace("#","%23") +'"');
}
url = this.server +'ssWidgets/photoFeedWidget/'+ this.publicKey.replace("#","::") +'/'+ this.page +'/'+ this.itemsPerPage +'/'+ this.sortOrder +'/'+ this.photoList +'/ScoopshotTeaserWidget['+ this.index +'].Build/'+ this.moderated +'/';
importFile("Scoopshot_SCR_"+ this.index, url, "script");
importFile("Scoopshot_CSS_"+ this.index, this.cssFile, "link");
function importFile(id, url, type) {
oFile = document.getElementById(id);
var head = document.getElementsByTagName("head")[0];
if(oFile) head.removeChild(oFile);
switch (type) {
case "script":
oFile = document.createElement("script");
oFile.type = "text/javascript";
oFile.setAttribute("src", url);
break;
case "link":
oFile = document.createElement("link");
oFile.type = 'text/css';
oFile.rel = 'stylesheet';
oFile.href = url;
oFile.media = 'screen';
break;
}
oFile.setAttribute("id",id);
head.appendChild(oFile);
}
}
function ScoopshotWidgetTrack(e, code, redir, blank) {
switch (e) {
case "init":
code = this.publicKey;
break;
case "page":
code = this.page;
break;
}
_gaq.push(['ScoopshotWidgetMetrics._trackEvent', 'Widgets', e, code.toString()]);
if (redir) {
if (this.linkTarget || blank) {
window.open(redir, this.linkTarget || "_blank");
window.focus();
} else {
//window.location.href= redir;
setTimeout(function(){ window.location.href= redir },500);
}
}
}
function ScoopshotWidgetGetText(tagName, x, y, z) {
if (this.wording) {
var text = this.wording[tagName];
if (text != undefined) {
if (x != undefined) text = text.replace("[x]", x);
if (y != undefined) text = text.replace("[y]", y);
if (z != undefined) text = text.replace("[z]", z);
return text;
}
}
switch (tagName) {
case "paging_index": return "Page "+ x +" of "+ y;
case "paging_prev": return "Previous";
case "paging_next": return "Next";
case "paging_first": return "First";
case "paging_last": return "Last";
case "total_items": return x +" Photos";
case "search_go_button": return "Go";
case "search_find": return "Find: ";
case "meta_tag_by": return "By: "+ x;
case "meta_tag_views": return "Views: "+ x;
case "meta_tag_likes": return "Likes: "+ x;
case "meta_tag_earning": return "Earned: "+ x;
case "meta_tag_price": return "Price: "+ x;
case "meta_tag_reward": return "Reward: "+ x;
case "meta_tag_licenses": return "Licenses sold: "+ x;
case "meta_tag_rating": return "Rating: "+ x;
case "meta_tag_comments": return "Comments: "+ x;
case "meta_tag_duration": return "Duration: "+ x +":" + y;
case "made_money_1": return "Nice!";
case "made_money_2": return "High five!";
case "made_money_3": return "Good job!";
case "made_money_4": return "Congrats!";
case "made_money_5": return "Fantastic!";
case "made_money_6": return "Bravo!";
case "made_money_7": return "Excellent!";
case "made_money_8": return "Awesome!";
case "made_money_9": return "Super!";
case "made_money_10": return "Well done!";
case "made_money_text": return "This photo earned "+ y;
case "info_no_matches": return "No matching items!";
case "info_no_shows": return "No photos available!";
case "info_not_available": return "Requested photo not available!";
case "date_format_day": return x +" "+ y;
case "date_format_time": return ((x > 12)? (x-12):x) +":"+ y + ((x > 12)? "pm":"am");
case "date_format": return x +" "+ y;
case "month_1": return "Jan";
case "month_2": return "Feb";
case "month_3": return "Mar";
case "month_4": return "Apr";
case "month_5": return "May";
case "month_6": return "Jun";
case "month_7": return "Jul";
case "month_8": return "Aug";
case "month_9": return "Sep";
case "month_10": return "Oct";
case "month_11": return "Nov";
case "month_12": return "Dec";
case "time_ago": return x + " "+ y +" ago";
case "just_now": return "Just now";
case "minute": return "minute";
case "minutes": return "minutes";
case "hour": return "hour";
case "hours": return "hours";
case "day": return "day";
case "days": return "days";
case "week": return "week";
case "weeks": return "weeks";
case "month": return "month";
case "months": return "months";
case "year": return "year";
case "years": return "years";
case "error": return "(Error "+ x +": "+ y +")";
case "advertisement": return "ADVERTISEMENT";
case "sponsored": return "SPONSORED";
case "close_ad": return "[Close ad]";
case "lightbox_close": return "Close";
case "lightbox_all": return "See all";
case "lightbox_buy": return "Buy photo";
case "lightbox_related": return "Related";
case "overlay_buy": return "Buy";
case "overlay_view": return "View";
case "overlay_intro": return "Upload your photos...";
case "preview_credits": return "Photo: "+ x;
case "preview_more": return "View on Scoopshot.com";
default: return (x != undefined)? x:"";
}
}
function ScoopshotWidgetFormatStamp(stamp) {
var currentDate = new Date();
var timeDiff = new Date(currentDate.getTime() + (currentDate.getTimezoneOffset() * 60000)) - new Date(stamp.substring(0,4),((stamp.substring(5,7))-1),stamp.substring(8,10),stamp.substring(11,13),stamp.substring(14,16),stamp.substring(17,19));
if (this.stampFormat == "date") {
var localDate = new Date(currentDate - timeDiff);
var time = this.GetText("date_format_time", localDate.getHours(), ((localDate.getMinutes() < 10)? '0':'') + localDate.getMinutes());
var day = this.GetText("date_format_day", this.GetText("month_"+(localDate.getMonth()+1)), localDate.getDate(), localDate.getFullYear());
return this.GetText("date_format", day, time);
} else {
var second = 1000;
var minute = second*60;
var hour = minute*60;
var day = hour*24;
var week = day*7;
var month = week*4.35;
var year = month*12;
if (timeDiff < minute) return this.GetText("just_now");
else if (timeDiff < hour) return this.GetText("time_ago", Math.floor(timeDiff/minute), ((Math.floor(timeDiff/minute) > 1)? this.GetText("minutes"): this.GetText("minute")));
else if (timeDiff < day) return this.GetText("time_ago", Math.floor(timeDiff/hour), ((Math.floor(timeDiff/hour) > 1)? this.GetText("hours"): this.GetText("hour")));
else if (timeDiff < week) return this.GetText("time_ago", Math.floor(timeDiff/day), ((Math.floor(timeDiff/day) > 1)? this.GetText("days"): this.GetText("day")));
else if (timeDiff < month) return this.GetText("time_ago", Math.floor(timeDiff/week), ((Math.floor(timeDiff/week) > 1)? this.GetText("weeks"): this.GetText("week")));
else if (timeDiff < year) return this.GetText("time_ago", Math.floor(timeDiff/month), ((Math.floor(timeDiff/month) > 1)? this.GetText("months"): this.GetText("month")));
else return this.GetText("time_ago", Math.floor(timeDiff/year), ((Math.floor(timeDiff/year) > 1)? this.GetText("years"): this.GetText("year")));;
}
}
function ScoopshotWidgetBrowse(direction, startSearch, tagFilterKey) {
if (direction == "next") this.page++;
else if (direction == "prev" && this.page > 1) this.page--;
else if (direction == "last") this.page = this.totalPages;
else this.page = 1;
if (tagFilterKey) this.filterTagKeyword = tagFilterKey;
try {
//this.filterSearchKeyword = document.getElementById("Scoopshot_"+ this.index +"_sk").value.replace(/"/g, "");
} catch (err) { }
this.GetJSON();
this.Track("page");
}
function ScoopshotWidgetPhotoPreview(code) {
var itemPreview;
var previewPlaceholder;
if (code) {
for (var i=0; i < this.items.length; i++) {
if (this.items[i]["code"] == code) {
itemPreview = this.items[i];
}
}
}
previewPlaceholder = this.previewDomId;
if (previewPlaceholder && document.getElementById(previewPlaceholder) != undefined) {
var photoPreviewHTML = "";
photoPreviewHTML += "
";
photoPreviewHTML += "
";
photoPreviewHTML += "
";
document.getElementById(previewPlaceholder).innerHTML = photoPreviewHTML;
}
return false;
}
function ScoopshotWidgetLighbox(code) {
var itemPreview;
var widgetIdx = this.index;
if (code) {
for (var i=0; i < this.items.length; i++) {
if (this.items[i]["code"] == code) {
itemPreview = this.items[i];
}
}
}
if (itemPreview) {
var img = new Image();
img.onload = function() {
this.lightboxPhotoWidth = this.width;
if (this.lightboxPhotoWidth > (window.innerWidth-40)) this.lightboxPhotoWidth = window.innerWidth-40;
this.lightboxPhotoHeight = this.height;
if (this.lightboxPhotoHeight > (window.innerHeight-80)) this.lightboxPhotoHeight = window.innerHeight-110;
document.getElementById("ssTeaserOverlayBox").style.width = (this.lightboxPhotoWidth+20) +"px";
document.getElementById("ssTeaserOverlayBox").style.height = (this.lightboxPhotoHeight+60) +"px";
document.getElementById("ssTeaserImageOverlay").style.width = this.lightboxPhotoWidth +"px";
document.getElementById("ssTeaserImageOverlay").style.height = this.lightboxPhotoHeight +"px";
document.getElementById("ssTeaserMetaDescription").style.width = this.lightboxPhotoWidth-10 +"px";
document.getElementById("ssTeaserImage").style.width = this.lightboxPhotoWidth +"px";
document.getElementById("ssTeaserImage").style.height = this.lightboxPhotoHeight +"px";
document.getElementById("ssTeaserImageOverlay").alt = itemPreview["description"];
document.getElementById("ssTeaserImageOverlay").title = itemPreview["description"];
var boxHeight = parseInt(document.getElementById("ssTeaserOverlayBox").style.height)+parseInt(document.getElementById("ssTeaserOverlayBox").style.borderWidth)*2;
var mar = ((parseInt(window.innerHeight || self.innerHeight || (document.documentElement&&document.documentElement.clientHeight) || document.body.clientHeight)-boxHeight)/2);
document.getElementById("ssTeaserOverlayBox").style.margin = mar+"px auto";
document.getElementById("ssTeaserOverlayIMG").style.backgroundImage = "url(" + itemPreview["fullUrl"] +")";
document.getElementById("ssTeaserOverlay").style.display = "block";
document.getElementById("ssTeaserOverlayBG").style.display = "block";
}
img.src = itemPreview["fullUrl"];
document.getElementById("ssTeaserMetaOwner").innerHTML = this.GetText("meta_tag_by", itemPreview["ownerName"]);
document.getElementById("ssTeaserMetaTime").innerHTML = this.GetText("meta_tag_time", this.FormatStamp(itemPreview["time"]));
if (itemPreview["description"]) {
document.getElementById("ssTeaserMetaDescription").style.display = "block";
document.getElementById("ssTeaserMetaDescription").innerHTML = itemPreview["description"];
} else {
document.getElementById("ssTeaserMetaDescription").style.display = "none";
}
if (itemPreview["forSale"]) document.getElementById("ssTeaserControlBuy").firstChild.value = this.GetText("lightbox_buy");
else document.getElementById("ssTeaserControlBuy").firstChild.value = this.GetText("lightbox_view");
if (this.publicKey == "stats" || this.publicKey == "stats30") document.getElementById("ssTeaserControlAll").firstChild.value = this.GetText("lightbox_related");
else document.getElementById("ssTeaserControlAll").firstChild.value = this.GetText("lightbox_all");
document.getElementById("ssTeaserControlBuy").onclick = function(e) { ScoopshotTeaserWidget[widgetIdx].Track('buyPhoto', code, itemPreview["deeplink"], true); if(!e) { var e = window.event;} e.stopPropagation(); return false; };
document.getElementById("ssTeaserControlAll").onclick = function(e) { ScoopshotTeaserWidget[widgetIdx].Track('seeAll', code, itemPreview["marketlink"], true); if(!e) { var e = window.event;} e.stopPropagation(); return false; };
} else {
document.getElementById("ssTeaserOverlayIMG").style.backgroundImage = "none";
document.getElementById("ssTeaserOverlay").style.display = "none";
document.getElementById("ssTeaserOverlayBG").style.display = "none";
}
return false;
}
function ScoopshotWidgetCreateLink(data, linkedHTML) {
var aTag = false;
var aOnclick = 'ScoopshotTeaserWidget['+ this.index +'].Track(\'photo\', \''+ data.code +'\'); ';
switch (this.onClickThumb) {
case "lightbox":
aOnclick += 'return ScoopshotTeaserWidget['+ this.index +'].lightbox(\''+ data.code +'\');';
break;
case "placeholder":
if (this.previewDomId && document.getElementById(this.previewDomId) != undefined) {
aOnclick += 'return ScoopshotTeaserWidget['+ this.index +'].photoPreview(\''+ data.code +'\');';
break;
}
case "deeplink":
aOnclick = 'ScoopshotTeaserWidget['+ this.index +'].Track(\'photo\', \''+ data.code +'\', \''+ data.deeplink +'\');';
break;
case "marketlink":
aOnclick = 'ScoopshotTeaserWidget['+ this.index +'].Track(\'photo\', \''+ data.code +'\', \''+ data.marketlink +'\');';
break;
default:
aOnclick += this.onClickThumb +'(\''+ data.code +'\',\''+ data.deeplink +'\')';
break;
}
return '' + linkedHTML + '';
}
function ScoopshotWidgetAdClose(id) {
document.getElementById(id).style.display = 'none';
return;
}
function ScoopshotWidgetBuild(data) {
function truncate(text, len) {
try {
if (text.length > len) {
text = text.substring(0, len-3) + "...";
}
} catch (err) {
text = "";
}
return text;
}
function formatNumber(num, sep) {
if (!sep) return num;
var temp = "";
var formatted = "";
num = num.toString();
for (var i=num.length-1;i>=0;i--) temp += num.charAt(i);
temp = temp.replace(/(\d{3})/g, "$1" + sep);
if (temp.slice(-sep.length) == sep) temp = temp.slice(0, -sep.length);
for (var i=temp.length-1;i>=0;i--) formatted += temp.charAt(i);
return formatted;
}
var totalSize;
var showCount = 0;
var page = 1;
var taskDetailsUrl;
try {
if (data["result"]["items"] != undefined) {
this.items = data["result"]["items"];
this.totalSize = data["result"]["totalSize"];
taskDetailsUrl = data["result"]["taskDetails"];
this.photoWidget = (data["result"]["photoWidget"] != undefined);
if (this.widgetTitle === true) {
if (data["result"]["taskTitle"] != undefined) this.widgetTitle = data["result"]["taskTitle"]
else this.widgetTitle = "";
}
}
showCount = this.items.length;
if (this.totalSize > 0) {
this.totalPages = Math.ceil(this.totalSize / this.itemsPerPage);
page = this.page;
}
} catch (err) {
try {
this.errMsg = this.GetText('error', data["error"]["code"], data["error"]["message"]);
this.photoWidget = data["error"]["photoWidget"]
} catch (err) { }
}
if (this.photoWidget) {
this.previewDomId = this.domId;
if (this.previewDomId && document.getElementById(this.previewDomId) != undefined) {
if (this.items[0]) {
this.photoPreview(this.items[0]["code"]);
} else {
this.photoPreview();
}
}
return;
}
var adSplashAdd = (this.adSplashData && Math.ceil(Math.random()*this.adSplashFreq) == 1)
var thumbAdIdx = showCount;
if (!adSplashAdd && this.adThumbData && Math.ceil(Math.random()*this.adThumbFreq) == 1) {
var thumbAdIdx = Math.round(Math.random()*(showCount-1));
}
var dominantHeight = this.thumbHeight;
if (this.metaHeight > dominantHeight) dominantHeight = this.metaHeight;
var dominantWidth = this.thumbWidth;
if (this.metaWidth > dominantWidth) dominantWidth = this.metaWidth;
var offset = this.page * this.itemsPerPage;
var widgetHTML = "";
var elemHeight = 0;
var elemWidth = 0;
var elemTop = 0;
var elemLeft = 0;
if (this.layout == "horizontal") {
elemHeight = (this.rowsPerPage*(this.thumbHeight+this.metaHeight+2*this.honorBorder)+(this.rowsPerPage-1)*this.padding+2*this.outerPadding+this.headerHeight+this.footerHeight);
elemWidth = (this.itemsPerRow*(dominantWidth+2*this.honorBorder)+(this.itemsPerRow-1)*this.padding+2*this.outerPadding);
} else {
elemHeight = (this.footerHeight+this.headerHeight+this.rowsPerPage*(dominantHeight+2*this.honorBorder)+(this.rowsPerPage-1)*this.padding+2*this.outerPadding);
elemWidth = (this.itemsPerRow*(this.metaWidth+this.thumbWidth+2*this.honorBorder+this.padding)+(this.itemsPerRow-1)*this.padding+2*this.outerPadding);
}
widgetHTML += ' ';
if (this.headerHeight > 0) widgetHTML += ' ';
if (this.footerHeight > 0) widgetHTML += ' ';
widgetHTML += '
'+ this.widgetTitle +'
';
if (this.pagingControl) {
widgetHTML += ' ';
}
if (this.totalCounter) {
widgetHTML += '
'+ this.GetText("total_items", this.totalSize) +'
';
}
if (this.filterSearch) {
widgetHTML += '
';
}
if (this.layout == "horizontal") elemHeight = (this.rowsPerPage*(this.thumbHeight+this.metaHeight+2*this.honorBorder)+(this.rowsPerPage-1)*this.padding+2*this.outerPadding);
else elemHeight = (this.rowsPerPage*(dominantHeight+2*this.honorBorder)+(this.rowsPerPage-1)*this.padding+2*this.outerPadding);
widgetHTML += '
';
for (var i=0; i < this.itemsPerPage; i++) {
if (this.items[i] != undefined) this.items[i]["truncatedDescription"] = truncate(this.items[i]["description"], this.metaDescriptionLength);
if (this.layout == "horizontal") {
elemLeft = (i%this.itemsPerRow)*(dominantWidth+this.padding+2*this.honorBorder)+((i%this.itemsPerRow > 0)?this.outerPadding-this.padding:0);
elemHeight = (this.thumbHeight+this.metaHeight+((Math.floor(i/this.itemsPerRow) == 0)?this.outerPadding:this.padding));
elemTop = (Math.floor(i/this.itemsPerRow)*(elemHeight+2*this.honorBorder)+((Math.floor(i/this.itemsPerRow) > 0)?(this.outerPadding-this.padding):0));
elemHeight += (Math.floor(i/this.itemsPerRow) == this.rowsPerPage-1)?this.outerPadding:this.padding;
elemWidth = (dominantWidth+((i%this.itemsPerRow == 0)?this.outerPadding:this.padding)+(((i+1)%this.itemsPerRow == 0)?this.outerPadding:this.padding));
if (thumbAdIdx == i) var thumbAdCellHTML = '
';
} else {
elemLeft = (i%this.itemsPerRow)*(this.thumbWidth+this.metaWidth+2*this.padding+2*this.honorBorder)+((i%this.itemsPerRow > 0)?this.outerPadding-this.padding:0);
elemHeight = (dominantHeight+((Math.floor(i/this.itemsPerRow) > 0)?this.padding:this.outerPadding));
elemTop = (Math.floor(i/this.itemsPerRow)*(elemHeight+2*this.honorBorder)+((Math.floor(i/this.itemsPerRow) > 0)?(this.outerPadding-this.padding):0));
//elemWidth = (this.thumbWidth+this.metaWidth+((i%this.itemsPerRow == 0)?this.outerPadding:this.padding)+(((i+1)%this.itemsPerRow == 0)?this.outerPadding:this.padding));
elemWidth = (this.thumbWidth+this.metaWidth+this.padding+((i%this.itemsPerRow == 0)?this.outerPadding:this.padding)+(((i+1)%this.itemsPerRow == 0)?this.outerPadding:this.padding));
if (thumbAdIdx == i) var thumbAdCellHTML = '
';
}
if (this.items[i] != undefined) widgetHTML += '
';
else widgetHTML += '
';
if (this.layout == "horizontal") {
elemHeight = this.thumbHeight;
elemWidth = dominantWidth;
} else {
elemHeight = dominantHeight;
elemWidth = this.thumbWidth;
}
if (this.items[i] == undefined) {
widgetHTML += '
';
continue;
}
widgetHTML += '
'+ this.CreateLink(this.items[i], '
' + ((this.highlightSold && this.items[i]["licensesSold"] > 0) ? '
'+ this.GetText("made_money_"+ Math.floor((Math.random()*10)+1), this.items[i]["licensesSold"], this.items[i]["earned"]) +''+ this.GetText("made_money_text", this.items[i]["licensesSold"], this.items[i]["earned"]) +'
':'') + '
') +'
';
widgetHTML += '
';
if (this.thumbOverlayImage) widgetHTML += this.CreateLink(this.items[i], '
');
else widgetHTML += this.CreateLink(this.items[i], '
'+ ((this.items[i]['forSale'])?this.GetText("overlay_buy"):this.GetText("overlay_view")) +'
');
widgetHTML +='
';
if (this.metaDescription || this.metaProducer || this.metaTime || this.metaDuration || this.metaViews || this.metaLikes || this.metaPrice || this.metaReward || this.metaLicensesSold || this.metaEarning) {
if (this.layout == "horizontal") {
elemTop = (this.padding+((Math.floor(i/this.itemsPerRow) == 0)?this.outerPadding:this.padding)+this.thumbHeight);
elemLeft = (i%this.itemsPerRow == 0)?this.outerPadding:this.padding;
elemHeight = this.metaHeight;
} else {
elemTop = ((Math.floor(i/this.itemsPerRow) == 0)?this.outerPadding:this.padding);
elemLeft = (((i%this.itemsPerRow == 0)?this.outerPadding:this.padding)+this.padding+this.thumbWidth);
elemWidth = this.metaWidth;
}
widgetHTML += '
';
if (this.metaTime) widgetHTML += '
'+ this.GetText("meta_tag_time", this.FormatStamp(this.items[i]["time"])) +'
';
if (this.metaDuration && this.items[i]["mediaDurationMillis"]) widgetHTML += '
'+ this.GetText("meta_tag_duration", Math.floor(this.items[i]["mediaDurationMillis"]/1000/60), ((Math.floor((this.items[i]["mediaDurationMillis"]/1000)%60) < 10)?'0':'') + Math.floor((this.items[i]["mediaDurationMillis"]/1000)%60)) +'
';
if (this.metaDescription) widgetHTML += '
'+ this.GetText("meta_tag_description", truncate(this.items[i]["description"], this.metaDescriptionLength)) +'
';
if (this.metaProducer) widgetHTML += '
'+ this.GetText("meta_tag_by", truncate(this.items[i]["ownerName"], this.metaProducerLength)) +'
';
if (this.metaViews) widgetHTML += '
'+ this.GetText("meta_tag_views", this.items[i]["views"]) +'
';
if (this.metaLikes) widgetHTML += '
'+ this.GetText("meta_tag_likes", this.items[i]["likes"]) +'
';
if (this.metaPrice) widgetHTML += '
'+ this.GetText("meta_tag_price", this.items[i]["price"]) +'
';
if (this.metaReward) widgetHTML += '
'+ this.GetText("meta_tag_reward", this.items[i]["reward"]) +'
';
if (this.metaLicensesSold) widgetHTML += '
'+ this.GetText("meta_tag_licenses", this.items[i]["licensesSold"]) +'
';
if (this.metaEarning) widgetHTML += '
'+ this.GetText("meta_tag_earning", this.items[i]["earned"]) +'
';
widgetHTML += '
';
}
if (thumbAdIdx == i) {
widgetHTML += thumbAdCellHTML;
widgetHTML += '
'+ ((this.adThumbSponsor)?(this.CreateLink(this.items[i],this.adThumbData)):this.adThumbData) +'
';
widgetHTML += '
'+ ((this.adThumbSponsor)?this.GetText("sponsored"):this.GetText("advertisement")) +'
';
widgetHTML += '
';
widgetHTML += '
';
}
widgetHTML += '
';
}
if (showCount < 1) {
if (this.layout == "horizontal") elemTop = Math.round((this.rowsPerPage*(this.padding+this.thumbHeight+this.metaHeight)-40+(this.rowsPerPage-1)*this.padding+this.outerPadding)/2);
else elemTop = Math.round((this.rowsPerPage*dominantHeight+(this.rowsPerPage-1)*this.padding+this.outerPadding)/2);
widgetHTML += '
'+ ((this.filterSearchKeyword != "")? this.GetText("info_no_matches"):this.GetText("info_no_shows")) + " "+ this.errMsg +'
';
}
widgetHTML += '
';
if (adSplashAdd) {
widgetHTML += '
';
widgetHTML += '
'+ this.adSplashData +'
';
widgetHTML += '
'+ this.GetText("advertisement") +'
';
widgetHTML += '
';
widgetHTML += '
';
if (this.adSplashOnce) this.adSplashData = false;
}
widgetHTML += '
';
if (this.domId != undefined) document.getElementById(this.domId).innerHTML = widgetHTML;
if (this.items[0]) {
this.firstShowItem = this.items[0];
this.eventFire("widget.pageChanged");
this.eventFire("widget.loaded");
if (this.previewDomId && document.getElementById(this.previewDomId) != undefined && document.getElementById("ssPreviewPlaceholder_"+ this.previewDomId) == undefined) {
this.photoPreview(this.items[0]["code"]);
this.Track("initPhotoWidget", this.items[0]["code"]);
}
}
if (!document.getElementById('ssTeaserOverlay') && this.onClickThumb != "placeholder") {
var lightboxHTML;
lightboxHTML = '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
lightboxHTML += '
';
var ssTeaserOverlay = document.createElement('div');
ssTeaserOverlay.innerHTML = lightboxHTML;
document.getElementsByTagName('body')[0].appendChild(ssTeaserOverlay);
}
}
function ScoopshotWidgetAddEventListener(type, fn) {
this.eventAction[type] = fn;
this.eventFire(type);
}
function ScoopshotWidgetEventFire(type) {
if (this.eventAction[type]) {
switch (type) {
case "widget.pageChanged":
case "widget.loaded":
if (this.firstShowItem) {
this.eventAction[type](this.firstShowItem);
this.removeEventListener("widget.loaded");
this.firstShowItem = false;
}
break;
}
}
}
function ScoopshotWidgetRemoveEventListener(type) {
this.eventAction[type] = false;
}
};