Изменения
MediaWiki:Gadget-CommentsToVk.js (посмотреть исходный код)
Версия от 02:19, 3 сентября 2016
, 02:19, 3 сентября 2016нет описания правки
var publishFormText = this.publishFormText = $('<textarea rows="10" cols="80"></textarea>')
var publishFormText = this.publishFormText = $('<textarea rows="10" cols="80"></textarea>')
publishFormText.appendTo(publishFormFieldset);
publishFormFieldset.append(publishFormText);
publishFormFieldset.append('<br>');
var publishFormLink = this.publishFormLink = $('<input type="url"></input>')
var publishFormLink = this.publishFormLink = $('<input type="url"></input>')
publishFormLink.appendTo(publishFormFieldset);
publishFormFieldset.append(publishFormLink);
publishFormFieldset.append('<br>');
var publishFormTime = this.publishFormTime = $('<input type="datetime"></input>')
var publishFormTime = this.publishFormTime = $('<input type="datetime"></input>')
publishFormTime.appendTo(publishFormFieldset);
publishFormFieldset.append(publishFormTime);
publishFormFieldset.append('<br>');
publishDialog.dialog({
publishDialog.dialog({
buttons : {
buttons : {
Submit : function() {
Submit : function() {
instance.publish();
},
},
Cancel : function() {
Cancel : function() {
},
},
});
});
$.datetimepicker.setLocale('ru');
}
}
this.publishFormLink.val(link);
this.publishFormLink.val(link);
this.publishDialog.dialog('open');
this.publishDialog.dialog('open');
var lastDate;
if (typeof localStorage['CommentsToVk_lastDate'] === 'undefined') {
lastDate = new Date();
} else {
var lastDate = new Date(1 * localStorage['CommentsToVk_lastDate']);
lastDate = new Date(Math.max(new Date().getTime(), lastDate
.getTime()));
}
nextDate = new Date(
(Math.floor(lastDate.getTime() / 1000.0 / 60 / 60) + 1) * 1000 * 60 * 60);
this.publishFormTime.datetimepicker({
format : 'H:i:s d.m.Y',
value : nextDate.toLocaleTimeString("ru-RU") + ' '
+ nextDate.toLocaleDateString("ru-RU")
});
}
CommentToVk.prototype.publish = function() {
var instance = this;
var link = this.publishFormLink.val();
var text = this.publishFormText.val();
var date = this.publishFormTime.datetimepicker('getValue');
var timestamp = Math.round(date.getTime() / 1000);
VK.Api.call('wall.post', {
owner_id : -47630162,
from_group : 1,
message : text,
attachments : link,
signed : 0,
publish_date : Math.floor(date.getTime() / 1000),
}, function(r) {
console.log(r);
if (r.response) {
localStorage['CommentsToVk_lastDate'] = date.getTime();
instance.publishDialog.dialog("close");
return;
}
if (r.error) {
alert(r.error.error_msg);
}
});
}
}