사용자:Drplain1202/common.js
참고: 설정을 저장한 후에 바뀐 점을 확인하기 위해서는 브라우저의 캐시를 새로 고쳐야 합니다.
- 파이어폭스 / 사파리: Shift 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5 또는 Ctrl-R을 입력 (Mac에서는 ⌘-R)
- 구글 크롬: Ctrl-Shift-R키를 입력 (Mac에서는 ⌘-Shift-R)
- 인터넷 익스플로러 / 엣지: Ctrl 키를 누르면서 새로 고침을 클릭하거나, Ctrl-F5를 입력.
- 오페라: Ctrl-F5를 입력.
/** 플러그인 uncytick***************************
* 게임 실행용 플러그인
* 버전 => 1.0.0
* 작성자 : [[사용자:BANIP|BANIP]]
* JSON => uncytick = {"name":"uncytick","descript":"게임 실행용 플러그인","version":"1.0.0","local":true,"creat":"BANIP","state":"사용자:BANIP/틱택토 live/플러그인","executable":true};
*/
function plugin_uncytick(){
if($("[data-name='uncytick']").length >= 1){
// 이부분에 코드 입력 //
jQuery.getScript("https://socket-io-chat.now.sh/socket.io/socket.io.js")
.done(function(){
var Socket = /** @class */ (function () {
function Socket(url, username) {
if (username === void 0) { username = Math.random().toString(); }
this.username = username;
this.socket = io(url);
this.defineJoin();
this.bindSocketListener();
}
Socket.prototype.defineJoin = function () {
this.socket.emit("join", { username: this.username });
};
Socket.prototype.bindSocketListener = function () {
var _this = this;
var socket = this.socket;
socket.on("newuser", function (_a) {
var username = _a.username;
Chat.server(username + "\uB2D8\uC774 \uB4E4\uC5B4\uC654\uC5B4\uC694.");
});
socket.on("passuser", function (_a) {
var username = _a.username;
Chat.server(username + "\uB2D8\uC774 \uB098\uAC14\uC5B4\uC694.");
});
socket.on("getuserlist", function (data) {
var buttonClickListener = function ($li, username, id) {
socket.emit("requestjoin", { targetId: id });
$(".activePull").removeClass();
$li.addClass("activePull");
Chat.server(username + "에게 게임신청을 했어요.");
};
var $lis = data
.map(function (userData) {
if (userData == null)
return;
var username = userData.username, id = userData.id;
var $li = $("<li />")
.text(username)
.data("id", id);
if (username != _this.username) {
var $button = $("<button>").text("게임 신청").addClass("btn-request");
$button.click(function () { return buttonClickListener($li, username, id); });
$li.append($button);
}
return $li;
});
$("#userlist").html($lis);
});
socket.on("servermessage", function (data) {
Chat.server(data.message);
});
socket.on("receivemessage", function (data) {
Chat.client(data.username, data.message);
});
socket.on("gamestart", function (_a) {
var enemyUsername = _a.enemyUsername;
var canStartGame = _this.game == undefined || _this.game.isGameEnd == true;
if (canStartGame) {
_this.game = new Game(socket, _this.username, enemyUsername);
}
else {
Chat.server(_this.game.enemyUsername + "\uACFC\uC758 \uAC8C\uC784\uC774 \uC544\uC9C1 \uB05D\uB098\uC9C0 \uC54A\uC558\uC5B4\uC694.");
}
});
};
return Socket;
}());
var Chat = /** @class */ (function () {
function Chat() {
}
Chat.server = function (message) {
var $li = $("<li></li>").text(message);
$("#messages").append($li);
Chat.moveBottom();
};
Chat.client = function (username, message) {
var $li = $("\n <li>\n <span class='username' /> : <span class='message'>\n </li>");
$li.find(".username").text(username);
$li.find(".message").text(message);
$("#messages").append($li);
Chat.moveBottom();
};
Chat.moveBottom = function () {
$("#messages").scrollTop($("#messages")[0].scrollHeight);
};
return Chat;
}());
var Game = /** @class */ (function () {
function Game(socket, username, ememyusername) {
this.socket = socket;
this.isGameEnd = false;
this.enemyUsername = ememyusername;
Chat.server(ememyusername + "과의 게임이 시작되었어요!");
$(".btn-request").fadeOut();
var bindClick = function ($target, axis) {
var x = axis[0], y = axis[1];
$target.text("H").click(function () {
console.log([x, y]);
socket.emit("draw", {
axis: [x, y]
});
});
};
$("#gamepan").slideDown().find("> div")
.each(function (x) {
$(this).find("> a").each(function (y) { bindClick($(this), [x, y]); });
});
this.bindSocketListener();
}
Game.prototype.bindSocketListener = function () {
var socket = this.socket;
var self = this;
socket.on("renewgamepan", function (_a) {
var gamepan = _a.gamepan;
gamepan.forEach(function (hori, x) {
return hori.forEach(function (cell, y) {
var textType = {
"1": "O",
"0": "H",
"-1": "X",
};
var text = textType[cell];
$("#gamepan").find("div").eq(x).find("a").eq(y)
.data("x", x).data("y", y)
.text(text);
console.log(x, y);
});
});
});
socket.on("gameend", function (_a) {
var state = _a.state;
var hideGamePan = function () { return $("#gamepan").slideUp(); };
var messageType = {
"win": "게임 승리!! 축하드려요!",
"lose": "윽... 져버렸네요...",
"draw": "비겼어요!",
};
var endMessage = messageType[state];
Chat.server(endMessage);
$(".btn-request").fadeIn();
setTimeout(hideGamePan, 3000);
self.isGameEnd = true;
self.removesocketListener();
});
};
Game.prototype.removesocketListener = function () {
$("#gamepan").find("a").off("click");
this.socket.off("gameend").off("renewgamepan");
};
return Game;
}());
var gamehtml = '<div id="gamepan"><div><a></a><a></a><a></a></div><div><a></a><a></a><a></a></div><div><a></a><a></a><a></a></div></div><div class="wrap"><ul id="userlist" class="scrollbox"></ul><ul id="messages" class="scrollbox"></ul><input id="chat" placeholder="메세지를 입력하세요..."/></div>';
$("#gamewindow").html(gamehtml);
var thisSocket = new Socket("https://banip.tk" + "/uncytt",mw.config.values.wgUserName);
$("#chat").keypress(function (e) {
if (e.key === "Enter" && $(this).val() != "") {
thisSocket.socket.emit("sendmessage", { message: $(this).val() });
$(this).val("");
}
});
});
// 여기까지 코드 입력 //
}
}
$( plugin_uncytick );
/* uncytick 끝 */
/** 플러그인 inputform***************************
* 완전한 입력기를 구현합니다. (베타)
* 버전 => 1.6.1
* 작성자 : [[사용자:Gustmd7410|Gustmd7410]]
* JSON => inputform = {"name":"inputform","descript":"완전한 입력기를 구현합니다. (베타)","version":"1.6.1","local":false,"creat":"Gustmd7410","state":"틀:입력 상자/플러그인","executable":true};
*/
function plugin_inputform(){
// 이부분에 코드 입력 //
mw.loader.using('oojs-ui-core').done(function () {
function toBool(value) {
switch (value) {
case undefined: return false;
case '': return true;
}
}
function toArray(value) {
if (value)
return value.split(' ');
else
return undefined;
}
function InpTable(table) {
this["case"] = {};
this["default"] = Object.assign({
prefix: '',
value: undefined,
suffix: '',
replace: [],
sub: [0]
}, table["default"]);
if (table["case"]) {
for (var value in table["case"]) {
this["case"][value] = Object.assign({}, this["default"], { value: this["default"].value || value }, table["case"][value]);
}
}
}
$('.input-form').each(function () {
var container = this;
$(this).html(new $('<form />', {
"class": $(this).data('class'),
id: $(this).data('id'),
style: $(this).data('style'),
'accept-charset': 'UTF-8',
autocomplete: toBool($(this).data('autocomplete')),
novalidate: toBool($(this).data('novalidate')),
html: $(this).html()
}));
$(this).children('form').submit(function (event) {
event.preventDefault();
var action = new URL('/w/index.php', location);
if (toBool($(container).data('pass')))
action.search = location.search;
if ($(container).data('get'))
new URLSearchParams($(container).data('get')).forEach(function (value, key) {
action.searchParams.set(key, value);
});
action.searchParams.set('title', $(container).data('title'));
$(this).children('.input-field').each(function () {
if (typeof ($(this).data('table')) == 'object') {
var name = $(this).data('name');
var rawval = $(this).find('input').val();
var table = new InpTable($(this).data('table'));
var cvttbl = table["case"][rawval] || table["default"];
var cvtval = (cvttbl.value || rawval).slice(cvttbl.sub[0], cvttbl.sub[1]);
cvttbl.replace.forEach(function (reparr) {
var regex = reparr[0].substr(1).split('/');
regex.pop();
regex = regex.join('/');
var flag = reparr[0].substr(1).split('/').reverse()[0];
cvtval = cvtval.replace(new RegExp(regex, flag), reparr[1]);
});
action.searchParams.set(name, cvttbl.prefix + cvtval + cvttbl.suffix);
}
else
action.searchParams.set($(this).data('name'), $(this).find('input').val());
});
location.href = action.href;
});
});
$('.input-field').each(function () {
$(this).html(new OO.ui.TextInputWidget({
accessKey: $(this).data('accessKey'),
autocomplete: toBool($(this).data('autocomplete')),
autofocus: toBool($(this).data('autofocus')),
classes: toArray($(this).data('classes')),
disabled: toBool($(this).data('disabled')),
flags: toArray($(this).data('flags')),
icon: $(this).data('icon'),
iconTitle: $(this).data('iconTitle'),
id: $(this).data('id'),
indicator: $(this).data('indicator'),
indicatorTitle: $(this).data('indicatorTitle'),
inputId: $(this).data('inputId'),
maxLength: Number($(this).data('maxLength')),
name: $(this).data('name'),
placeholder: $(this).data('placeholder'),
readOnly: toBool($(this).data('readOnly')),
required: toBool($(this).data('required')),
spellcheck: toBool($(this).data('spellcheck')),
tabIndex: Number($(this).data('tabIndex')),
text: $(this).data('text'),
title: $(this).data('title'),
type: $(this).data('type'),
validate: (function(container) {
if ($(container).data('validatetype') == 'RegExp') {
var value = $(container).data('validate').substr(1).split('/');
return RegExp(value[0], value[1]);
}
else
return $(container).data('validate');
})(this),
value: this.dataset.value || ''
}).$element);
if(toBool($(this).data('inline'))) $(this).find('*').css({
display: 'inline',
width: 'auto'
});
});
$('.input-button').each(function () {
$(this).html(new OO.ui.ButtonInputWidget({
accessKey: $(this).data('accessKey'),
classes: toArray($(this).data('classes')),
disabled: toBool($(this).data('disabled')),
flags: toArray($(this).data('flags')),
framed: toBool($(this).data('framed')),
icon: $(this).data('icon'),
iconTitle: $(this).data('iconTitle'),
id: $(this).data('id'),
indicator: $(this).data('indicator'),
indicatorTitle: $(this).data('indicatorTitle'),
inputId: $(this).data('inputId'),
label: $(this).data('label'),
name: $(this).data('name'),
tabIndex: Number($(this).data('tabIndex')),
text: $(this).data('text'),
title: $(this).data('title'),
type: $(this).data('type'),
value: $(this).data('value')
}).$element);
});
noPlugin('input');
});
// 여기까지 코드 입력 //
}
$( plugin_inputform );
/* inputform 끝 */