TheDesk Mio (15.7.0)

This commit is contained in:
cutls
2018-06-17 23:26:45 +09:00
parent a8e0133edb
commit f42f6e2572
21 changed files with 426 additions and 267 deletions

View File

@@ -210,10 +210,12 @@ function cbCopy(mode){
//本文のコピー
function staCopy(id){
var html=$("[toot-id="+id+"] .toot").html();
html = html.match(/^<p>(.+)<\/p>$/)[1];
html = html.replace(/^<p>(.+)<\/p>$/,"$1");
html = html.replace(/<br\s?\/?>/, "\n");
html = html.replace(/<p>/, "\n");
html = html.replace(/<\/p>/, "\n");
console.log(html);
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, "$1");
html=$.strip_tags(html);
if(execCopy(html)){
Materialize.toast("トゥート本文をコピーしました", 1500);
@@ -222,14 +224,49 @@ function staCopy(id){
}
//魚拓
function shot(){
var id=$("#tootmodal").attr("data-id");
var w=$("#toot-this").width();
var h=$("#toot-this").height()+150;
var text=$("#toot-this").html();
localStorage.setItem("sc-text",text)
var title=$("#tootmodal").attr("data-id");
var off = $('#toot-this').offset();
var w=$("#toot-this").width()+50;
var h=$("#toot-this").height()+50;
var electron = require("electron");
const fs = require("fs");
const os = require('os')
const shell = electron.shell;
const path = require('path')
var ipc = electron.ipcRenderer;
ipc.send('screen', [w,h,id]);
let options = {
types: ['screen'],
thumbnailSize: {
width: window.parent.screen.width,
height: window.parent.screen.height
}
}
const desktopCapturer = electron.desktopCapturer;
desktopCapturer.getSources(options, function(error, sources) {
if (error) return console.log(error)
sources.forEach(function(source) {
if (source.name === 'Screen 1' || source.name === 'TheDesk') {
var durl=source.thumbnail.toDataURL();
var b64 = durl.match(
/data:image\/png;base64,(.+)/
);
const screenshotPath = path.join(os.tmpdir(), 'screenshot.png');
const savePath = path.join(os.tmpdir(), 'screenshot.png');
var ipc = electron.ipcRenderer;
ipc.send('shot', ['file://' + screenshotPath,w,h,b64[1],title,off.top+50,off.left]);
if($("#toot-this .img-parsed").length>0){
for(i=0;i<$("#toot-this .img-parsed").length;i++){
var url=$("#toot-this .img-parsed").eq(i).attr("data-url");
ipc.send('shot-img-dl', [url,title+"_img"+i+".png"]);
}
}
return;
const message = `Saved screenshot to: ${screenshotPath}`
//screenshotMsg.textContent = message
}
})
})
}
//翻訳
function trans(tar){

View File

@@ -36,7 +36,7 @@ function mixtl(acct_id, tlid, type) {
var homearr=[];
var timeline = jsonL.concat(jsonH);
timeline.sort(function(a,b){
if(date(a.created_at,"unix")>date(b.created_at,"unix")) return -1;
if(date(a.created_at,"unix")>=date(b.created_at,"unix")) return -1;
if(date(a.created_at,"unix")<date(b.created_at,"unix")) return 1;
return 0;
});
@@ -85,15 +85,15 @@ function mixre(acct_id, tlid, TLtype) {
websocketHome[wshid] = new WebSocket(startHome);
websocketLocal[wslid] = new WebSocket(startLocal);
websocketHome[wshid].onopen = function(mess) {
console.log("Connect Streaming API(Home)");
console.log("Connect Streaming API(Integrated:Home)");
$("#notice_icon_" + tlid).removeClass("red-text");
}
websocketLocal[wslid].onopen = function(mess) {
console.log("Connect Streaming API(Local)");
console.log("Connect Streaming API(Integrated:Local)");
$("#notice_icon_" + tlid).removeClass("red-text");
}
websocketLocal[wslid].onmessage = function(mess) {
console.log("Receive Streaming API:");
console.log("Receive Streaming API:(Integrated:Local)");
var obj = JSON.parse(JSON.parse(mess.data).payload);
console.log(obj);
@@ -103,12 +103,14 @@ function mixre(acct_id, tlid, TLtype) {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") {
var templete = parse([obj], '', acct_id, tlid);
if (!$("[toot-id="+obj.id+"]").length) {
if (!$("#timeline_"+tlid+" [toot-id="+obj.id+"]").length) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
if (pool && templete) {
pool = templete + pool;
} else {
} else if (templete) {
pool = templete
}else{
pool="";
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();
@@ -118,7 +120,7 @@ function mixre(acct_id, tlid, TLtype) {
}}
}
websocketHome[wshid].onmessage = function(mess) {
console.log("Receive Streaming API:(Home)");
console.log("Receive Streaming API:(Integrated:Home)");
var obj = JSON.parse(JSON.parse(mess.data).payload);
console.log(obj);
@@ -136,12 +138,14 @@ function mixre(acct_id, tlid, TLtype) {
var templete="";
}
}
if (!$("[toot-id="+obj.id+"]").length) {
if (!$("#timeline_"+tlid+" [toot-id="+obj.id+"]").length) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
if (pool && templete) {
pool = templete + pool;
} else {
} else if (templete) {
pool = templete
}else{
pool="";
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();

View File

@@ -135,7 +135,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
'" class="emoji-img" data-emoji="'+shortcode+'">';
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
@@ -208,7 +208,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
'" class="emoji-img" data-emoji="'+shortcode+'">';
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
@@ -239,7 +239,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
'" class="emoji-img" data-emoji="'+shortcode+'">';
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
@@ -345,7 +345,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
'" class="emoji-img" data-emoji="'+shortcode+'">';
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
@@ -623,7 +623,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url +
'" class="emoji-img" data-emoji="'+shortcode+'">';
'" class="emoji-img" data-emoji="'+shortcode+'" alt=" :'+shortcode+': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});