TheDesk Riina (ver.8)

This commit is contained in:
cutls
2018-02-26 00:32:10 +09:00
parent ba95bd9a24
commit 19eb4c2588
13 changed files with 79 additions and 22 deletions

View File

@@ -8,7 +8,7 @@ function ck() {
var at = localStorage.getItem(domain + "_at");
//コード受信
if(location.search){
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=([a-zA-Z-0-9]+)/);
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
var mode=m[1];
var codex=m[2];
if(mode=="manager" || mode=="login"){
@@ -32,6 +32,12 @@ function ck() {
ck();
//ログインポップアップ
function login(url) {
if($('#linux:checked').val()=="linux"){
var red = "urn:ietf:wg:oauth:2.0:oob"
}else{
var red = 'thedesk://login';
}
localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps";
fetch(start, {
method: 'POST',
@@ -41,7 +47,7 @@ function login(url) {
body: JSON.stringify({
scopes: 'read write follow',
client_name: "TheDesk(PC)",
redirect_uris: 'thedesk://login',
redirect_uris: red,
website: "https://thedesk.top"
})
}).then(function(response) {
@@ -78,6 +84,8 @@ function instance() {
//コードを入れた後認証
function code(code,mode) {
var red = localStorage.getItem("redirect");
localStorage.removeItem("redirect")
if(!code){
var code = $("#code").val();
}
@@ -96,7 +104,7 @@ function code(code,mode) {
},
body: JSON.stringify({
grant_type: "authorization_code",
redirect_uri: "thedesk://"+mode,
redirect_uri: red,
client_id: id,
client_secret: secret,
code: code

View File

@@ -145,6 +145,12 @@ function login(url) {
if (ng) {
return;
}
if($('#linux:checked').val()=="linux"){
var red = "urn:ietf:wg:oauth:2.0:oob"
}else{
var red = 'thedesk://manager';
}
localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps";
fetch(start, {
method: 'POST',
@@ -154,7 +160,7 @@ function login(url) {
body: JSON.stringify({
scopes: 'read write follow',
client_name: "TheDesk(PC)",
redirect_uris: 'thedesk://manager',
redirect_uris: red,
website: "https://thedesk.top"
})
}).then(function(response) {
@@ -179,7 +185,11 @@ function login(url) {
shell.openExternal(auth);
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('quit', 'go');
if($('#linux:checked').val()=="linux"){
}else{
ipc.send('quit', 'go');
}
});
}
@@ -191,6 +201,7 @@ function instance() {
//コード入れてAccessTokenゲット
function code(code) {
localStorage.removeItem("redirect")
if(!code){
var code = $("#code").val();
}

View File

@@ -21,6 +21,8 @@
location.href = url;
}
}else{
location.href = url;
}
}
return false;

View File

@@ -18,7 +18,16 @@ function notf(acct_id, tlid, sys) {
todo(error);
console.error(error);
}).then(function(json) {
var templete = parse(json, '', acct_id, tlid, -1)
var templete="";
Object.keys(json).forEach(function(key) {
var obj = json[key];
if(obj.type!="follow"){
templete = templete+parse([obj], '', acct_id, tlid, -1);
}else{
templete = templete+userparse([obj.account], '', acct_id, tlid, -1);
}
});
if (sys == "direct") {
$("#timeline_" + tlid).html(templete);
} else {
@@ -51,7 +60,11 @@ function notf(acct_id, tlid, sys) {
if (!popup) {
popup = 0;
}
var templete = parse(json, '', acct_id, tlid, popup)
if(json.type!="follow"){
templete = templete+parse([json], '', acct_id, tlid, popup);
}else{
templete = templete+userparse([json], '', acct_id, tlid, popup);
}
var notices = templete[1];
console.log(templete);
if (sys == "direct") {

View File

@@ -51,7 +51,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var notice = noticetext;
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
Materialize.toast(noticetext, popup * 1000);
Materialize.toast(toot.account.display_name+"が"+what, popup * 1000);
$(".notf-icon_" + tlid).addClass("red-text");
localStorage.setItem("notice-mem", noticetext);
noticetext = "";
@@ -96,7 +96,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
var spoiler = "cw cw_hide_" + toot.id;
var api_spoil = "gray";
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id +
'\')" class="nex parsed">見る</a>';
'\')" class="nex parsed">見る</a><br>';
} else {
var ct = toot.content.split('</p>').length + toot.content.split('<br />').length -
2;
@@ -296,7 +296,7 @@ function parse(obj, mix, acct_id, tlid, popup) {
}
//オブジェクトパーサー(ユーザーデータ)
function userparse(obj, auth, acct_id, notf) {
function userparse(obj, auth, acct_id, tlid, popup) {
var templete = '';
var datetype = localStorage.getItem("datetype");
Object.keys(obj).forEach(function(key) {
@@ -320,6 +320,13 @@ function userparse(obj, auth, acct_id, notf) {
}else{
var notftext="";
}
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && noticetext != memory) {
Materialize.toast(toot.display_name+"にフォローされました", popup * 1000);
$(".notf-icon_" + tlid).addClass("red-text");
localStorage.setItem("notice-mem", noticetext);
noticetext = "";
}
templete = templete +
'<div class="" style="padding-top:5px;" user-id="' + toot.id + '">' +
notftext +

View File

@@ -43,3 +43,17 @@ function zoomBox() {
}
}
//コード受信
if(location.search){
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
var mode=m[1];
var codex=m[2];
if(mode=="share"){
console.log(codex);
$('textarea').focus();
$("#textarea").val(decodeURI(codex));
show();
$("body").removeClass("mini-post");
$(".mini-btn").text("expand_less");
}
}

View File

@@ -2,7 +2,7 @@
localStorage.removeItem("history");
//コード受信
if(location.search){
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=([a-zA-Z-0-9]+)/);
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
var mode=m[1];
var codex=m[2];
if(mode=="user"){