사용자:나와그녀와그녀/연습장
// 이부분에 코드 입력 //
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).data('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');
});
// 여기까지 코드 입력 //