diff --git a/functions.js b/functions.js index 91bf00d..83a6bb1 100644 --- a/functions.js +++ b/functions.js @@ -144,8 +144,10 @@ function do_upload(upload) function parsed(canvas,file) { console.log(canvas,file); + // rawViewer.previews.image_filenamecr2.getMetadata() + // TODO: need to do something smart with that. upload(canvas.toDataURL("image/jpeg"),file.name+".jpg",file.lastModified); - $(canvas).remove(); + canvas.remove(); raws.splice(0,1); busy = false; } diff --git a/functions.min.js b/functions.min.js index 43a6d3c..3c42852 100644 --- a/functions.min.js +++ b/functions.min.js @@ -1 +1 @@ -function fqueue(d){d.preventDefault();var c=d.target.files!=undefined?d.target.files:d.dataTransfer.files,b=0;for(;bc){b.height*=c/b.width;b.width=c}var j=CE("canvas"),h=j.getContext("2d");h.clearRect(0,0,j.width,j.height);j.width=b.width;j.height=b.height;h.drawImage(b,0,0,b.width,b.height);stackBlurCanvasRGBA(j,0,0,b.width,b.height,10);h.font=(b.height/100)*12+"px Ubuntu";h.fillInversedText("Uploading image...",(b.width/100)*15,(b.height/100)*50);var g=j.toDataURL(),k=new Image();j.remove();b.remove();k.src=g;k.classList.add("image");k.style.maxWidth="19%";k.style.cursor="progress";grid.appendChild(k);if(typeof window.scrollTo=="function"){window.scrollTo(0,$(k).offset().top)}uploads[d]={binary:f,fname:e,date:a,uploaded:0,uploading:false,thumbnail:k,id:d};uploads.queued++})}function startWorker(){if(typeof(Worker)!=="undefined"&&typeof(w)=="undefined"&&preload){w=new Worker("preload.min.js");w.onmessage=function(c){var d=basename(c.data[1]),a=c.data[0];var b=(window.URL||window.webkitURL).createObjectURL(a);imgs[d]=b;mdata[d]=json_decode(c.data[2]);console.info("WebWorker has successfully downloaded "+d+" to "+b)};w.postMessage(imgs);console.info("Preload WebWorker started")}}function update(){var b=new xhr(),a=url;b.open("GET","download.php/rename/"+a+"/"+this.id+"/"+this.textContent,true);b.addEventListener("readystatechange",function(){if(this.readyState==4&&this.status==200){if(!json_decode(this.responseText).success){alert("Something went wrong while renaming")}var c=new xhr();c.open("GET","download.php/exif/"+a+"?"+rand(),false);c.send();mdata[a]=json_decode(c.response)}});b.send()}function lhash(){requestAnimationFrame(lhash);var g=location.hash;if(g[1]=="!"){if(g.length<=2){console.warn("No arguments provided but #!. Stopping.")}else{argr=substr(g,2);args=explode(",",argr);for(var d=0;d2){console.warn("Multiple values specified, using first one")}if(c=="ts"){if(f!=""){thumbsize=f}}if(c=="rs"){if(f!=""){realsize=f}}if(c=="image"){if(f!=""&&f!=undefined){var e=(container.style.display=="none");if(e||$.data(img,"original")!=f){var b=findthumb(f);if(b!=undefined&&($.data(img,"original")!=$.data(b,"original")||e)){openpic(b)}}}}if(c=="info"){if(f=="true"&&!info){infolay.classList.remove("closed");info=true}else{if(f=="false"&&info){infolay.classList.add("closed");info=false}}}if(c=="preload"){if(f=="false"||f==false){preload=false}if(f=="true"||f==true){preload=true}}if(c=="overview"){if(f=="true"||f==true){if(container.style.display!="none"){container.click()}}}}}}}function winwidth(){var b=window,h=document,f=h.documentElement,c=h.getElementsByTagName("body")[0],a=b.innerWidth||f.clientWidth||c.clientWidth;return a}function kinput(f){var c=f.target,d=c.contentEditable,a=c.tagName,b=f.keyCode||f.which;if(!d||a!="SPAN"){if(b==105){infooverlay()}if(b==102){fs()}if(b==27){f.preventDefault();container.click()}if(b==39||b==110){next()}if(b==37||b==112){prev()}if(b==8||b==46){f.preventDefault();del()}}if(d&&a=="SPAN"){if(b==13){f.preventDefault();c.blur()}}}function addimg(a){var b=CE("img");if(thumbsize!=0){b.src="download.php/resize/"+(parseInt(thumbsize)+(parseInt(thumbsize)/10))+"/"+a;b.style.width=thumbsize+"px"}else{b.src=smalldev?"download.php/resize/110/"+a:"thumbs.dir/"+a+".jpg";b.style.width="19%"}$.data(b,"original",a);b.classList.add("image");b.addEventListener("click",openpic);grid.appendChild(b)}function openpic(h){if(this.tagName=="IMG"){h=this}if(h==undefined){console.warn("srcthumb is undefined");return}url=$.data(h,"original");var a=false,A=imgs[url];if(substr(A,0,4)=="blob"){console.info("Reading image "+url+" from "+A);img.src=A;a=true}else{if(realsize==0){img.src=url}else{if(realsize=="dyn"){img.src="download.php/resize/"+(smalldev?winwidth()*4:(winwidth()/100)*95)+"/"+url}else{img.src="download.php/resize/"+realsize+"/"+url}}}$.data(img,"original",url);location.hash="#!image="+basename(url)+(info?",info=true":"");container.style.display="";infobut.style.display="";while(infolay.firstChild){infolay.removeChild(infolay.firstChild)}var E=mdata[url]!=undefined?mdata[url]:json_decode(file_get_contents("download.php/exif/"+url)),g="";var v=E.meta,j="";if(v==false){v={}}if("title" in v&&v.title!=""){j+=v.title}else{j+="Unbenannt"}var e=CE("span");e.appendChild(document.createTextNode(j));if(features.renaming){e.contentEditable=true}e.id="title";e.addEventListener("blur",update);var r=CE("span");r.id="upby";r.appendChild(document.createTextNode("upby" in v&&v.upby!=""?v.upby:"Unbekannt"));if(features.renaming){r.contentEditable=true}r.addEventListener("blur",update);var q=CE("span"),b="description" in v&&v.description!=""?v.description:"Unbeschrieben";q.id="description";q.addEventListener("blur",update);q.appendChild(document.createTextNode(b));if(features.renaming){q.contentEditable=true}infolay.appendChilds(e,document.createTextNode(" von "),r,document.createTextNode(": "),q);if(E!=false&&E!=null){var u=E.width,n=E.height,c=E.make,d=E.model,s=E.GPS,C=E.date,B=E.ISO,k=E.aperture,D=E.exposure,f=E.filesize,p=E.flash,o=E.software;if(C!=false){g+=", fotografiert am "+C}if(C!=false&&c!=false&&d!=false){var y=c+" "+d;if(c==d){y=d}if(d.indexOf(c)!=-1){y=d}g+=", mit einer / einem "+y}else{if(c!=false&&d!=false){var y=c+" "+d;if(c==d){y=d}if(d.indexOf(c)!=-1){y=d}g+=", fotografiert mit einer / einem "+y}}if(B!=false){g+=", ISO: "+B}if(k!=false){g+=", Blende: "+k}if(D!=false){g+=", Belichtungszeit: "+D}if(p!=false){g+=", Blitz aktiviert"}if(f!=false){g+=", Dateigröße: "+f}if(u!=false&&n!=false){g+=", Abmessungen: "+u+"x"+n}if(o!=false&&o!=null){g+=", software: "+o}infolay.appendChild(document.createTextNode(g+" "));var x=CE("a");x.download=url;x.href=a?A:url;x.appendChild(document.createTextNode("In Originalgröße downloaden"));infolay.appendChild(x);if(s!=false){var z=CE("a");z.target="_blank";z.href="//maps.apple.com/?q="+urlencode(s);z.appendChild(document.createTextNode("Ort in Karten öffnen"));infolay.appendChild(z)}if(features.deleting){infolay.appendChild(document.createTextNode(" "));var l=CE("button");l.addEventListener("click",del);l.classList.add("delbut");l.appendChild(document.createTextNode("Löschen"));infolay.appendChild(l)}}}function infooverlay(){infolay.classList.toggle("closed");info=infolay.classList.contains("closed")?false:true;if(container.style.display!="none"){location.hash="#!image="+url+(info?",info=true":"")}}function findthumb(b){var a=document.getElementsByClassName("image");for(i=0;i0&&!busy){busy=true;rawViewer.readFile(raws[0],parsed)}setTimeout(rawloop,3000)}if(typeof HTMLElement.prototype.remove!="function"){HTMLElement.prototype.remove=function(){$(this).remove()}}function back(){img.classList.remove("move");img.classList.add("cent");img.style.top="50%";img.classList.add("move");img.style.left="50%"}function init(){window.thumbsize=0;window.svg=typeof SVGRect!="undefined"&&window.navigator.userAgent.indexOf("Windows")<0?true:false;window.realsize="dyn";window.argr="";window.args=[];window.info=false;window.smalldev=$(window).width()<768;window.preload=smalldev?false:true;window.loaded=false;window.url="";window.grid=CE("div");window.container=CE("div");window.desc=CE("span");window.prevb=CE("img");window.nextb=CE("img");window.img=CE("img");window.mdata={};window.empty;window.prog=CE("span");window.uploads={active:0,queued:0};window.raws=[];window.busy=false;window.upname="";window.xhr=function(){return window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")};prog.id="progress";container.id="bigpic";container.style.cursor="pointer";container.style.display="none";container.addEventListener("click",iclick);prevb.src=svg?"icons/prev.svg":"icons/prev.png";prevb.classList.add("prev");prevb.classList.add("symbol");prevb.classList.add("vertcent");prevb.style.width="10%";prevb.addEventListener("click",prev);nextb.src=svg?"icons/next.svg":"icons/next.png";nextb.classList.add("next");nextb.classList.add("symbol");nextb.classList.add("vertcent");nextb.style.width="10%";nextb.addEventListener("click",next);img.classList.add("largepic");img.classList.add("cent");img.addEventListener("dblclick",fs);window.infobut=CE("img");infobut.src=svg?"icons/info.svg":"icons/info.png";infobut.classList.add("symbol");infobut.style.width="7%";infobut.style.bottom="2%";infobut.addEventListener("click",infooverlay);infobut.classList.add("horcent");window.infolay=CE("div");infolay.classList.add("infolay");infolay.classList.add("horcent");infolay.classList.add("closed");container.appendChilds(prevb,nextb,img,infobut,infolay);document.body.appendChilds(prog,grid,container);imgs.forEach(addimg);ety();lhash();startWorker();update_progress();rawloop();window.addEventListener("keypress",kinput);var o=false,r=false;$(img).draggable({start:function(){img.classList.remove("cent");img.classList.remove("move");o=false},drag:function(e){if(e.clientX<(winwidth()/100)*10){o=true;r=false}if(e.clientX>(winwidth()/100)*90){o=true;r=true}},stop:function(){img.style.width="";if(!o){back()}else{img.classList.add("move");if(!r){img.style.left=-winwidth()+"px";setTimeout(prev,500);setTimeout("img.classList.remove('move');img.style.left = winwidth()+'px'",500);setTimeout(back,1000)}else{img.style.left=winwidth()+"px";setTimeout(next,500);setTimeout("img.classList.remove('move');img.style.left = -winwidth()+'px'",500);setTimeout(back,1000)}}},axis:"x"});if(features.uploading){var upbut=document.querySelector(".upload");document.querySelector(".fileUpload").style.display="";upbut.addEventListener("change",fqueue);document.body.addEventListener("dragover",function(e){e.preventDefault()});document.body.addEventListener("drop",fqueue)}if(!features.srs){var x=new xhr();x.open("GET","raw.min.js",false);x.send();eval(x.responseText);window.rawViewer=new Rawson.Viewer("preview",{formats:{read:["RAW"]},controls:[new Rawson.Control.FileProgress()]})}if(features.srs==undefined){var x=new xhr();x.open("GET","download.php/rawtest",true);x.addEventListener("readystatechange",function(){if(this.readyState==4&&this.status==200){this.response=="true"?features.srs=true:features.srs=false}});x.send()}}; \ No newline at end of file +function fqueue(d){d.preventDefault();var c=d.target.files!=undefined?d.target.files:d.dataTransfer.files,b=0;for(;bc){b.height*=c/b.width;b.width=c}var j=CE("canvas"),h=j.getContext("2d");h.clearRect(0,0,j.width,j.height);j.width=b.width;j.height=b.height;h.drawImage(b,0,0,b.width,b.height);stackBlurCanvasRGBA(j,0,0,b.width,b.height,10);h.font=(b.height/100)*12+"px Ubuntu";h.fillInversedText("Uploading image...",(b.width/100)*15,(b.height/100)*50);var g=j.toDataURL(),k=new Image();j.remove();b.remove();k.src=g;k.classList.add("image");k.style.maxWidth="19%";k.style.cursor="progress";grid.appendChild(k);if(typeof window.scrollTo=="function"){window.scrollTo(0,$(k).offset().top)}uploads[d]={binary:f,fname:e,date:a,uploaded:0,uploading:false,thumbnail:k,id:d};uploads.queued++})}function startWorker(){if(typeof(Worker)!=="undefined"&&typeof(w)=="undefined"&&preload){w=new Worker("preload.min.js");w.onmessage=function(c){var d=basename(c.data[1]),a=c.data[0];var b=(window.URL||window.webkitURL).createObjectURL(a);imgs[d]=b;mdata[d]=json_decode(c.data[2]);console.info("WebWorker has successfully downloaded "+d+" to "+b)};w.postMessage(imgs);console.info("Preload WebWorker started")}}function update(){var b=new xhr(),a=url;b.open("GET","download.php/rename/"+a+"/"+this.id+"/"+this.textContent,true);b.addEventListener("readystatechange",function(){if(this.readyState==4&&this.status==200){if(!json_decode(this.responseText).success){alert("Something went wrong while renaming")}var c=new xhr();c.open("GET","download.php/exif/"+a+"?"+rand(),false);c.send();mdata[a]=json_decode(c.response)}});b.send()}function lhash(){requestAnimationFrame(lhash);var g=location.hash;if(g[1]=="!"){if(g.length<=2){console.warn("No arguments provided but #!. Stopping.")}else{argr=substr(g,2);args=explode(",",argr);for(var d=0;d2){console.warn("Multiple values specified, using first one")}if(c=="ts"){if(f!=""){thumbsize=f}}if(c=="rs"){if(f!=""){realsize=f}}if(c=="image"){if(f!=""&&f!=undefined){var e=(container.style.display=="none");if(e||$.data(img,"original")!=f){var b=findthumb(f);if(b!=undefined&&($.data(img,"original")!=$.data(b,"original")||e)){openpic(b)}}}}if(c=="info"){if(f=="true"&&!info){infolay.classList.remove("closed");info=true}else{if(f=="false"&&info){infolay.classList.add("closed");info=false}}}if(c=="preload"){if(f=="false"||f==false){preload=false}if(f=="true"||f==true){preload=true}}if(c=="overview"){if(f=="true"||f==true){if(container.style.display!="none"){container.click()}}}}}}}function winwidth(){var b=window,h=document,f=h.documentElement,c=h.getElementsByTagName("body")[0],a=b.innerWidth||f.clientWidth||c.clientWidth;return a}function kinput(f){var c=f.target,d=c.contentEditable,a=c.tagName,b=f.keyCode||f.which;if(!d||a!="SPAN"){if(b==105){infooverlay()}if(b==102){fs()}if(b==27){f.preventDefault();container.click()}if(b==39||b==110){next()}if(b==37||b==112){prev()}if(b==8||b==46){f.preventDefault();del()}}if(d&&a=="SPAN"){if(b==13){f.preventDefault();c.blur()}}}function addimg(a){var b=CE("img");if(thumbsize!=0){b.src="download.php/resize/"+(parseInt(thumbsize)+(parseInt(thumbsize)/10))+"/"+a;b.style.width=thumbsize+"px"}else{b.src=smalldev?"download.php/resize/110/"+a:"thumbs.dir/"+a+".jpg";b.style.width="19%"}$.data(b,"original",a);b.classList.add("image");b.addEventListener("click",openpic);grid.appendChild(b)}function openpic(h){if(this.tagName=="IMG"){h=this}if(h==undefined){console.warn("srcthumb is undefined");return}url=$.data(h,"original");var a=false,A=imgs[url];if(substr(A,0,4)=="blob"){console.info("Reading image "+url+" from "+A);img.src=A;a=true}else{if(realsize==0){img.src=url}else{if(realsize=="dyn"){img.src="download.php/resize/"+(smalldev?winwidth()*4:(winwidth()/100)*95)+"/"+url}else{img.src="download.php/resize/"+realsize+"/"+url}}}$.data(img,"original",url);location.hash="#!image="+basename(url)+(info?",info=true":"");container.style.display="";infobut.style.display="";while(infolay.firstChild){infolay.removeChild(infolay.firstChild)}var E=mdata[url]!=undefined?mdata[url]:json_decode(file_get_contents("download.php/exif/"+url)),g="";var v=E.meta,j="";if(v==false){v={}}if("title" in v&&v.title!=""){j+=v.title}else{j+="Unbenannt"}var e=CE("span");e.appendChild(document.createTextNode(j));if(features.renaming){e.contentEditable=true}e.id="title";e.addEventListener("blur",update);var r=CE("span");r.id="upby";r.appendChild(document.createTextNode("upby" in v&&v.upby!=""?v.upby:"Unbekannt"));if(features.renaming){r.contentEditable=true}r.addEventListener("blur",update);var q=CE("span"),b="description" in v&&v.description!=""?v.description:"Unbeschrieben";q.id="description";q.addEventListener("blur",update);q.appendChild(document.createTextNode(b));if(features.renaming){q.contentEditable=true}infolay.appendChilds(e,document.createTextNode(" von "),r,document.createTextNode(": "),q);if(E!=false&&E!=null){var u=E.width,n=E.height,c=E.make,d=E.model,s=E.GPS,C=E.date,B=E.ISO,k=E.aperture,D=E.exposure,f=E.filesize,p=E.flash,o=E.software;if(C!=false){g+=", fotografiert am "+C}if(C!=false&&c!=false&&d!=false){var y=c+" "+d;if(c==d){y=d}if(d.indexOf(c)!=-1){y=d}g+=", mit einer / einem "+y}else{if(c!=false&&d!=false){var y=c+" "+d;if(c==d){y=d}if(d.indexOf(c)!=-1){y=d}g+=", fotografiert mit einer / einem "+y}}if(B!=false){g+=", ISO: "+B}if(k!=false){g+=", Blende: "+k}if(D!=false){g+=", Belichtungszeit: "+D}if(p!=false){g+=", Blitz aktiviert"}if(f!=false){g+=", Dateigröße: "+f}if(u!=false&&n!=false){g+=", Abmessungen: "+u+"x"+n}if(o!=false&&o!=null){g+=", software: "+o}infolay.appendChild(document.createTextNode(g+" "));var x=CE("a");x.download=url;x.href=a?A:url;x.appendChild(document.createTextNode("In Originalgröße downloaden"));infolay.appendChild(x);if(s!=false){var z=CE("a");z.target="_blank";z.href="//maps.apple.com/?q="+urlencode(s);z.appendChild(document.createTextNode("Ort in Karten öffnen"));infolay.appendChild(z)}if(features.deleting){infolay.appendChild(document.createTextNode(" "));var l=CE("button");l.addEventListener("click",del);l.classList.add("delbut");l.appendChild(document.createTextNode("Löschen"));infolay.appendChild(l)}}}function infooverlay(){infolay.classList.toggle("closed");info=infolay.classList.contains("closed")?false:true;if(container.style.display!="none"){location.hash="#!image="+url+(info?",info=true":"")}}function findthumb(b){var a=document.getElementsByClassName("image");for(i=0;i0&&!busy){busy=true;rawViewer.readFile(raws[0],parsed)}setTimeout(rawloop,3000)}if(typeof HTMLElement.prototype.remove!="function"){HTMLElement.prototype.remove=function(){$(this).remove()}}function back(){img.classList.remove("move");img.classList.add("cent");img.style.top="50%";img.classList.add("move");img.style.left="50%"}function init(){window.thumbsize=0;window.svg=typeof SVGRect!="undefined"&&window.navigator.userAgent.indexOf("Windows")<0?true:false;window.realsize="dyn";window.argr="";window.args=[];window.info=false;window.smalldev=$(window).width()<768;window.preload=smalldev?false:true;window.loaded=false;window.url="";window.grid=CE("div");window.container=CE("div");window.desc=CE("span");window.prevb=CE("img");window.nextb=CE("img");window.img=CE("img");window.mdata={};window.empty;window.prog=CE("span");window.uploads={active:0,queued:0};window.raws=[];window.busy=false;window.upname="";window.xhr=function(){return window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("Microsoft.XMLHTTP")};prog.id="progress";container.id="bigpic";container.style.cursor="pointer";container.style.display="none";container.addEventListener("click",iclick);prevb.src=svg?"icons/prev.svg":"icons/prev.png";prevb.classList.add("prev");prevb.classList.add("symbol");prevb.classList.add("vertcent");prevb.style.width="10%";prevb.addEventListener("click",prev);nextb.src=svg?"icons/next.svg":"icons/next.png";nextb.classList.add("next");nextb.classList.add("symbol");nextb.classList.add("vertcent");nextb.style.width="10%";nextb.addEventListener("click",next);img.classList.add("largepic");img.classList.add("cent");img.addEventListener("dblclick",fs);window.infobut=CE("img");infobut.src=svg?"icons/info.svg":"icons/info.png";infobut.classList.add("symbol");infobut.style.width="7%";infobut.style.bottom="2%";infobut.addEventListener("click",infooverlay);infobut.classList.add("horcent");window.infolay=CE("div");infolay.classList.add("infolay");infolay.classList.add("horcent");infolay.classList.add("closed");container.appendChilds(prevb,nextb,img,infobut,infolay);document.body.appendChilds(prog,grid,container);imgs.forEach(addimg);ety();lhash();startWorker();update_progress();rawloop();window.addEventListener("keypress",kinput);var o=false,r=false;$(img).draggable({start:function(){img.classList.remove("cent");img.classList.remove("move");o=false},drag:function(e){if(e.clientX<(winwidth()/100)*10){o=true;r=false}if(e.clientX>(winwidth()/100)*90){o=true;r=true}},stop:function(){img.style.width="";if(!o){back()}else{img.classList.add("move");if(!r){img.style.left=-winwidth()+"px";setTimeout(prev,500);setTimeout("img.classList.remove('move');img.style.left = winwidth()+'px'",500);setTimeout(back,1000)}else{img.style.left=winwidth()+"px";setTimeout(next,500);setTimeout("img.classList.remove('move');img.style.left = -winwidth()+'px'",500);setTimeout(back,1000)}}},axis:"x"});if(features.uploading){var upbut=document.querySelector(".upload");document.querySelector(".fileUpload").style.display="";upbut.addEventListener("change",fqueue);document.body.addEventListener("dragover",function(e){e.preventDefault()});document.body.addEventListener("drop",fqueue)}if(!features.srs){var x=new xhr();x.open("GET","raw.min.js",false);x.send();eval(x.responseText);window.rawViewer=new Rawson.Viewer("preview",{formats:{read:["RAW"]},controls:[new Rawson.Control.FileProgress()]})}if(features.srs==undefined){var x=new xhr();x.open("GET","download.php/rawtest",true);x.addEventListener("readystatechange",function(){if(this.readyState==4&&this.status==200){this.response=="true"?features.srs=true:features.srs=false}});x.send()}}; \ No newline at end of file