Scheduled toot available

This commit is contained in:
cutls
2019-01-22 01:25:40 +09:00
parent 4f82cf00d6
commit f3186373bf
7 changed files with 127 additions and 13 deletions

View File

@@ -31,4 +31,54 @@ function nl2br(str) {
str = str.replace(/\r\n/g, "<br />");
str = str.replace(/(\n|\r)/g, "<br />");
return str;
}
function formattime(date){
var str=date.getFullYear()+"-";
if(date.getMonth()+1<10){
str=str+"0"+(date.getMonth()+1)+"-";
}else{
str=str+(date.getMonth()+1)+"-";
}
if(date.getDate()<10){
str=str+"0"+date.getDate()
}else{
str=str+date.getDate()
}
str=str+"T";
if(date.getHours()<10){
str=str+"0"+date.getHours()+":"
}else{
str=str+date.getHours()+":"
}
if(date.getMinutes()<10){
str=str+"0"+date.getMinutes()
}else{
str=str+date.getMinutes()
}
return str;
}
function formattimeutc(date){
var str=date.getUTCFullYear()+"-";
if(date.getUTCMonth()+1<10){
str=str+"0"+(date.getUTCMonth()+1)+"-";
}else{
str=str+(date.getUTCMonth()+1)+"-";
}
if(date.getUTCDate()<10){
str=str+"0"+date.getUTCDate()
}else{
str=str+date.getUTCDate()
}
str=str+"T";
if(date.getUTCHours()<10){
str=str+"0"+date.getUTCHours()+":"
}else{
str=str+date.getUTCHours()+":"
}
if(date.getUTCMinutes()<10){
str=str+"0"+date.getUTCMinutes()
}else{
str=str+date.getUTCMinutes()
}
return str;
}

View File

@@ -105,6 +105,14 @@ function post(mode,postvis) {
}else if(vis=="local"){
toot.status=str+"👁️";
}
//ここに非公開・未収載タグについてwarn
if(~str.indexOf("#")){
if(vis == "local" || vis=="unlisted" || vis=="direct" || vis=="private"){
if(!confirm(lang_post_tagVis[lang])){
return false;
}
}
}
if ($("#cw").hasClass("cw-avail")) {
var spo = $("#cw-text").val();
cw();
@@ -112,6 +120,14 @@ function post(mode,postvis) {
} else {
var spo = "";
}
if ($("#sch-box").hasClass("sch-avail")) {
var scheduled=formattimeutc(new Date(Date.parse($("#sch-date").val())))
schedule();
toot.scheduled_at=scheduled;
} else {
var scheduled = "";
}
var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true);
httpreq.setRequestHeader('Content-Type', 'application/json');

View File

@@ -112,4 +112,18 @@ $(function() {
});
});
});
//スケジュール
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");
}
}