/*イメージビューワー*/ //postのimg.jsとは異なります。 function imgv(id, key, acct_id) { $("#imgprog").text(0); $('#imgmodal').hide(); $('#imgmodal').attr('src', '../../img/loading.svg'); var murl = $("#" + id + "-image-" + key).attr("data-url"); var type = $("#" + id + "-image-" + key).attr("data-type"); $("#imagemodal").attr("data-id",id); $("#imagemodal").attr("data-acct",acct_id); $(document).ready(function() { if (type == "image") { $('#imagemodal').modal('open'); xhr = new XMLHttpRequest; xhr.open('GET', murl, true); xhr.addEventListener('progress', function (event) { if (event.lengthComputable) { var total=event.total; var now=event.loaded; var per=now/total*100; $("#imgprog").text(Math.floor(per)); } }, false); xhr.addEventListener('loadend', function (event) { var total=event.total; var now=event.loaded; var per=now/total*100; $("#imgprog").text(Math.floor(per)); }, false); xhr.send(); $('#imgmodal').attr('src', murl); $('#imagewrap').dragScroll(); // ドラッグスクロール設定 $('#imgmodal').show(); $('#imagemodal').attr('data-key', key); $('#imagemodal').attr('data-id', id); } else if (type == "video" || type == "gifv") { $('#video').attr('src', murl); $('#videomodal').modal('open'); $('#imgmodal').show(); } var element = new Image(); var width; element.onload = function() { var width = element.naturalWidth; var height = element.naturalHeight; var windowH = $(window).height(); var windowW = $(window).width(); $("#imagemodal").css("bottom","0") $("#imagemodal img").css("width","auto") if(heightwindowW*0.8){ $("#imagemodal").css("width","80vw") $("#imagemodal img").css("width","100%") var heightS=windowW*0.8/width*height; $("#imagemodal").css("height",heightS+60+"px") }else{ $("#imagemodal").css("width",width+"px") } }else{ console.log("long") $("#imagemodal img").css("width","auto") var widthS=windowH/height*width; if(widthSwindowW*0.8){ $("#imagemodal").css("width","80vw") $("#imagemodal img").css("width","100%") var heightS=windowW*0.8/width*height; $("#imagemodal").css("height",heightS+60+"px") }else{ $("#imagemodal").css("width",width+"px") } }else{ console.log("long") $("#imagemodal img").css("width","auto") var widthS=windowH/height*width; if(widthS 0) { zoom(1.1) } else { zoom(0.9) } } //当該トゥート function detFromImg(){ var id=$("#imagemodal").attr("data-id"); var acct_id=$("#imagemodal").attr("data-acct"); $('#imagemodal').modal('close'); details(id,acct_id); } //画像保存 function dlImg(){ var url=$("#imgmodal").attr("src"); var electron = require("electron"); var ipc = electron.ipcRenderer; if(localStorage.getItem("savefolder")){ var save=localStorage.getItem("savefolder"); }else{ var save=""; } ipc.send('general-dl', [url,save,false]); ipc.on('general-dl-prog', function (event, arg) { console.log(arg); }) ipc.on('general-dl-message', function (event, arg) { var argC=arg.replace(/\\/g,"\\\\")+"\\\\."; Materialize.toast(lang.lang_img_DLDone+arg+'', 5000); }) } function openFinder(dir){ ipc.send('open-finder', dir); }