Разница между страницами «Файл:Gushyin Valentin Anatolyevich 3.jpeg» и «MediaWiki:Gadget-CommentsToVk.js»

Материал из ВикиФизтех
(Различия между страницами)
Перейти к навигации Перейти к поиску
imported>ImportBot
 
imported>Admin2
 
Строка 1: Строка 1:
Валентин Анатольевич Гущин
+
(function() {
 +
 
 +
CommentToVk = function() {
 +
var instance = this;
 +
 
 +
var loginDiv = this.loginDiv = $('<div id="vkLoginStatus" style="float: right;"></div>');
 +
var loginLabel = this.loginLabel = $('<h4>Пользователь не авторизован</h4>');
 +
loginLabel.appendTo(loginDiv);
 +
 
 +
var btnLogin = $("<button>Login</button>");
 +
btnLogin.button();
 +
btnLogin.click(function() {
 +
instance.login();
 +
});
 +
loginDiv.append(btnLogin);
 +
 
 +
loginDiv.prependTo($("#bodyContent"));
 +
 
 +
if ($("#vk_api_transport").length == 0) {
 +
$(document.body).append($('<div id="vk_api_transport"></div>'));
 +
 
 +
window.vkAsyncInit = function() {
 +
VK.init({
 +
apiId : 2654830
 +
});
 +
};
 +
 
 +
setTimeout(function() {
 +
var el = document.createElement("script");
 +
el.type = "text/javascript";
 +
el.src = "//vk.com/js/api/openapi.js";
 +
el.async = true;
 +
document.getElementById("vk_api_transport").appendChild(el);
 +
}, 0);
 +
}
 +
 
 +
var publishDialog = this.publishDialog = $('<div id="commentsToVkDialog" title="Добавить комментарий в очередь"></div>')
 +
var publishForm = $('<form></form>')
 +
publishForm.appendTo(publishDialog);
 +
 
 +
var publishFormFieldset = $('<fieldset></fieldset>')
 +
publishFormFieldset.appendTo(publishForm);
 +
 
 +
var publishFormText = this.publishFormText = $('<textarea rows="10" cols="80"></textarea>')
 +
publishFormFieldset.append(publishFormText);
 +
publishFormFieldset.append('<br>');
 +
 
 +
var publishFormLink = this.publishFormLink = $('<input type="url"></input>')
 +
publishFormFieldset.append(publishFormLink);
 +
publishFormFieldset.append('<br>');
 +
 
 +
var publishFormTime = this.publishFormTime = $('<input type="datetime"></input>')
 +
publishFormFieldset.append(publishFormTime);
 +
publishFormFieldset.append('<br>');
 +
 
 +
publishDialog.dialog({
 +
autoOpen : false,
 +
height : 'auto',
 +
width : 'auto',
 +
modal : true,
 +
buttons : {
 +
Submit : function() {
 +
 
 +
},
 +
Cancel : function() {
 +
publishDialog.dialog("close");
 +
}
 +
},
 +
});
 +
 
 +
$.datetimepicker.setLocale('ru');
 +
}
 +
 
 +
CommentToVk.prototype.login = function() {
 +
var instance = this;
 +
 
 +
VK.Auth.login(function(result) {
 +
if (result.status === 'connected') {
 +
var user = result.session.user;
 +
instance.loginLabel.text('Авторизован: ' + user.first_name
 +
+ ' ' + user.last_name);
 +
 
 +
instance.appendPublishButtons();
 +
}
 +
});
 +
}
 +
 
 +
CommentToVk.prototype.appendPublishButtons = function() {
 +
var instance = this;
 +
 
 +
$(".c-item").each(function(index, item) {
 +
var container = $(item).find(".c-container");
 +
 
 +
var btnPublish = $("<button>Publish</button>");
 +
btnPublish.button();
 +
btnPublish.click(function() {
 +
instance.dialogPublish($(item));
 +
});
 +
container.append($("<br>"));
 +
container.append(btnPublish);
 +
});
 +
}
 +
 
 +
CommentToVk.prototype.dialogPublish = function(cItem) {
 +
var container = $(cItem).find(".c-container");
 +
var comment = $(cItem).find(".c-comment");
 +
var link = $(container.find("a")[0]).attr('href');
 +
link = link.split('#')[0];
 +
var text = comment.text();
 +
 
 +
this.publishFormText.val(text);
 +
this.publishFormLink.val(link);
 +
this.publishDialog.dialog('open');
 +
 
 +
this.publishFormTime.datetimepicker({
 +
format : $.datetimepicker.ISO_8601,
 +
minDate : new Date().toISOString().split('T')[0],
 +
value : new Date().toISOString()
 +
});
 +
}
 +
 
 +
if (wgArticleId == 5168) {
 +
new CommentToVk();
 +
}
 +
})();

Версия от 18:52, 30 июля 2016

(function() {

	CommentToVk = function() {
		var instance = this;

		var loginDiv = this.loginDiv = $('<div id="vkLoginStatus" style="float: right;"></div>');
		var loginLabel = this.loginLabel = $('<h4>Пользователь не авторизован</h4>');
		loginLabel.appendTo(loginDiv);

		var btnLogin = $("<button>Login</button>");
		btnLogin.button();
		btnLogin.click(function() {
			instance.login();
		});
		loginDiv.append(btnLogin);

		loginDiv.prependTo($("#bodyContent"));

		if ($("#vk_api_transport").length == 0) {
			$(document.body).append($('<div id="vk_api_transport"></div>'));

			window.vkAsyncInit = function() {
				VK.init({
					apiId : 2654830
				});
			};

			setTimeout(function() {
				var el = document.createElement("script");
				el.type = "text/javascript";
				el.src = "//vk.com/js/api/openapi.js";
				el.async = true;
				document.getElementById("vk_api_transport").appendChild(el);
			}, 0);
		}

		var publishDialog = this.publishDialog = $('<div id="commentsToVkDialog" title="Добавить комментарий в очередь"></div>')
		var publishForm = $('<form></form>')
		publishForm.appendTo(publishDialog);

		var publishFormFieldset = $('<fieldset></fieldset>')
		publishFormFieldset.appendTo(publishForm);

		var publishFormText = this.publishFormText = $('<textarea rows="10" cols="80"></textarea>')
		publishFormFieldset.append(publishFormText);
		publishFormFieldset.append('<br>');

		var publishFormLink = this.publishFormLink = $('<input type="url"></input>')
		publishFormFieldset.append(publishFormLink);
		publishFormFieldset.append('<br>');

		var publishFormTime = this.publishFormTime = $('<input type="datetime"></input>')
		publishFormFieldset.append(publishFormTime);
		publishFormFieldset.append('<br>');

		publishDialog.dialog({
			autoOpen : false,
			height : 'auto',
			width : 'auto',
			modal : true,
			buttons : {
				Submit : function() {

				},
				Cancel : function() {
					publishDialog.dialog("close");
				}
			},
		});

		$.datetimepicker.setLocale('ru');
	}

	CommentToVk.prototype.login = function() {
		var instance = this;

		VK.Auth.login(function(result) {
			if (result.status === 'connected') {
				var user = result.session.user;
				instance.loginLabel.text('Авторизован: ' + user.first_name
						+ ' ' + user.last_name);

				instance.appendPublishButtons();
			}
		});
	}

	CommentToVk.prototype.appendPublishButtons = function() {
		var instance = this;

		$(".c-item").each(function(index, item) {
			var container = $(item).find(".c-container");

			var btnPublish = $("<button>Publish</button>");
			btnPublish.button();
			btnPublish.click(function() {
				instance.dialogPublish($(item));
			});
			container.append($("<br>"));
			container.append(btnPublish);
		});
	}

	CommentToVk.prototype.dialogPublish = function(cItem) {
		var container = $(cItem).find(".c-container");
		var comment = $(cItem).find(".c-comment");
		var link = $(container.find("a")[0]).attr('href');
		link = link.split('#')[0];
		var text = comment.text();

		this.publishFormText.val(text);
		this.publishFormLink.val(link);
		this.publishDialog.dialog('open');

		this.publishFormTime.datetimepicker({
			format : $.datetimepicker.ISO_8601,
			minDate : new Date().toISOString().split('T')[0],
			value : new Date().toISOString()
		});
	}

	if (wgArticleId == 5168) {
		new CommentToVk();
	}
})();

История файла

Нажмите на дату/время, чтобы увидеть версию файла от того времени.

Дата/времяМиниатюраРазмерыУчастникПримечание
текущий04:24, 19 августа 2022Миниатюра для версии от 04:24, 19 августа 2022189 × 293 (8 Кб)Maintenance script (обсуждение | вклад)== Краткое описание == Importing file

Следующие 2 страницы используют этот файл: