// This javascript prevents carelessly submission (hitting Enter at summary field).
// To enable, copy and paste this script to a subpage of your user page.
// 2004-07-30: New feature: Replace Fullwidth comma (U+FF0C) to Ideographic comma (U+3001)
// and Fullwidth full stop (U+FF0E) to Ideographic full stop (U+3002)
// If you don't need this feature, use the past version.
// This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
// You can use/modify/redistribute without any permission.
var submitchecker_buttonclicked = false;
var confirm_prompt = "Textarea contains “\uFF0C”(U+FF0C) and/or “\uFF0E”(U+FF0E).\nReplace them?";
var confirm_result = null;
function install_submitchecker() {
var f = document.getElementById("editform");
if(f) {
var inputs = f.getElementsByTagName("input");
for(var i = 0; i < inputs.length; ++i)
if(inputs[i].type == "submit")
inputs[i].onclick = submitchecker_nocheck;
f.onsubmit = submitchecker;
}
}
function submitchecker() {
var edit = document.getElementById("editform").getElementsByTagName("textarea")[0];
if(edit && /[\uFF0C\uFF0E]/.test(edit.value)) {
var r;
if(window.execScript) {
window.execScript(
"confirm_result = MsgBox(confirm_prompt,vbYesNoCancel)",
"VBScript");
if(confirm_result == 2) return false;
r = (confirm_result == 6);
} else {
r = prompt(confirm_prompt, "yes");
if(!r) return false;
r = /^[yY]/.test(r);
}
if(r) {
edit.value = edit.value.replace(/\uFF0C/g, '\u3001').replace(/\uFF0E/g, '\u3002');
}
}
if(submitchecker_buttonclicked) return true;
return confirm("Are you sure you want to submit your changes?");
}
function submitchecker_nocheck(e) {
if(e && e.target) {
var name = e.target.name;
if(name != "wpSave" && name != "wpPreview") return true;
}
submitchecker_buttonclicked = true;
return true;
}
if(window.attachEvent) window.attachEvent("onload", install_submitchecker);
else if(window.addEventListener) window.addEventListener("load", install_submitchecker, false);
// restore helper
function install_restore_helper() {
var e, t, p, b;
if(!(e = document.getElementById('undelete'))) return;
if(!(t = e.getElementsByTagName('h2')[1])) return;
p = document.createElement('p');
b = document.createElement('button');
b.type = 'button';
b.onclick = restore_select_all;
b.appendChild(document.createTextNode('Check all'));
p.appendChild(b);
p.appendChild(document.createTextNode(' '));
b = document.createElement('button');
b.type = 'button';
b.onclick = restore_select_reverse;
b.appendChild(document.createTextNode('Reverse checks'));
p.appendChild(b);
e.insertBefore(p, t.nextSibling);
}
function restore_select_all() {
var e, i;
if(!(e = document.getElementById('undelete'))) return;
e = e.getElementsByTagName('input');
for(i = 0; i < e.length; ++i)
if(e[i].type == 'checkbox') e[i].checked = true;
return false;
}
function restore_select_reverse() {
var e, i;
if(!(e = document.getElementById('undelete'))) return;
e = e.getElementsByTagName('input');
for(i = 0; i < e.length; ++i)
if(e[i].type == 'checkbox') e[i].checked = !e[i].checked;
return false;
}
if(window.attachEvent) window.attachEvent("onload", install_restore_helper);
else if(window.addEventListener) window.addEventListener("load", install_restore_helper, false);
//log
function addlogtab()
{
// get title from URL
var u = location.href;
if(/[\?&]title=([^&]+)/.test(u)) u = RegExp.$1;
else if(/\/wiki\/([^\?]+)/.test(u)) u = RegExp.$1;
else return;
// insertion point of toolbox
var lit = document.getElementById('t-recentchangeslinked');
if(!lit) lit = document.getElementById('t-whatlinkshere');
// if not found, we're in special page
if(!lit) return;
// insertion point of actions tab
var act = document.getElementById('p-cactions');
act = act.getElementsByTagName('ul')[0];
// get namespace number
var ns = document.body.className.split(' ');
for(var i = 0; i < ns.length; ++i) {
var r = /^ns-([0-9]+)$/.exec(ns[i]);
if(r) { ns = parseInt(r[1]); break; }
}
if(typeof ns != 'number') return;
// purge cache
a = document.createElement('a');
a.appendChild(document.createTextNode('Purge cache'));
a.setAttribute('href', '/wiki/' + u + '?action=purge');
a.setAttribute('title', decodeURI(u));
li = document.createElement('li');
li.appendChild(a);
lit.parentNode.insertBefore(li, lit.nextSibling);
// User: or User_talk:
if(ns == 2 || ns == 3) {
// strip subpage
var user = decodeURI(u).replace(/^[^:]+:/, '').replace(/\/.*/, '');
// User's log
a = document.createElement('a');
a.appendChild(document.createTextNode('User log'));
a.setAttribute('href', '/wiki/Special:Log?user=' + encodeURI(user));
a.setAttribute('title', 'User:' + user + "'s log");
li = document.createElement('li');
li.appendChild(a);
lit.parentNode.insertBefore(li, lit.nextSibling);
// IP address
var m = /^\d+\.\d+\.\d+\.\d+$/.exec(user);
if(m) {
a = document.createElement('a');
a.appendChild(document.createTextNode('whois'));
a.setAttribute('href', 'http://linky.wikipedia.jp/whois?key=' + encodeURI(user));
a.setAttribute('title', 'whois query for ' + user);
li = document.createElement('li');
li.appendChild(a);
act.appendChild(li);
}
}
// Page log
a = document.createElement('a');
a.appendChild(document.createTextNode('Page log'));
a.setAttribute('href', '/wiki/Special:Log?page=' + u);
a.setAttribute('title', decodeURI(u));
li = document.createElement('li');
li.appendChild(a);
lit.parentNode.insertBefore(li, lit.nextSibling);
// Image: or Image_talk:
if((ns == 6 || ns == 7) && location.host != 'commons.wikimedia.org') {
var img = u.replace(/^[^:]+:/, (ns == 6 ? 'Image:' : 'Image_talk:'));
// link to commons
a = document.createElement('a');
a.appendChild(document.createTextNode('commons'));
a.setAttribute('href', 'http://commons.wikimedia.org/wiki/' + img);
a.setAttribute('title', 'commons:' + decodeURI(img));
li = document.createElement('li');
li.appendChild(a);
act.appendChild(li);
}
}
$(addlogtab);
// *** CUSTOMIZE SECTION
var logoutconfirm_message = "!!ATTENTION!!\nAre you sure you want to log out?";
// ***
function install_logoutconfirm() {
var e = document.getElementById('pt-logout');
e = e.getElementsByTagName('a')[0];
if(e.addEventListener) e.addEventListener("click", logoutconfirm, false);
else if(e.attachEvent) e.attachEvent("onclick", logoutconfirm);
}
function logoutconfirm(e) {
if(confirm(logoutconfirm_message)) return true;
if(e.preventDefault) e.preventDefault();
else if(window.event) event.returnValue = false;
return false;
}
$(install_logoutconfirm);
// *** CUSTOMIZE SECTION
var useralert_message = 'ATTENTION: This page is user page. Are you sure you want to edit?';
// ***
$(function() {
if(wgCanonicalNamespace != 'User') return;
if(!document.getElementById('editform')) return;
if(wgUserName == wgTitle.split('/')[0]) return;
var div = document.createElement('div');
div.setAttribute('class', 'usermessage');
div.setAttribute('style', 'display:block');
div.innerHTML = useralert_message;
var s = document.getElementById('contentSub');
s.parentNode.insertBefore(div, s.nextSibling);
});
// This script is under public domain, and comes with ABSOLUTELY NO WARRANTY.
// You can use/modify/redistribute without any permission.
function addvfd()
{
var u, p, s, mode;
if(!document.getElementById('editform')) return;
u = location.href;
if(/[\?&]title=([^&]+)/.test(u)) u = RegExp.$1;
else if(/\/wiki\/([^\?]+)/.test(u)) u = RegExp.$1;
else return;
u = decodeURI(u);
if(wgCanonicalNamespace == 'User_talk') mode = 'usertalk';
else if(/^Wiktionary:今日の単語\//i.test(u)) mode = 'wotd';
else if(wgCanonicalNamespace == 'User') mode = 'user';
else if(wgCanonicalNamespace == 'Category') mode = 'category';
else return;
p = document.createElement('p');
s = '<select size="1" id="reqInsertSel">';
if(mode == 'usertalk') {
s += '<option value="Welcome">ようこそ</option>';
s += '<option value="WelcomeIP">ようこそIP</option>';
s += '<option value="Preview">プレビュー</option>';
s += '<option value="Sign">sign</option>';
s += '<option value="Edit">編集方針</option>';
s += '<option value="test">test</option>';
s += '<option value="test2">test2</option>';
s += '<option value="test3">test3</option>';
s += '<option value="test4">test4</option>';
s += '<option value="Blocked">Blocked</option>';
s += '<option value="3rr">3RR</option>';
} else if(mode == 'wotd') {
s += '<option value="wotd">wotd</option>';
} else if(mode == 'user') {
s += '<option value="UsernameBlock">UsernameBlock</option>';
s += '<option value="sharedaccount">Sharedaccount</option>';
} else if(mode == 'category') {
s += '<option value="catpath">CategoryPath</option>';
}
s += '</select> <button type="button" onclick="reqInsert()">挿入</button>';
p.innerHTML = s;
s = document.getElementById('contentSub');
s.parentNode.insertBefore(p, s.nextSibling);
}
function reqInsert() {
var e, s, pre, post, a;
e = document.getElementById('editform');
s = document.getElementById('reqInsertSel');
switch(s.options[s.selectedIndex].value) {
case "Welcome":
pre = "";
post = "\u007B\u007Bsubst:Welcome}}";
e.wpSummary.value = "ウィクショナリーへようこそ";
e.wpMinoredit.checked = false;
break;
case "WelcomeIP":
pre = "";
post = "\u007B\u007Bsubst:ようこそIP}}";
e.wpSummary.value = "ウィクショナリーへようこそ";
e.wpMinoredit.checked = false;
break;
case "Preview":
pre = "";
post = "\u007B\u007Bsubst:Preview}}";
e.wpSummary.value = "プレビュー機能のお知らせ";
e.wpMinoredit.checked = false;
break;
case "Sign":
pre = "";
post = "\u007B\u007Bsubst:sign}}";
e.wpSummary.value = "発言時の署名のお願い";
e.wpMinoredit.checked = false;
break;
case "Edit":
pre = "";
post = "\u007B\u007Bsubst:User:Ninomy/あいさつ/編集方針}}";
e.wpSummary.value = "編集方針を守ってください";
e.wpMinoredit.checked = false;
break;
case "test":
pre = "";
post = "\u007B\u007Bsubst:test}}";
e.wpSummary.value = "お知らせ";
e.wpMinoredit.checked = false;
break;
case "test2":
pre = "";
post = "\u007B\u007Bsubst:test2}}";
e.wpSummary.value = "注意";
e.wpMinoredit.checked = false;
break;
case "test3":
pre = "";
post = "\u007B\u007Bsubst:test3}}";
e.wpSummary.value = "警告";
e.wpMinoredit.checked = false;
break;
case "test4":
pre = "";
post = "\u007B\u007Bsubst:test4}}";
e.wpSummary.value = "最後のお願い";
e.wpMinoredit.checked = false;
break;
case "Blocked":
pre = "";
post = "\u007B\u007Bsubst:Blocked}}--\u007E\u007E\u007E\u007E";
e.wpSummary.value = "Blocked";
e.wpMinoredit.checked = false;
break;
case "3rr":
pre = "";
post = "\u007B\u007Bsubst:3rr| (page) }}";
e.wpSummary.value = "Blocked due to 3rr";
e.wpMinoredit.checked = false;
break;
case "wotd":
pre = "";
post = "\u007B\u007Bwotd||||2007|2|}}";
e.wpSummary.value = "";
e.wpMinoredit.checked = true;
break;
case "UsernameBlock":
pre = "\u007B\u007BUsernameBlock}}";
post = "";
e.wpSummary.value = "\u007B\u007BUsernameBlock}}";
e.wpMinoredit.checked = false;
break;
case "sharedaccount":
pre = "\u007B\u007BSharedaccount}}";
post = "";
e.wpSummary.value = "\u007B\u007BSharedaccount}}";
e.wpMinoredit.checked = false;
break;
case "catpath":
pre = "\u007B\u007Bcatpath|}}";
post = "";
e.wpSummary.value = "Category path";
e.wpMinoredit.checked = false;
break;
default:
return;
}
e.wpTextbox1.value = e.wpTextbox1.value.replace(/^[^\n]+/, "$&\n" + pre) + post + "\n";
e.wpSave.focus();
}
$(addvfd);