function printInstalled(tpls,out) { console.log(OTPLS,RSRC); var list = OTPLS.list; out.push("

Installed

"); out.push(""); out.push(""); for(var ri=0; ri"); out.push(""); } out.push("
Name
") if(cr) { if(cr[0]==TYPE) out.push(""+shorten(cr[9],24)+""); else out.push(shorten(cr[9],24)); } else out.push("????"); //out.push("Uninstall
Uninstall
"); } function printAuthors(tps, out) { var as = JSON.parse(JSON.stringify(tps.authors)), list=tps.list; var to = [0,"Total:",0,0,0,0]; for(var i=0; i"; var thr = ""; out.push("

Best Contributors

"); out.push(""); out.push(""+thr+"#Templates"+thr+"Usages"+thr+"Total Size"+thr+"Last One"); for(var i=0; i" : ""); if(!last) out.push(""); else out.push(""); out.push(""); out.push(tdr+ca[2]+""); out.push(tdr+printNum(ca[3])+""); out.push(tdr+printBytes(ca[4])+""); out.push(tdr+""+printAge(ca[5])+" ago"); out.push(""); } out.push("
Name
"+(i+1)+"."+shorten(ca[1],24)+"
"); } function makeView(tps,out,twds,wds,curc,caut,cit) { var list = tps.list, cts=tps.categories; if(cit==-1) { if(caut!=-1) out.push("

× "+escapeHtml(tps.authors[caut][1])+"

"); var oi = out.length; out.push(""); var N=0, U=0, S=0; for(var i=0; i"; } else { var tpl = list[cit]; makeItem(tps,cit,cts,out, true); out.push(""); } } function uses() { return TYPE==0?"uses":"installs"; } function shorten(str, lim) { return (str.length300) num++; var cc = Math.floor(rst/num); //console.log(cc); var isz = cc-20; //console.log(isz); var tit = escapeHtml(tpl[9]); var lim = ~~(isz/9); //console.log(tpl); if(big) isz=rst/2; var wi = (isz+"px"); var hi = ((isz*9.3/16)+"px"); lst.push("
"); var iurl = tpl[4]; //(Math.random()<0.5?"wide.png":"tall.png"); // tpl[3] //* lst.push("
"); // ict if(!big) lst.push(""); lst.push(""); //if(big) lst.push("


Open
"); if(!big) lst.push("
"); lst.push("
"); // ict lst.push("
"); // cmt if(!big) lst.push(""); var tag = big?"h1":"span"; lst.push("<"+tag+" class=\"title "+(big?"t1":"t2")+"\" "+(big?"onclick=\"labelClicked()\"":"")+">" + (big?tit:shorten(tit,lim)) + (gotR?" ✅":"") + ""); if(!big) lst.push(""); var au = tps.authors[tpl[1]]; var cat = cts["c"+tpl[5]]; lst.push("") lst.push( "By " +escapeHtml(big?au[1]:shorten(au[1],~~(lim*0.7)))+""); lst.push(" in " + cat+""); lst.push(""); if(big) { lst.push("

"+findLinks(escapeHtml(tpl[10]))+"

"); lst.push("

"); var dstr = printDate(tpl[2]); lst.push(""+printNum(tpl[7])+" "+uses()+"") lst.push(" • "+printBytes(tpl[8])); lst.push(" • "+dstr+"");// lst.push("
"); lst.push("

"); lst.push("

"); var aurl = "//www.Photopea.com#t"+tempID(tpl); if(TYPE==0) lst.push("photopea.com#t"+tempID(tpl)+""); else lst.push(""+(gotR?"Uninstall":"Install")+""); lst.push("

"); } else { lst.push("
"); var us=tpl[7], ss=""; //us = Math.floor(Math.random()*1e9); if(us<1000) ss=us+""; else if(us<1e6) ss=(us/1e3).toFixed(us<1e4 ? 1 : 0)+"K"; else if(us<1e9) ss=(us/1e6).toFixed(us<1e7 ? 1 : 0)+"M"; var sl=ss.length-3; if(ss[sl]=="." && ss[sl+1]=="0") ss=ss.slice(0,sl)+ss[sl+2]; lst.push(ss+" "+uses()); var ts = printAge(tpl[2]); lst.push(" • "+ts+" ago"); lst.push(""); } lst.push("
"); // cmt lst.push("
"); } function OC(tgt) { // onclick if(IFR) return "onclick=\"rebuild('"+tgt+"')\" style=\"cursor:pointer;\""; if(tgt[0]=="-") tgt=""; return "href=\""+(tgt==""?"/templates/":tgt)+"\""; } function printAge(time) { var sts = [60, 60, 24, 30, 12,10000]; var uns = ["sec","min","hour","day","month","year"]; var td = (Date.now()/1000) - time, ts=""; var lim = 1; for(var i=0; i1?"s":""); break; } } return ts; } function printBytes(bs) { var bst = bs.toString(2); var zrs=0; while(zrs+1099 || fxd[fxd.length-1]=="0") ? rn : fxd; var ext = ["B","KB","MB","GB","TB","PB"][Math.floor(zrs/10)]; return num+" "+ext; } function printDate(d) { var dt = new Date(d*1000); var mon = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"][dt.getMonth()]; return mon+" "+(dt.getDate())+", "+dt.getFullYear(); } function printNum(f) { return f.toLocaleString('en-US', {maximumFractionDigits:2}); } function tempID(tpl) { return tpl[3].split("").reverse().join(""); } function isWhite(c) { return c==" " || c=="\n" || c=="\t"; } function isChar(c) { c=c.charCodeAt(0); return (65<=c && c<=90) || (97<=c && c<=122); } function findLinks(str) { //return str; var iod = []; for(var i=0; imin) continue; while(i0>0 && !isWhite(str[i0-1])) i0--; while(i1"+mid+""+str.slice(i1+1); min=i0; } return str//.replaceAll("\n","
"); } function escapeHtml(unsafe) { return unsafe .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); } function getCatCounts(tps) { var list = tps.list, cts=tps.categories; var ccnt = JSON.parse(JSON.stringify(cts)); for(var cat in ccnt) ccnt[cat]=0; for(var i=0; i"); out.push("AUTHORS"); out.push("CATEGORIES"); for(var cat in cts) { if(ccnt[cat]==0) continue; var cw = parseInt(cat.slice(1)), isTop = (cw%10)==0; //console.log(cw); out.push(""); out.push("
"); // onclick=\"catClicked("+cw+")\" out.push(cts[cat]); out.push(""+ccnt[cat]+""); out.push("
"); out.push("
"); } if(TYPE!=0) out.push("
INSTALLED ("+RSRC.length+")"); } function toCat(cat) { var ioa=cat.indexOf(" &"); if(ioa!=-1) cat=cat.slice(0,ioa)+cat.slice(ioa+2); var ioa=cat.indexOf(" /"); if(ioa!=-1) cat=cat.slice(0,ioa)+cat.slice(ioa+2); return cat.toLowerCase().replace(/\s+/g, "-"); } function cost0(v) { var age = (Date.now()*0.001 - v[2]) / (60*60*24); // age in days var cst = (v[7]+1) / age; // usages per day var ext = 60*Math.pow(Math.PI,-age*0.15); return cst+ext; } function cost1(v) { return v[2]; } function cost2(v) { return v[7]; }