Change: markers API trigger

This commit is contained in:
Cutls 2019-09-22 19:55:59 +09:00
parent 8c29f21970
commit f2ec258e7a
10 changed files with 144 additions and 43 deletions

View File

@ -107,6 +107,8 @@ var lang={
"lang_tags_tagwarn": "Автоматично попълване на {{tag}}, ако раздумката няма {{tag}}",
"lang_tl_media": "Media",
"lang_tl_reconnect": "Reconnect to streaming API",
"lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait",
"lang_img_DLDone": "Downloaded:",
"lang_layout_gotop": "Go top of this column. When icon is red, this column cannot connect straming API. Please reload.",
"lang_layout_thisacct": "{{notf}} of this account",

View File

@ -107,6 +107,8 @@ var lang={
"lang_tags_tagwarn": "Auto complete {{tag}}, if toot without {{tag}}",
"lang_tl_media": "Média",
"lang_tl_reconnect": "Reconnect to streaming API",
"lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait",
"lang_img_DLDone": "Downloaded:",
"lang_layout_gotop": "Go top of this column. When icon is red, this column cannot connect straming API. Please reload.",
"lang_layout_thisacct": "{{notf}} tohoto účtu",

View File

@ -107,6 +107,8 @@ var lang={
"lang_tags_tagwarn": "Automatisch {{tag}} anfügen, wenn Tröt ohne {{tag}} ist",
"lang_tl_media": "Medien",
"lang_tl_reconnect": "Mit Streaming API erneut verbinden",
"lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait",
"lang_img_DLDone": "Heruntergeladen:",
"lang_layout_gotop": "Gehen Sie zum Anfang dieser Spalte. Wenn das Symbol rot ist, kann diese Spalte keine Verbindung zur Streaming-API herstellen. Bitte neu laden.",
"lang_layout_thisacct": "{{notf}} dieses Kontos",

View File

@ -131,6 +131,8 @@ var lang = {
//tl/tl.js
"lang_tl_media": "Media",
"lang_tl_reconnect": "Reconnect to streaming API",
"lang_tl_postmarkers_title": "Process...",
"lang_tl_postmarkers": "POST markers data. Please wait",
//ui/img.js
"lang_img_DLDone": "Downloaded:",
//ui/layout.js

View File

@ -131,6 +131,8 @@ var lang = {
//tl/tl.js
"lang_tl_media": "メディア",
"lang_tl_reconnect": "Streamingに再接続しました",
"lang_tl_postmarkers_title": "処理中",
"lang_tl_postmarkers": "未読マーカーを送信しています。3秒以内に閉じられます。",
//ui/img.js
"lang_img_DLDone": "ダウンロード先:",
//ui/layout.js

View File

@ -183,6 +183,10 @@ onmessage = function (e) {
updateMess(e.data[1]);
} else if (e.data[0] == "renderAbout") {
renderAbout(e.data[1]);
} else if (e.data[0] == "asRead") {
asRead()
} else if (e.data[0] == "asReadEnd") {
asReadEnd()
} else if (e.data[0] == "alert") {
Swal.fire({
type: 'info',

View File

@ -57,6 +57,8 @@ onmessage = function (e) {
ipc.send('download-btn', e.data[1]);
} else if (e.data[0] == "nano") {
ipc.send('nano', null);
} else if (e.data[0] == "asReadComp") {
ipc.send('sendMarkersComplete', null);
}
}
//version.js
@ -164,6 +166,12 @@ ipc.on('prog', function (event, arg) {
ipc.on('mess', function (event, arg) {
postMessage(["updateMess", arg], "*")
})
ipc.on('asRead', function (event, arg) {
postMessage(["asRead", ""], "*")
})
ipc.on('asReadEnd', function (event, arg) {
postMessage(["asReadEnd", ""], "*")
})
var webviewDom = document.getElementById('webview');
if (webviewDom) {
webviewDom.addEventListener('new-window', function (e) {

View File

@ -999,24 +999,24 @@ function ueload(tlid) {
columnReload(tlid, type)
}
if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type)
} else {
var mute = [];
var mute = []
}
var templete = parse(json, '', acct_id, tlid, "", mute, type);
var templete = parse(json, '', acct_id, tlid, "", mute, type)
var len = json.length - 1
$("#timeline_" + tlid).prepend(templete);
$("#timeline_" + tlid).prepend(templete)
if ($("#timeline_" + tlid + " .cvo:eq(" + len + ")").length) {
var to = $("#timeline_" + tlid + " .cvo:eq(" + len + ")").offset().top
$("#timeline_box_" + tlid + "_box .tl-box").scrollTop(to)
}
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
todc();
additional(acct_id, tlid)
jQuery("time.timeago").timeago()
todc()
ueloadlock = false
});
}
function asRead() {
function asRead(callback) {
//Markers
var markers = localStorage.getItem("markers");
if (markers == "no") {
@ -1027,7 +1027,9 @@ function asRead() {
if (markers) {
var multi = localStorage.getItem("column")
var obj = JSON.parse(multi)
for (var i = 0; i < obj.length; i++) {
var obl = obj.length
ct = 0
for (var i = 0; i < obl; i++) {
var acct_id = obj[i].domain
var type = obj[i].type
if (type == "home" || type == "notf") {
@ -1046,23 +1048,53 @@ function asRead() {
}
}
}
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var httpreq = new XMLHttpRequest();
var domain = localStorage.getItem("domain_" + acct_id)
var at = localStorage.getItem("acct_" + acct_id + "_at")
var httpreq = new XMLHttpRequest()
var start = "https://" + domain + "/api/v1/markers"
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');
httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
httpreq.responseType = "json";
httpreq.send(JSON.stringify(poster));
httpreq.open('POST', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = "json"
httpreq.send(JSON.stringify(poster))
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
var json = httpreq.response
console.log(json)
ct++
if (ct == obl && callback) {
postMessage(["asReadComp", ""], "*")
}
}
}
}
}
}
}
cbTimer1 = setInterval(asRead, 60000);
function asReadEnd() {
//Markers
var markers = localStorage.getItem("markers");
if (markers == "no") {
markers = false;
} else {
markers = true
}
if (markers) {
asRead(true)
Swal.fire({
title: lang.lang_tl_postmarkers_title,
html: lang.lang_tl_postmarkers,
timer: 3000,
onBeforeOpen: () => {
Swal.showLoading()
},
onClose: () => {
}
}).then((result) => {
})
} else {
postMessage(["asReadComp", ""], "*")
}
}

View File

@ -12,6 +12,7 @@ const np = require('./main/np.js');
const systemFunc = require('./main/system.js');
const Menu = electron.Menu
const join = require('path').join;
// アプリケーションをコントロールするモジュール
const app = electron.app;
// ウィンドウを作成するモジュール
@ -29,8 +30,8 @@ if (!gotTheLock) {
// 多重起動を試みた場合、既に存在するウィンドウにフォーカスを移す
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
if (mainWindow.isMinimized()) mainWindow.restore()
mainWindow.focus()
}
})
}
@ -40,18 +41,18 @@ if (process.argv.indexOf("--dev") === -1) {
} else {
var packaged = false;
console.log(
"||\\\\\\ \n"+
"|||| \\\\\\\\ \n"+
"|||| \\\\\\\\ \n"+
"|||| Am I a \\\\\\\\ \n"+
"|||| cat? ^ ^ \\\\\\\\\\ _____ _ ____ _ \n"+
"|||| (.-.) \\\\\\\\\\ |_ _| |__ ___| _ \\ ___ ___| | __\n"+
"|||| ___> ) ||||| | | | '_ \\ / _ \\ | | |/ _ \\/ __| |/ /\n"+
"|||| < _ _) ////// | | | | | | __/ |_| | __/\__ \\ < \n"+
"|||| |_||_| ///// |_| |_| |_|\\___|____/ \\___||___/_|\\_\\ \n"+
"|||| ///// \n"+
"|||| /////\n"+
"|||| /////\n"+
"||\\\\\\ \n" +
"|||| \\\\\\\\ \n" +
"|||| \\\\\\\\ \n" +
"|||| Am I a \\\\\\\\ \n" +
"|||| cat? ^ ^ \\\\\\\\\\ _____ _ ____ _ \n" +
"|||| (.-.) \\\\\\\\\\ |_ _| |__ ___| _ \\ ___ ___| | __\n" +
"|||| ___> ) ||||| | | | '_ \\ / _ \\ | | |/ _ \\/ __| |/ /\n" +
"|||| < _ _) ////// | | | | | | __/ |_| | __/\__ \\ < \n" +
"|||| |_||_| ///// |_| |_| |_|\\___|____/ \\___||___/_|\\_\\ \n" +
"|||| ///// \n" +
"|||| /////\n" +
"|||| /////\n" +
"||||//////"
)
console.log("Welcome!")
@ -63,9 +64,9 @@ var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
try {
fs.readFileSync(ha_path, 'utf8');
app.disableHardwareAcceleration()
if(!packaged) console.log("disabled: Hardware Acceleration");
if (!packaged) console.log("disabled: Hardware Acceleration");
} catch{
if(!packaged) console.log("enabled: Hardware Acceleration");
if (!packaged) console.log("enabled: Hardware Acceleration");
}
var window_size;
try {
@ -131,8 +132,8 @@ function createWindow() {
fs.writeFileSync(lang_path, lang);
});
}
if(!packaged) console.log("your lang:" + app.getLocale());
if(!packaged) console.log("launch:" + lang);
if (!packaged) console.log("your lang:" + app.getLocale());
if (!packaged) console.log("launch:" + lang);
// メイン画面の表示。ウィンドウの幅、高さを指定できる
var platform = process.platform;
var bit = process.arch;
@ -173,7 +174,7 @@ function createWindow() {
if (window_size.max) {
mainWindow.maximize();
}
})
})
electron.session.defaultSession.clearCache(() => { })
if (process.argv) {
if (process.argv[1]) {
@ -200,7 +201,27 @@ function createWindow() {
electron.ipcMain.removeAllListeners();
mainWindow = null;
});
mainWindow.on('close', function () {
closeArg = false
mainWindow.on('close', function (e, arg) {
if(!closeArg){
e.preventDefault()
}
const promise = new Promise(function (resolve) {
mainWindow.webContents.send('asReadEnd', "")
setTimeout(function () { resolve() }, 3000)
})
promise.then((function (response) {
writePos(mainWindow)
closeArg = true
mainWindow.close()
})
);
});
electron.ipcMain.on('sendMarkersComplete', function (e, arg) {
closeArg = true
mainWindow.close()
})
function writePos(mainWindow){
if (
max_window_size.width == mainWindow.getBounds().width &&
max_window_size.height == mainWindow.getBounds().height &&
@ -211,11 +232,14 @@ function createWindow() {
} else {
var size = { width: mainWindow.getBounds().width, height: mainWindow.getBounds().height, x: mainWindow.getBounds().x, y: mainWindow.getBounds().y }
}
fs.writeFileSync(info_path, JSON.stringify(size));
});
fs.writeFileSync(info_path, JSON.stringify(size))
}
mainWindow.on('maximize', function () {
fs.writeFileSync(max_info_path, JSON.stringify(mainWindow.getBounds()));
});
mainWindow.on('minimize', function () {
mainWindow.webContents.send('asRead', "")
})
var platform = process.platform;
var bit = process.arch;
@ -230,6 +254,29 @@ function createWindow() {
np.TheDeskNowPlaying(mainWindow);
//その他system
systemFunc.system(mainWindow, dir, lang, dirname);
setInterval(function () { mouseTrack(mainWindow) }, 1000);
}
var x = 0
var y = 0
var unchanged = 0
var locked = false
function mouseTrack(mainWindow) {
let mousePos = electron.screen.getCursorScreenPoint()
let xNow = mousePos.x
let yNow = mousePos.x
if (x != xNow || y != yNow) {
unchanged = 0
locked = false
} else {
unchanged++
if (unchanged > 60 && !locked) {
unchanged = 0
locked = true
mainWindow.webContents.send('asRead', "")
}
}
x = xNow
y = yNow
}
// Electronの初期化完了後に実行
app.on('ready', createWindow);

View File

@ -62,8 +62,8 @@
"vue": "^2.6.10"
},
"optionalDependencies": {
"itunes-nowplaying-mac": "kPherox/itunes-nowplaying-mac#get-artworks-base64",
"font-manager": "^0.3.0"
"font-manager": "^0.3.0",
"itunes-nowplaying-mac": "kPherox/itunes-nowplaying-mac#get-artworks-base64"
},
"devDependencies": {
"electron": "^6.0.0",