thedesk/app/js/ui/sort.js

120 lines
3.2 KiB
JavaScript
Raw Normal View History

2018-02-05 01:56:31 +11:00
//ソートデータ読み込み
function sortLoad () {
2020-08-02 17:08:07 +10:00
$("#sort").html("")
var col = localStorage.getItem("column")
2019-05-19 17:39:30 +10:00
if (col) {
2020-08-02 17:08:07 +10:00
var obj = JSON.parse(col)
2019-05-19 17:39:30 +10:00
}
Object.keys(obj).forEach(function (key) {
2020-08-02 17:08:07 +10:00
var acct = obj[key]
var flag = "false"
2019-05-19 17:39:30 +10:00
if (localStorage.getItem("card_" + key) == "true") {
flag = "true"
2018-02-05 01:56:31 +11:00
}
2020-08-02 17:08:07 +10:00
var insert = ""
2018-04-07 14:31:09 +10:00
2019-05-19 17:39:30 +10:00
if (acct.background) {
if (acct.text == "def") {
} else {
if (acct.text == "black") {
2020-08-02 17:08:07 +10:00
var txhex = "000000"
2019-05-19 17:39:30 +10:00
} else if (acct.text == "white") {
2020-08-02 17:08:07 +10:00
var txhex = "ffffff"
2019-05-19 17:39:30 +10:00
}
2020-08-02 17:08:07 +10:00
insert = ' style="background-color:#' + acct.background + '; color: #' + txhex + '" '
2018-04-07 14:31:09 +10:00
}
}
2020-08-02 17:08:07 +10:00
var user = localStorage.getItem("user_" + acct.domain)
var domain = localStorage.getItem("domain_" + acct.domain)
2019-05-19 17:39:30 +10:00
if (!user || !domain) {
2020-08-02 17:08:07 +10:00
var acctdata = ""
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
var acctdata = user + "@" + domain
2019-05-19 17:39:30 +10:00
}
var html = '<li class="drag-content" data-id="' + key + '" data-flag="' + flag + '"' + insert + '><div class="sorticon"><i class="material-icons">' + icon(acct.type) + '</i></div><div class="sorttitle">' + cap(acct.type, acct.data, acct.domain) + '</div><div class="sortaction"><a onclick="goColumn(' + key +
2019-05-19 17:39:30 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_sort_gothis + '">forward</i></a> <a onclick="removeColumn(' + key +
2020-08-02 17:08:07 +10:00
')" class="setting nex"><i class="material-icons waves-effect nex" title="このカラムを削除">cancel</i></a></div><div class="sortacct">' + acctdata + '</div></li>'
$("#sort").append(html)
})
drag()
2018-02-05 01:56:31 +11:00
}
//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"
2019-05-19 17:39:30 +10:00
} else if (type == "webview") {
2018-09-10 03:06:00 +10:00
return "Twitter"
2019-05-19 17:39:30 +10:00
} else if (type == "tootsearch") {
return "tootsearch(" + data + ")"
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
console.error("unknown timeline type: " + type)
2018-02-05 01:56:31 +11:00
}
}
//jquery-ui依存
2019-05-19 17:39:30 +10:00
function drag() {
2020-08-02 17:08:07 +10:00
$('#sort').sortable()
$('#sort').disableSelection()
2018-02-05 01:56:31 +11:00
}
//ソート指定
2019-05-19 17:39:30 +10:00
function sort() {
2020-08-02 17:08:07 +10:00
var arr = []
var flags = []
2019-05-19 17:39:30 +10:00
$(".drag-content").each(function (i, elem) {
2020-08-02 17:08:07 +10:00
var id = $(this).attr("data-id")
var flag = $(this).attr("data-flag")
2018-02-05 01:56:31 +11:00
arr.push(id)
2020-08-02 17:08:07 +10:00
flags.push(flag)
})
var col = localStorage.getItem("column")
var obj = JSON.parse(col)
var newobj = []
2019-05-19 17:39:30 +10:00
for (i = 0; i < arr.length; i++) {
2020-08-02 17:08:07 +10:00
var data = obj[arr[i]]
2018-02-05 01:56:31 +11:00
var add = {
domain: data.domain,
type: data.type,
2019-05-19 17:39:30 +10:00
data: data.data,
background: data.background,
text: data.text
2020-08-02 17:08:07 +10:00
}
newobj.push(add)
2019-05-19 17:39:30 +10:00
if (flags[i] == "true") {
2020-08-02 17:08:07 +10:00
localStorage.setItem("card_" + i, "true")
2019-05-19 17:39:30 +10:00
} else {
2020-08-02 17:08:07 +10:00
localStorage.removeItem("card_" + i)
2018-02-05 01:56:31 +11:00
}
}
2020-08-02 17:08:07 +10:00
var json = JSON.stringify(newobj)
localStorage.setItem("column", json)
$("#sort").html("")
2019-06-07 02:11:04 +10:00
M.toast({ html: "Sorted", displayLength: 3000 })
2020-08-02 17:08:07 +10:00
sortLoad()
parseColumn()
sortMenu()
2018-03-13 04:41:38 +11:00
}
2018-03-14 17:52:55 +11:00
//ソートボタントグル
2019-05-19 17:39:30 +10:00
function sortMenu() {
2020-08-02 17:08:07 +10:00
$("#left-menu a").removeClass("active")
$("#sortMenu").addClass("active")
$(".menu-content").addClass("hide")
$("#sort-box").removeClass("hide")
$("#sort").html("")
sortLoad()
2018-03-27 13:39:35 +11:00
}