thedesk/app/js/post/secure.js

130 lines
3.3 KiB
JavaScript
Raw Normal View History

2018-01-28 23:22:43 +11: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");
}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");
}
}
//投稿公開範囲
function vis(set){
$("#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");
2018-03-14 05:31:31 +11:00
if(set=="public"){
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("public");
$("#vis-icon").addClass("purple-text");
2018-03-14 05:31:31 +11:00
}else if(set=="unlisted"){
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("lock_open");
$("#vis-icon").addClass("blue-text");
2018-09-06 02:47:27 +10:00
}else if(set=="private"){
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("lock");
$("#vis-icon").addClass("orange-text");
2018-09-06 02:47:27 +10:00
}else if(set=="direct"){
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("mail");
$("#vis-icon").addClass("red-text");
2018-09-06 02:47:27 +10:00
}else if(set=="limited"){
2018-05-02 14:14:03 +10:00
$("#vis-icon").text("group");
$("#vis-icon").addClass("teal-text");
2018-09-06 02:47:27 +10:00
}else if(set=="local"){
$("#vis-icon").text("visibility");
$("#vis-icon").addClass("light-blue-text");
2018-03-14 05:31:31 +11:00
}
2018-01-28 23:22:43 +11:00
var vis=localStorage.getItem("vis");
if(vis=="memory"){
2018-06-18 00:26:45 +10:00
var acct_id = $("#post-acct-sel").val();
localStorage.setItem("vis-memory-"+acct_id,set);
2018-01-28 23:22:43 +11:00
}
2018-09-14 02:25:43 +10:00
$('.dropdown-button').dropdown('close');
2018-01-28 23:22:43 +11:00
}
2018-03-14 05:31:31 +11:00
function loadVis(){
var vist = localStorage.getItem("vis");
2018-06-18 00:26:45 +10:00
console.log(vist);
2018-03-14 05:31:31 +11:00
if (!vist) {
vis("public");
} else {
if (vist == "memory") {
2018-06-18 00:26:45 +10:00
var acct_id = $("#post-acct-sel").val();
var memory = localStorage.getItem("vis-memory-"+acct_id);
if (!memory) {
memory = "public";
}
vis(memory);
} else if(vist == "server") {
var acct_id = $("#post-acct-sel").val();
var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi);
var memory = obj[acct_id]["vis"];
2018-03-14 05:31:31 +11:00
if (!memory) {
memory = "public";
}
vis(memory);
} else {
vis(vist);
}
}
}
loadVis();
2018-01-28 23:22:43 +11:00
2018-06-18 00:26:45 +10:00
//コンテントワーニング
2018-01-28 23:22:43 +11:00
function cw(){
if($("#cw").hasClass("cw-avail")){
$("#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");
}else{
$("#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");
var cwt=localStorage.getItem("cw-text");
if(cwt){
$("#cw-text").val(cwt);
}
}
}
2018-06-18 00:26:45 +10:00
//TLでコンテントワーニングを表示トグル
2018-01-28 23:22:43 +11:00
function cw_show(id){
$(".cw_hide_"+id).toggleClass("cw");
2018-02-13 06:16:46 +11:00
$(".cw-long-"+id).toggleClass("hide");
2018-06-18 00:26:45 +10:00
}
$(function() {
$('#cw-text').on('change', function(event) {
var acct_id = $("#post-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var cwlen=$('#cw-text').val().length;
if(idata[domain+"_letters"]){
$("#textarea").attr("data-length", idata[domain+"_letters"]-cwlen)
}else{
$("#textarea").attr("data-length", 500-cwlen)
}
});
2019-01-22 03:25:40 +11:00
});
//スケジュール
function schedule(){
if($("#sch-box").hasClass("sch-avail")){
$("#sch-box").hide();
$("#sch-box").removeClass("sch-avail");
}else{
var date = new Date();
$("#sch-box").show();
$("#sch-date").val(formattime(date));
console.log(formattime(date));
$("#sch-box").addClass("sch-avail");
}
}