跳转到内容

MediaWiki:Gadget-EditCommon.js

维基百科,自由的百科全书

这是本页的一个历史版本,由Shinjiman留言 | 贡献2008年8月14日 (四) 11:55 (自 MediaWIki:Common.js 中移入)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//<source lang="javascript">

/*

== 編輯工具欄 ==
*/

/**
 * tip for custom edittools
 * 
 * Maintainers: fdcn@zh.wikipedia
 */
hookEvent("load",function(){
	var wpEditToolbar=document.getElementById("toolbar");
	if(!wpEditToolbar){return;}

	// 增加对未注册用户的提示
	if(!mwCustomEditButtons.length){
		wpEditToolbar.appendChild( createElement("a","扩展编辑按钮?",{
			'href':getWikiPath('Wikipedia:維基百科工具/編輯工具'),
			'title':wgULS('注册一个用户,即可以定制自己的编辑按钮','註冊一個賬號,即可以定制自己的編輯按鈕'),
			'styles':{'fontSize':'smaller','marginLeft':'1em'}
		}));
	}

	// 有重複按鈕的提示
	if(mwCustomEditButtons.state=='rID'){
		wpEditToolbar.appendChild( createElement("span"," ! ",{
			'title':wgULS('你选择的编辑按钮扩展可能有重复的按钮','你選擇的編輯按鈕擴展可能有重複的按鈕'),
			'styles':{'color':'red','cursor':'pointer'}
		}));
	}


	//增加編輯摘要的下拉選單
	var wpSummaryLabel=document.getElementById("wpSummaryLabel");
	if(!wpSummaryLabel){return;}
	var form = document.getElementById('editform');
	var summarys={};
	var i=0;
	function add(label,summary){
		var val='summary'+(i++);
		summarys[val]=summary;
		var option=new Option(label,val);
		return menu.options[menu.options.length]=option;
	}
	var menu=createElement(
		"select",
		[new Option(wgULS("摘要类型","摘要類型"))],
		{id:"summaryMenu",size:1,events:{'change':function(){
			var key=menu.options[menu.selectedIndex].value;
			var s=summarys[key];
			if(s){form.wpSummary.value += ' '+s;}
			menu.selectedIndex=0;
		}}}
	);
	add( wgULS('新条目','新條目'),         wgULS('新条目','新條目')                                 );
	add( wgULS('修饰语句','修飾語句'),     wgULS('修饰语句','修飾語句')                             );
	add( wgULS('修正笔误','修正筆誤'),     wgULS('修正笔误','修正筆誤')                             );
	add( wgULS('内容扩充','內容擴充'),     wgULS('内容扩充','內容擴充')                             );
	add( '排版',                           wgULS('调整格式、排版','調整格式、排版')                 );
	add( wgULS('段落章节','段落章節'),     wgULS('移动或调整段落章节','移動或調整段落章節')         );
	add( wgULS('内部链接','內部連結'),     wgULS('增加或调整内部链接','增加或調整內部連結')         );
	add( wgULS('跨语言链接','跨語言連結'), wgULS('增加或调整跨语言链接','增加或調整跨語言連結')     );
	add( wgULS('分类','分類'),             wgULS('增加或调整分类','增加或調整分類')                 );
	add( wgULS('小作品标签','小作品標籤'), wgULS('增加或调整小作品标签','增加或調整小作品標籤')     );
	add( wgULS('字词转换','字詞轉換'),     wgULS('增加或调整字词转换代码','增加或調整字詞轉換代碼') );
	add( wgULS('消歧义','消歧義'),         wgULS('消歧义','消歧義')                                 );
	add( wgULS('维基化','維基化'),         wgULS('维基化','維基化')                                 );
	add( wgULS('标识删除','標識刪除'),     wgULS('提交删除讨论或速删','提交刪除討論或速刪')         );
	add( wgULS('侵权','侵權'),             wgULS('提交侵权删除','提交侵權刪除')                     );
	add( wgULS('欢迎','歡迎'),             wgULS('欢迎用户','歡迎用戶')                             );
	add( '警告',                           wgULS('警告用户','警告用戶')                             );
	wpSummaryLabel.appendChild(menu);

	//加入對摘要框的限制,以適應中文UTF-8的字節數
	var summaryinput=document.getElementById("wpSummary");
	if(summaryinput && summaryinput.maxLength)summaryinput.maxLength=83;

	//在提交新段落時,讓主題欄在特定情況下失效
	if(document.getElementById('no-new-title') && document.editform.wpSection.value=="new") {
		menu.disabled=true;
		if(summaryinput) summaryinput.disabled=true;
	}

});

/*

== 强制预览 ==
*/
if(wgAction=="edit") hookEvent("load", function(){

	if ( wgUserGroups.join().indexOf("autoconfirmed")==-1 || (document.editform.wpSection.value=="new" && document.getElementById('cannot-submit')) ) {
		var saveButton = document.getElementById("wpSave");
		if (!saveButton) return;
		saveButton.disabled = true;
		saveButton.value += wgULS(" (预览后可用)"," (預覽後可用)");
		saveButton.style.fontWeight = "normal";
		document.getElementById("wpPreview").style.fontWeight = "bold";
	}

});

/*

== 取消修訂編輯摘要修正 ==
*/
/**
  fix edit summary prompt for undo
  this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the edit summary unchanged
  this was added by [[:en:User:Deskana]], code by [[:en:User:Tra]]
*/
addOnloadHook(function () {
	var autoSummary=document.getElementsByName('wpAutoSummary')[0];
	if (document.location.search.indexOf("undo=") != -1 && autoSummary)
	{ autoSummary.value=''; }
})

//</source>