thedesk/app/js/ui/layout.js

334 lines
12 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11:00
//レイアウトの設定
2018-03-27 13:39:35 +11:00
var websocketOld = [];
var websocket = [];
var websocketHome = [];
var websocketLocal = [];
var websocketNotf = [];
2018-01-28 23:22:43 +11:00
2018-03-27 13:39:35 +11:00
//カラム追加ボックストグル
function addToggle() {
$("#add-box").toggleClass("hide");
addselCk()
2018-07-28 07:25:12 +10:00
$("#add-box").css("bottom","40px");
$("#add-box").css("left",$('#add-tgl').offset().left-$('#add-box').width()/2+"px");
2018-03-27 13:39:35 +11:00
$("#add-box").toggleClass("show");
}
2018-01-28 23:22:43 +11:00
//最初、カラム変更時に発火
2018-03-27 13:39:35 +11:00
function parseColumn() {
2018-08-05 02:26:34 +10:00
console.log("parse");
2018-03-27 13:39:35 +11:00
var size = localStorage.getItem("size");
if (size) {
$("#timeline-container").css("font-size", size + "px");
$(".toot-reset").css("font-size", size + "px");
$(".cont-series").css("font-size", size + "px");
}
tlCloser();
var multi = localStorage.getItem("multi");
if (!multi) {
var obj = [];
var json = JSON.stringify(obj);
localStorage.setItem("multi", json);
} else {
var obj = JSON.parse(multi);
2018-01-28 23:22:43 +11:00
2018-03-27 13:39:35 +11:00
var templete;
2018-01-28 23:22:43 +11:00
Object.keys(obj).forEach(function(key) {
var acct = obj[key];
2018-03-27 13:39:35 +11:00
localStorage.setItem("name_" + key, acct.name);
localStorage.setItem("user_" + key, acct.user);
localStorage.setItem("user-id_" + key, acct.id);
localStorage.setItem("prof_" + key, acct.prof);
localStorage.setItem("domain_" + key, acct.domain);
2018-07-07 03:51:48 +10:00
localStorage.setItem("acct_"+ key + "_at", acct.at);
2018-03-27 13:39:35 +11:00
notf(key, 0);
ckdb(key);
2018-07-17 01:39:06 +10:00
//フィルターデータ読もう
getFilter(key);
2018-01-28 23:22:43 +11:00
});
2018-03-27 13:39:35 +11:00
}
2018-06-18 00:26:45 +10:00
var acctlist=obj;
2018-07-07 03:51:48 +10:00
console.log(obj);
2018-03-27 13:39:35 +11:00
var xed=localStorage.getItem("xed");
if(xed){
xpand();
}
var col = localStorage.getItem("column");
if (!col) {
var obj = [{
domain: 0,
type: 'local'
}];
localStorage.setItem("card_0","true");
var json = JSON.stringify(obj);
localStorage.setItem("column", json);
} else {
var obj = JSON.parse(col);
}
if ($("#timeline-container").length) {
$("#timeline-container").html("");
}
Object.keys(obj).forEach(function(key) {
var acct = obj[key];
if(acct.type=="notf"){
var notf_attr=' data-notf='+acct.domain;
2018-08-11 01:58:00 +10:00
var if_notf="hide";
2018-03-27 13:39:35 +11:00
}else{
var notf_attr='';
2018-08-11 01:58:00 +10:00
var if_notf="";
2018-01-28 23:22:43 +11:00
}
2018-03-27 13:39:35 +11:00
if(localStorage.getItem("notification_" + acct.domain)){
2018-07-29 19:43:08 +10:00
var unique_notf=lang_layout_thisacct[lang].replace("{{notf}}" ,localStorage.getItem("notification_" + acct.domain));
2018-03-27 13:39:35 +11:00
}else{
2018-07-29 19:43:08 +10:00
if(lang=="ja"){
var notflocale="通知";
}else if(lang=="en"){
var notflocale="Notification";
}
var unique_notf=lang_layout_thisacct[lang].replace("{{notf}}" ,notflocale);
2018-01-28 23:22:43 +11:00
}
2018-04-07 14:31:09 +10:00
var insert="";
var icnsert="";
if(acct.background){
if(acct.text=="def"){
}else{
if(acct.text=="black"){
var txhex="000000";
var ichex="9e9e9e"
}else if(acct.text=="white"){
var txhex="ffffff";
var ichex="eeeeee"
}
2018-06-18 00:26:45 +10:00
insert='background-color:#'+acct.background+'; color: #'+txhex+'; ';
2018-04-07 14:31:09 +10:00
icnsert=' style="color: #'+ichex+'" ';
}
}
2018-07-07 03:51:48 +10:00
console.log(acct.domain);
if(acctlist[acct.domain]){
if(acctlist[acct.domain].background!="def"){
insert=insert+" border-bottom:medium solid #"+acctlist[acct.domain].background;
}
2018-06-18 00:26:45 +10:00
}
2018-08-11 01:58:00 +10:00
2018-03-27 13:39:35 +11:00
var html = '<div class="box" id="timeline_box_' + key + '_box" tlid="' + key +
2018-06-18 00:26:45 +10:00
'" data-acct="'+acct.domain+'"><div class="notice-box z-depth-2" id="menu_'+key+'" style="'+insert+'">'+
2018-07-29 19:43:08 +10:00
'<div class="area-notice"><i class="material-icons waves-effect red-text" id="notice_icon_' + key + '"'+notf_attr+' style="font-size:40px; padding-top:25%;" onclick="goTop(' + key + ')" title="'+lang_layout_gotop[lang]+'"></i></div>'+
2018-04-07 14:31:09 +10:00
'<div class="area-notice_name"><span id="notice_' + key + '" class="tl-title"></span></div>'+
2018-03-27 13:39:35 +11:00
'<div class="area-a1"><a onclick="notfToggle(' + acct.domain + ',' + key +
2018-08-11 01:58:00 +10:00
')" class="setting nex '+if_notf+'" title="'+unique_notf+'"'+icnsert+'><i class="material-icons waves-effect nex notf-icon_' +
2018-07-28 07:25:12 +10:00
acct.domain + '">notifications</i></div><div class="area-sta"><span class="new badge teal notf-reply_'+acct.domain+' hide" data-badge-caption="Reply">0</span><span class="new badge yellow black-text notf-fav_'+acct.domain+' hide" data-badge-caption="Fav">0</span><span class="new badge blue notf-bt_'+acct.domain+' hide" data-badge-caption="BT">0</span><span class="new badge orange notf-follow_'+acct.domain+' hide" data-badge-caption="Follow">0</span></a></div>'+
2018-03-27 13:39:35 +11:00
'<div class="area-a2"><a onclick="removeColumn(' + key +
2018-07-29 19:43:08 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang_layout_delthis[lang]+'"'+icnsert+'>cancel</i></a></div>'+
2018-04-07 14:31:09 +10:00
'<div class="area-a3"><a onclick="setToggle(' + key +
2018-07-29 19:43:08 +10:00
')" class="setting nex" title="'+lang_layout_setthis[lang]+'"'+icnsert+'><i class="material-icons waves-effect nex">settings</i></a></div></div>'+
2018-08-10 01:18:35 +10:00
'<div class="column-hide notf-indv-box z-depth-4" id="notf-box_' + key +
2018-03-27 13:39:35 +11:00
'"><div id="notifications_' + key +
2018-08-10 01:18:35 +10:00
'" data-notf="' + acct.domain + '" data-type="notf"></div></div><div class="column-hide notf-indv-box" id="util-box_' + key +
2018-04-07 14:31:09 +10:00
'" style="padding:5px;"><a onclick="mediaToggle(' + key +
2018-07-29 19:43:08 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang_layout_mediafil[lang]+'">perm_media</i><span id="sta-media-' +
key + '">On</span></a>'+lang_layout_mediafil[lang]+'<br><a onclick="cardToggle(' + key +
')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang_layout_linkanades[lang]+'">link</i><span id="sta-card-' +
key + '">On</span></a>'+lang_layout_linkana[lang]+'<br><a onclick="voiceToggle(' + key +
')" class="setting nex"><i class="material-icons waves-effect nex" title="'+lang_layout_tts[lang]+'">hearing</i><span id="sta-voice-' +
key + '">On</span></a>'+lang_layout_tts[lang]+'TL<br>'+lang_layout_headercolor[lang]+'<br><div id="picker_'+key+'" class="color-picker"></div></div><div class="tl-box" tlid="' + key + '"><div id="timeline_' + key +
'" class="tl" tlid="' + key + '"'+notf_attr+' data-type="' + acct.type + '"><div style="text-align:center">'+lang_layout_nodata[lang]+'</div></div></div></div>';
2018-03-27 13:39:35 +11:00
$("#timeline-container").append(html);
localStorage.removeItem("pool_" + key);
if (acct.data) {
var data = acct.data;
} else {
var data = "";
}
2018-07-22 23:03:46 +10:00
if(localStorage.getItem("catch_" + key)){
2018-07-17 01:39:06 +10:00
var delc="true";
}else{
var delc="false";
}
2018-07-22 23:03:46 +10:00
if(localStorage.getItem("voice_" + key)){
var voice=true;
}else{
var voice=false;
}
tl(acct.type, data, acct.domain, key, delc,voice);
2018-03-27 13:39:35 +11:00
cardCheck(key);
mediaCheck(key);
2018-07-28 07:25:12 +10:00
catchCheck(key);
voiceCheck(key);
2018-03-27 13:39:35 +11:00
});
var width = localStorage.getItem("width");
if (width) {
$(".box").css("min-width", width + "px");
2018-01-28 23:22:43 +11:00
}
2018-03-27 13:39:35 +11:00
var box = localStorage.getItem("box");
2018-08-05 13:36:23 +10:00
if (box == "absolute") {
2018-08-10 12:35:21 +10:00
setTimeout(show, 1000);
2018-03-27 13:39:35 +11:00
}
favTag();
2018-08-05 13:36:23 +10:00
var cw = localStorage.getItem("always-cw");
if (cw == "yes") {
if(!$("#cw").hasClass("cw-avail")){
$("#cw-text").show();
$("#cw").addClass("yellow-text");
$("#cw").addClass("cw-avail");
var cwt=localStorage.getItem("cw-text");
if(cwt){
$("#cw-text").val(cwt);
}
}
}
2018-03-27 13:39:35 +11:00
}
2018-01-28 23:22:43 +11:00
//カラム追加
2018-03-27 13:39:35 +11:00
function addColumn() {
var acct = $("#add-acct-sel").val();
localStorage.setItem("last-use", acct);
var type = $("#type-sel").val();
if(acct=="noauth"){
acct=$("#noauth-url").val();
type="noauth"
2018-01-28 23:22:43 +11:00
}
2018-03-27 13:39:35 +11:00
var add = {
domain: acct,
type: type
};
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
2018-04-07 14:31:09 +10:00
if(!obj){
var leng=0;
localStorage.setItem("card_" + leng,"true");
var json = JSON.stringify([add]);
localStorage.setItem("column", json);
}else{
var leng=obj.length;
localStorage.setItem("card_" + leng,"true");
obj.push(add);
var json = JSON.stringify(obj);
localStorage.setItem("column", json);
}
2018-03-27 13:39:35 +11:00
parseColumn();
}
function addselCk(){
var acct = $("#add-acct-sel").val();
2018-05-02 14:14:03 +10:00
var domain=localStorage.getItem("domain_" + acct);
2018-03-27 13:39:35 +11:00
if(acct=="noauth"){
$("#auth").addClass("hide");
$("#noauth").removeClass("hide");
}else{
$("#auth").removeClass("hide");
$("#noauth").addClass("hide");
2018-01-28 23:22:43 +11:00
}
2018-05-02 14:14:03 +10:00
if(domain=="knzk.me" || domain=="mstdn.y-zu.org"){
2018-07-29 19:43:08 +10:00
$("#type-sel").append('<option value="dm" data-trans="dm" id="direct-add">'+lang_layout_dm[lang]+'</option>');
2018-05-02 14:14:03 +10:00
$('#type-sel').material_select('update');
}else{
$("#direct-add").remove();
$('#type-sel').material_select('update');
}
2018-03-27 13:39:35 +11:00
}
//カラム削除
function removeColumn(tlid) {
2018-07-29 17:37:54 +10:00
$("#sort-box").addClass("hide");
$("#sort-box").removeClass("show");
2018-03-27 13:39:35 +11:00
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
//聞く
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('column-del', "");
ipc.on('column-del-reply', function (event, arg) {
console.log(arg);
if(arg==1){
localStorage.removeItem("card_" + tlid);
obj.splice(tlid, 1);
2018-07-05 11:26:07 +10:00
for(var i=0;i<obj.length;i++){
localStorage.setItem("card_" + i,"true");
2018-07-22 23:03:46 +10:00
localStorage.removeItem("catch_" + i);
2018-07-05 11:26:07 +10:00
}
2018-03-27 13:39:35 +11:00
var json = JSON.stringify(obj);
localStorage.setItem("column", json);
parseColumn();
sortload()
}
})
2018-04-07 14:31:09 +10:00
}
//設定トグル
function setToggle(tlid) {
colorpicker(tlid);
2018-08-10 01:18:35 +10:00
if($("#util-box_" + tlid).hasClass("column-hide")){
$("#util-box_" + tlid).css("display","block")
$("#util-box_" + tlid).animate({
'height': '200px'
},{
'duration': 300,
'complete': function(){
$("#util-box_" + tlid).css("overflow-y","scroll")
$("#util-box_" + tlid).removeClass("column-hide")
}
});
}else{
$("#util-box_" + tlid).css("overflow-y","hidden")
$("#util-box_" + tlid).animate({
'height': '0'
},{
'duration': 300,
'complete': function(){
$("#util-box_" + tlid).addClass("column-hide")
$("#util-box_" + tlid).css("display","none")
}
});
}
2018-04-07 14:31:09 +10:00
}
function colorpicker(key){
temp=
'<div onclick="coloradd('+key+',\'def\',\'def\')" class="pointer">Default</div>'+
'<div onclick="coloradd('+key+',\'f44336\',\'white\')" class="red white-text pointer">Red</div>'+
'<div onclick="coloradd('+key+',\'e91e63\',\'white\')" class="pink white-text pointer">Pink</div>'+
'<div onclick="coloradd('+key+',\'9c27b0\',\'white\')" class="purple white-text pointer">Purple</div>'+
'<div onclick="coloradd('+key+',\'673ab7\',\'white\')" class="deep-purple white-text pointer">Deep-purple</div>'+
'<div onclick="coloradd('+key+',\'3f51b5\',\'white\')" class="indigo white-text pointer">Indigo</div>'+
'<div onclick="coloradd('+key+',\'2196f3\',\'white\')" class="blue white-text pointer">Blue</div>'+
'<div onclick="coloradd('+key+',\'03a9f4\',\'black\')" class="light-blue black-text pointer">Light-blue</div>'+
'<div onclick="coloradd('+key+',\'00bcd4\',\'black\')" class="cyan black-text pointer">Cyan</div>'+
'<div onclick="coloradd('+key+',\'009688\',\'white\')" class="teal white-text pointer">Teal</div>'+
'<div onclick="coloradd('+key+',\'4caf50\',\'black\')" class="green black-text pointer">Green</div>'+
'<div onclick="coloradd('+key+',\'8bc34a\',\'black\')" class="light-green black-text pointer">Light-green</div>'+
'<div onclick="coloradd('+key+',\'cddc39\',\'black\')" class="lime black-text pointer">Lime</div>'+
'<div onclick="coloradd('+key+',\'ffeb3b\',\'black\')" class="yellow black-text pointer">Yellow</div>'+
'<div onclick="coloradd('+key+',\'ffc107\',\'black\')" class="amber black-text pointer">Amber</div>'+
'<div onclick="coloradd('+key+',\'ff9800\',\'black\')" class="orange black-text pointer">Orange</div>'+
'<div onclick="coloradd('+key+',\'ff5722\',\'white\')" class="deep-orange white-text pointer">Deep-orange</div>'+
'<div onclick="coloradd('+key+',\'795548\',\'white\')" class="brown white-text pointer">Brown</div>'+
'<div onclick="coloradd('+key+',\'9e9e9e\',\'white\')" class="grey white-text pointer">Grey</div>'+
'<div onclick="coloradd('+key+',\'607d8b\',\'white\')" class="blue-grey white-text pointer">Blue-grey</div>'+
'<div onclick="coloradd('+key+',\'000000\',\'white\')" class="black white-text pointer">Black</div>'+
'<div onclick="coloradd('+key+',\'ffffff\',\'black\')" class="white black-text pointer">White</div>';
$("#picker_"+key).html(temp);
}
function coloradd(key,bg,txt){
var col = localStorage.getItem("column");
var o = JSON.parse(col);
var obj=o[key];
obj.background=bg;
obj.text=txt;
o[key]=obj;
var json = JSON.stringify(o);
localStorage.setItem("column", json);
if(txt=="def"){
2018-06-18 00:26:45 +10:00
$("#menu_"+key).css("background-color","");
$("#menu_"+key).css("color","");
2018-04-07 14:31:09 +10:00
}else{
$("#menu_"+key).css('background-color','#'+bg);
if(txt=="black"){
var bghex="000000";
var ichex="9e9e9e"
}else if(txt=="white"){
var bghex="ffffff";
var ichex="eeeeee"
}
$("#menu_"+key+" .nex").css('color','#'+ichex);
$("#menu_"+key).css('color','#'+bghex);
}
2018-03-27 13:39:35 +11:00
}