Note: After saving, you have to
bypass your browser's cache to see the changes.
Internet Explorer: press
Ctrl-F5 ,
Mozilla: hold down
Shift while clicking
Reload (or press
Ctrl-Shift-R ),
Opera/Konqueror: press
F5 ,
Safari: hold down
Shift + Alt while clicking
Reload ,
Chrome: hold down
Shift while clicking
Reload .
// CommonsHelper Helper (CH²) by Krimpet
// Released into the public domain
var ch2_wplanguage = "zh" ;
var ch2_wpproject = "wikipedia" ;
var ch2_chlanguage = "zh" ;
var ch2_edittitle_Prefix = "正在編輯Image:" ;
var ch2_edittitle_Postfix = "" ;
var ch2_string_SpecifyNewName = "新的檔案名稱?(可留空以使用原名):" ;
var ch2_string_UseWikiSense = "使用 WikiSense 搜尋可加入的分類?" ;
var ch2_string_RmExtCat = "移除現有的分類?" ;
var ch2_string_StartCommonsHelper = "開始 CommonsHelper" ;
var ch2_string_FinishedUploading = "上傳完成後點擊這裡" ;
var ch2_string_Done = "完成!請再檢查下面的項目以確保它們都是正確的,然後儲存這個頁面。" ;
var ch2_string_MoveToCommons = "移動圖像到共享資源" ;
var ch2_string_EditSummary = "使用 [[:en:User:Krimpet/CommonsHelper Helper|CH²]] [[Wikipedia:圖像轉移共享資源|移動圖像到維基媒體共享資源]]" ;
var ch2_template_ncd = "nowcommons" ;
var ch2_templates_copy = new Array (
"複製到維基媒體共享資源" ,
"移動到維基媒體共享資源" ,
"移動到共享資源" ,
"移動到Commons" ,
"到共享資源" ,
"到Commons"
);
var ch2_templates_embed = new Array (
"PD-USGov-HHS-CDC" ,
"PD-USGov-USDA-ARS"
);
var ch2 = null ;
var ch2frame = null , ch2framedoc = null ;
var newName = "" ;
var imageTitle = "" ;
function ch2Form () {
ch2 = document . createElement ( 'div' );
ch2 . setAttribute ( "style" , "margin-bottom: 2em;" );
ch2 . innerHTML = "<h2>" + ch2_string_MoveToCommons + "</h2><p><b>" + ch2_string_SpecifyNewName + " <input id=\"newnamet\"><br /><input id=\"csense\" type=checkbox value=1 /><b>" + ch2_string_UseWikiSense + "</b><br /><button onClick=\"ch2Start();\">" + ch2_string_StartCommonsHelper + "</button></p>" ;
document . getElementById ( 'wikiPreview' ). appendChild ( ch2 );
}
function ch2Start () {
newName = document . getElementById ( "newnamet" ). value ;
var sense = document . getElementById ( "csense" ). checked ;
var rmextcat = document . getElementById ( "crmextcat" ). checked ;
ch2 . innerHTML = "<iframe name=\"CH2iframe\" id=\"CH2iframe\" height=\"300px\" width=\"100%\"></iframe><br/><button onClick=\"ch2Finalize()\">" + ch2_string_FinishedUploading + "</button>" ;
ch2frame = document . getElementById ( "CH2iframe" );
ch2framedoc = ch2frame . contentDocument ;
if ( ch2framedoc == undefined || ch2framedoc == null )
ch2framedoc = ch2frame . contentWindow . document ;
ch2framedoc . open ();
ch2framedoc . write ( "請輸入一個維基百科語言代號及圖像名稱,它會自動產生一個用以複製到共享資源上傳表格的圖像描述。</small><br/><form action=\'http://tools.wikimedia.de/~magnus/commonshelper.php?interface=" + ch2_chlanguage + "\' method=\'post\'>語言代號:<input type=text name=language value=\'" + ch2_wplanguage + "\' cols=4/><br/>圖像名稱:<input type=text name=image value=\'" + imageTitle + "\' cols=30/><br/>新名稱:<input type=text name=newname value=\'" + newName + "\' cols=30/>(僅供直接上傳用;可留空以使用原名)<br/>計劃:<input type=text name=project value=\'" + ch2_wpproject + "\' cols=30/>(也可以是維基教科書或維基文庫)<br/><input type=checkbox name=commonsense value=1 " + ( sense ? "checked" : "" ) + " />使用 WikiSense 搜尋可加入的分類<br/><input type=checkbox name=remove_categories value=0 " + ( rmextcat ? "checked" : "" ) + " />移除現有的分類<br/><input type=submit name=doit value=\'Get text\'/></form><script>document.forms[0].doit.click();</script>" );
ch2framedoc . close ();
}
function ch2Finalize () {
ncd = "{{" + ch2_template_ncd + ( newName != "" ? "|Image:" + newName : "" ) + "}}" ;
editBox = document . editform . wpTextbox1 ;
for ( var i = 0 ; i < ch2_templates_copy . length ; i ++ )
editBox . value = editBox . value . replace ( "\{\{" + ch2_templates_copy [ i ] + "\}\}" , ncd );
for ( var i = 0 ; i < ch2_templates_embed . length ; i ++ )
editBox . value = editBox . value . replace ( "\{\{" + ch2_templates_embed [ i ] + "\}\}" , "\{\{" + ch2_templates_embed [ i ] + "|commons=" + ncd + "\}\}" );
if ( editBox . value . indexOf ( ncd ) == - 1 )
editBox . value += "\n" + ncd ;
document . editform . wpSummary . value = ch2_string_EditSummary ;
ch2 . innerHTML = "<b>" + ch2_string_Done + "</b>" ;
}
function ch2Init () {
if ( typeof ch2I18N != "undefined" )
ch2I18N ();
if ( wgNamespaceNumber == 6 ) {
if ( wgAction == "edit" ) {
if ( window . location . href . search ( "&ch2=yes" ) != - 1 ) {
ch2Form ();
} else {
mw . util . addPortletLink ( "p-cactions" , "javascript:ch2Form()" , ch2_string_MoveToCommons , "ca-ch2" );
}
} else {
mw . util . addPortletLink ( "p-cactions" , mw . config . get ( 'wgServer' ) + mw . config . get ( 'wgScript' ) + "?title=" + encodeURIComponent ( wgPageName ) + "&action=edit&ch2=yes" , ch2_string_MoveToCommons , "ca-ch2" );
}
}
}
addOnloadHook ( ch2Init );