thedesk/app/js/ui/sort.js

111 lines
2.8 KiB
JavaScript
Raw Normal View History

2018-02-05 01:56:31 +11:00
//ソートデータ読み込み
function sortload(){
var col = localStorage.getItem("column");
if (col) {
var obj = JSON.parse(col);
}
Object.keys(obj).forEach(function(key) {
var acct = obj[key];
var flag="false";
if(localStorage.getItem("card_" + key)=="true"){
flag="true"
}
2018-04-07 14:31:09 +10:00
var insert="";
if(acct.background){
if(acct.text=="def"){
}else{
if(acct.text=="black"){
var txhex="000000";
}else if(acct.text=="white"){
var txhex="ffffff";
}
insert=' style="background-color:#'+acct.background+'; color: #'+txhex+'" ';
}
}
var html='<li class="drag-content" data-id="'+key+'" data-flag="'+flag+'"'+insert+'><a onclick="goColumn(' + key +
2018-07-28 07:25:12 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="このカラムへ">forward</i></a> <a onclick="removeColumn(' + key +
2018-07-29 17:37:54 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="このカラムを削除">cancel</i></a><br>'+localStorage.getItem("user_" + acct.domain)+"@"+localStorage.getItem("domain_" + acct.domain)+" "+cap(acct.type, acct.data,acct.domain)+'</li>';
2018-02-05 01:56:31 +11:00
$("#sort").append(html);
});
drag();
}
//TLのタイトル
2018-05-20 16:17:10 +10:00
function Scap(type, data) {
2018-02-05 01:56:31 +11:00
if (type == "home") {
return "Home"
} else if (type == "local") {
return "Local"
} else if (type == "pub") {
return "Public"
} else if (type == "tag") {
return "#" + data
} else if (type == "list") {
return "List(id:" + data + ")"
} else if (type == "notf") {
return "Notification"
2018-02-24 03:02:44 +11:00
} else if (type == "mix") {
return "Integrated"
2018-07-29 17:37:54 +10:00
}else{
console.log(type);
2018-02-05 01:56:31 +11:00
}
}
//jquery-ui依存
function drag(){
$('#sort').sortable();
$('#sort').disableSelection();
}
//ソート指定
function sort(){
var arr=[];
var flags=[];
$(".drag-content").each(function(i, elem) {
var id=$(this).attr("data-id");
var flag=$(this).attr("data-flag");
arr.push(id)
flags.push(flag);
});
var col = localStorage.getItem("column");
var obj = JSON.parse(col);
var newobj=[];
for(i=0;i<arr.length;i++){
var data=obj[arr[i]];
var add = {
domain: data.domain,
type: data.type,
2018-05-12 04:12:25 +10:00
data:data.data,
background:data.background,
text:data.text
2018-02-05 01:56:31 +11:00
};
newobj.push(add);
if(flags[i]=="true"){
localStorage.setItem("card_" + i, "true");
}else{
localStorage.removeItem("card_" + i);
}
}
var json = JSON.stringify(newobj);
localStorage.setItem("column", json);
$("#sort").html("");
Materialize.toast("並べ替え完了。", 3000);
sortload();
2018-03-13 04:41:38 +11:00
parseColumn();
2018-07-28 07:25:12 +10:00
sortToggle()
2018-03-13 04:41:38 +11:00
}
2018-03-14 17:52:55 +11:00
//ソートボタントグル
2018-03-13 04:41:38 +11:00
function sortToggle(){
$("#sort").html("");
if ($("#sort-box").hasClass("hide")) {
$("#sort-box").removeClass("hide");
2018-04-01 07:00:27 +10:00
$("#sort-box").addClass("show");
2018-03-13 04:41:38 +11:00
//並べ替え
sortload();
} else {
2018-04-01 07:00:27 +10:00
$("#sort-box").addClass("hide");
$("#sort-box").removeClass("show");
2018-03-13 04:41:38 +11:00
}
2018-03-27 13:39:35 +11:00
}