thedesk/app/js/post/secure.js

131 lines
3.3 KiB
JavaScript
Raw Permalink Normal View History

2018-01-28 23:22:43 +11:00
/*保護系*/
//画像保護
2019-05-19 17:39:30 +10:00
function nsfw() {
if ($("#nsfw").hasClass("nsfw-avail")) {
2018-05-02 14:14:03 +10:00
$("#nsfw").removeClass("yellow-text");
$("#nsfw").html("visibility_off");
2018-01-28 23:22:43 +11:00
$("#nsfw").removeClass("nsfw-avail");
2019-05-19 17:39:30 +10:00
} else {
2018-05-02 14:14:03 +10:00
$("#nsfw").addClass("yellow-text");
$("#nsfw").html("visibility");
2018-01-28 23:22:43 +11:00
$("#nsfw").addClass("nsfw-avail");
}
}
//投稿公開範囲
2019-05-19 17:39:30 +10:00
function vis(set) {
2018-01-28 23:22:43 +11:00
$("#vis").text(set);
2018-05-02 14:14:03 +10:00
$("#vis-icon").removeClass("red-text");
$("#vis-icon").removeClass("orange-text");
$("#vis-icon").removeClass("blue-text");
$("#vis-icon").removeClass("purple-text");
2018-09-06 02:47:27 +10:00
$("#vis-icon").removeClass("light-blue-text");
$("#vis-icon").removeClass("teal-text");
2019-05-19 17:39:30 +10:00
if (set == "public") {
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("public");
$("#vis-icon").addClass("purple-text");
2019-05-19 17:39:30 +10:00
} else if (set == "unlisted") {
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("lock_open");
$("#vis-icon").addClass("blue-text");
2019-05-19 17:39:30 +10:00
} else if (set == "private") {
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("lock");
$("#vis-icon").addClass("orange-text");
2019-05-19 17:39:30 +10:00
} else if (set == "direct") {
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("mail");
$("#vis-icon").addClass("red-text");
2019-05-19 17:39:30 +10:00
} else if (set == "limited") {
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("group");
$("#vis-icon").addClass("teal-text");
2019-05-19 17:39:30 +10:00
} else if (set == "local") {
2018-09-06 02:47:27 +10:00
$("#vis-icon").text("visibility");
$("#vis-icon").addClass("light-blue-text");
2018-03-14 05:31:31 +11:00
}
2019-05-19 17:39:30 +10:00
var vis = localStorage.getItem("vis");
if (vis == "memory") {
var acct_id = $("#post-acct-sel").val();
localStorage.setItem("vis-memory-" + acct_id, set);
}
2019-06-16 21:35:15 +10:00
var ins = M.Dropdown.getInstance($('#dropdown1'))
if(ins){
ins.close();
}
2018-01-28 23:22:43 +11:00
}
2019-05-19 17:39:30 +10:00
function loadVis() {
var vist = localStorage.getItem("vis");
if (!vist) {
vis("public");
} else {
if (vist == "memory") {
var acct_id = $("#post-acct-sel").val();
var memory = localStorage.getItem("vis-memory-" + acct_id);
if (!memory) {
memory = "public";
2018-03-14 05:31:31 +11:00
}
2019-05-19 17:39:30 +10:00
vis(memory);
} else if (vist == "useapi") {
var acct_id = $("#post-acct-sel").val();
var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi);
var memory = obj[acct_id]["vis"];
if (!memory) {
memory = "public";
}
vis(memory);
} else {
vis(vist);
}
2018-03-14 05:31:31 +11:00
}
}
loadVis();
2018-01-28 23:22:43 +11:00
2018-06-18 00:26:45 +10:00
//コンテントワーニング
2019-05-19 17:39:30 +10:00
function cw() {
if ($("#cw").hasClass("cw-avail")) {
2018-01-28 23:22:43 +11:00
$("#cw-text").val();
$("#cw-text").hide();
2018-05-02 14:14:03 +10:00
$("#cw").removeClass("yellow-text");
2018-01-28 23:22:43 +11:00
$("#cw").removeClass("cw-avail");
2019-05-19 17:39:30 +10:00
} else {
2018-01-28 23:22:43 +11:00
$("#cw-text").show();
2018-05-02 14:14:03 +10:00
$("#cw").addClass("yellow-text");
2018-01-28 23:22:43 +11:00
$("#cw").addClass("cw-avail");
2019-05-19 17:39:30 +10:00
var cwt = localStorage.getItem("cw-text");
if (cwt) {
2018-01-28 23:22:43 +11:00
$("#cw-text").val(cwt);
}
}
}
2018-06-18 00:26:45 +10:00
//TLでコンテントワーニングを表示トグル
2019-05-19 17:39:30 +10:00
function cw_show(id) {
$(".cw_hide_" + id).toggleClass("cw");
$(".cw-long-" + id).toggleClass("hide");
2018-06-18 00:26:45 +10:00
}
2019-05-19 17:39:30 +10:00
$(function () {
$('#cw-text').on('change', function (event) {
2018-06-18 00:26:45 +10:00
var acct_id = $("#post-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
2019-05-19 17:39:30 +10:00
var cwlen = $('#cw-text').val().length;
2018-06-18 00:26:45 +10:00
2019-05-19 17:39:30 +10:00
if (idata[domain + "_letters"]) {
$("#textarea").attr("data-length", idata[domain + "_letters"] - cwlen)
} else {
$("#textarea").attr("data-length", 500 - cwlen)
2018-06-18 00:26:45 +10:00
}
2019-05-19 17:39:30 +10:00
2018-06-18 00:26:45 +10:00
});
2019-05-19 17:39:30 +10:00
});
2019-01-22 03:25:40 +11:00
//スケジュール
2019-05-19 17:39:30 +10:00
function schedule() {
if ($("#sch-box").hasClass("sch-avail")) {
2019-01-22 03:25:40 +11:00
$("#sch-box").hide();
$("#sch-box").removeClass("sch-avail");
2019-05-19 17:39:30 +10:00
} else {
2019-01-22 03:25:40 +11:00
var date = new Date();
2019-05-19 17:39:30 +10:00
2019-01-22 03:25:40 +11:00
$("#sch-box").show();
$("#sch-date").val(formattime(date));
$("#sch-box").addClass("sch-avail");
}
}