Изменения

Перейти к навигации Перейти к поиску
нет описания правки
Строка 43: Строка 43:     
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({
Строка 58: Строка 61:  
buttons : {
 
buttons : {
 
Submit : function() {
 
Submit : function() {
 
+
instance.publish();
 
},
 
},
 
Cancel : function() {
 
Cancel : function() {
Строка 65: Строка 68:  
},
 
},
 
});
 
});
 +
 +
$.datetimepicker.setLocale('ru');
 
}
 
}
   Строка 107: Строка 112:  
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);
 +
}
 +
});
 
}
 
}
  
Анонимный участник

Навигация