3,389
个编辑
MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
Salt lovely(留言 | 贡献) 小 (→所有页面: // Edit via Wikiplus) |
Salt lovely(留言 | 贡献) 小 (→mw.html.escape: // Edit via Wikiplus) |
||
| (未显示3个用户的5个中间版本) | |||
| 第1行: | 第1行: | ||
{{不完整|一晚上就搬完不可能的|只翻译了一半}} | |||
{{不完整|一晚上就搬完不可能的}} | |||
{{帮助文档难度/困难}} | {{帮助文档难度/困难}} | ||
{{浮动帮助菜单}} | {{浮动帮助菜单}} | ||
| 第23行: | 第22行: | ||
其中大部分以 '''wg''' 为前缀。 | 其中大部分以 '''wg''' 为前缀。 | ||
* | * 因为历史原因,这些变量是全局的js变量。若<code>$wgLegacyJavaScriptGlobals</code>为真,所以需要一个前缀以防变量名冲突。 | ||
* A subset of these names correspond to $wg_variable in PHP, but others are unrelated. | * A subset of these names correspond to $wg_variable in PHP, but others are unrelated. | ||
* | * 除了本列表中的名字意外,很多扩展还设置了额外的以wg开头的js配置变量。 | ||
你可以通过<code>mw.config</code>来访问这些值。 | 你可以通过<code>mw.config</code>来访问这些值。 | ||
| 第53行: | 第52行: | ||
|valign="top"|<code>wgArticlePath</code> | |valign="top"|<code>wgArticlePath</code> | ||
|valign="top"|字符串 | |valign="top"|字符串 | ||
|valign="top"| | |valign="top"|从根目录开始的本地路径, 用于引用文章。含有一个“$1”占位符,可以用页面标题替换来获取一个有效的页面URL。给定有效的页面标题<code>title</code>, 可以用<code>wgArticlePath.replace('$1', title)</code>获取有效URL。另见$wgArticlePath。 | ||
|valign="top"|MW 1.8+ | |valign="top"|MW 1.8+ | ||
|- | |- | ||
|valign="top"|<code>wgCaseSensitiveNamespaces</code> | |valign="top"|<code>wgCaseSensitiveNamespaces</code> | ||
|valign="top"|数组 | |valign="top"|数组 | ||
|valign="top"| | |valign="top"| MediaWiki中对大小写敏感的命名空间的ID。由<code>$wgCapitalLinks</code>和<code>$wgCapitalLinksOverrides</code> 这两个配置变量的值决定。<!-- I'm assuming; it would be good to have someone confirm this --> | ||
|valign="top"|MW 1.18+ (90234) | |valign="top"|MW 1.18+ (90234) | ||
|- | |- | ||
| 第68行: | 第67行: | ||
|valign="top"|<code>wgContentNamespaces</code> | |valign="top"|<code>wgContentNamespaces</code> | ||
|valign="top"|整数数组 | |valign="top"|整数数组 | ||
|valign="top"| | |valign="top"| MediaWiki看作是“内容名字空间”的名字空间ID。和配置变量<code>$wgContentNamespaces</code>的值等价, 没有加载好的话就是<code>0</code>。 | ||
|valign="top"|MW 1.23+ <small>(Git: 3d87e3a86bcb39d444ef916129dd48bf80b5bb31)</small> | |valign="top"|MW 1.23+ <small>(Git: 3d87e3a86bcb39d444ef916129dd48bf80b5bb31)</small> | ||
|- | |- | ||
| 第83行: | 第82行: | ||
|valign="top"|<code>wgEnableWriteAPI</code> | |valign="top"|<code>wgEnableWriteAPI</code> | ||
|valign="top"|布尔型 | |valign="top"|布尔型 | ||
|valign="top"|如果mw的写入API启用则为<code>true</code>,反之为<code>false</code> | |valign="top"|如果mw的写入API启用则为<code>true</code>,反之为<code>false</code>。如果<code>wgEnableAPI && !wgEnableWriteAPI</code>, 只有读取API会被启用。 | ||
|valign="top"|MW 1.12+ | |valign="top"|MW 1.12+ | ||
|- | |- | ||
| 第103行: | 第102行: | ||
|valign="top"|<code>wgScript</code> | |valign="top"|<code>wgScript</code> | ||
|valign="top"|字符串 | |valign="top"|字符串 | ||
|valign="top"| | |valign="top"| 到达主要脚本接入点的完全路径,从根部开始。包括带着扩展名的脚本名。在WMF Wiki上,一般是"/w/index.php"。另见$wgScript。 | ||
|valign="top"|MW 1.11+ | |valign="top"|MW 1.11+ | ||
|- | |- | ||
|valign="top"|<code>wgScriptPath</code> | |valign="top"|<code>wgScriptPath</code> | ||
|valign="top"|字符串 | |valign="top"|字符串 | ||
|valign="top"|<code>wgScript</code>的路径部分,结尾不是"/" | |valign="top"|<code>wgScript</code>的路径部分,结尾不是"/"。这是用于直接调用php接入点(如<code>index.php</code>或<code>api.php</code>)的路径。另见$wgScriptPath。 | ||
|valign="top"|MW 1.8+ | |valign="top"|MW 1.8+ | ||
|- | |- | ||
|valign="top"|<code>wgServer</code> | |valign="top"|<code>wgServer</code> | ||
|valign="top"|字符串 | |valign="top"|字符串 | ||
|valign="top"|服务器链接,结尾不是"/" | |valign="top"|服务器链接,结尾不是"/"。<code>wgServer + wgScriptPath + "/api.php"</code>。比如说,可以得到API脚本接入点的合法URL。 | ||
|valign="top"|MW 1.8+ | |valign="top"|MW 1.8+ | ||
|- | |- | ||
| 第135行: | 第134行: | ||
=== 所有页面 === | === 所有页面 === | ||
(根据用户/页面不同,这些值会变动。) | (根据用户/页面不同,这些值会变动。) | ||
{| class="wikitable" | {| class="wikitable sortable" | ||
! 名称 | ! 名称 | ||
! 类型 | ! 类型 | ||
| 第199行: | 第198行: | ||
| valign="top" |<code>wgPageName</code> | | valign="top" |<code>wgPageName</code> | ||
| valign="top" |字符串 | | valign="top" |字符串 | ||
| valign="top" | | | valign="top" |完整的页面名,包括翻译过的名字空间,如果名字空间有名字(主名字空间(0)没有),空格将被替换为下划线。使用<code>wgTitle</code>获取没有名字空间的页面名。 | ||
| valign="top" |MW 1.8+ | | valign="top" |MW 1.8+ | ||
|- | |- | ||
| valign="top" |<code>wgRedirectedFrom</code> | | valign="top" |<code>wgRedirectedFrom</code> | ||
| valign="top" |字符串 | | valign="top" |字符串 | ||
| valign="top" | | | valign="top" |显示重定向自的页面。如果页面不是重定向来的,就没有这个值(不在<code>mw.config</code>中)。格式与<code>wgPageName</code>相同。 | ||
| valign="top" |MW 1.19+ (104668) | | valign="top" |MW 1.19+ (104668) | ||
|- | |- | ||
| 第224行: | 第223行: | ||
| valign="top" |<code>wgRestrictionEdit</code> | | valign="top" |<code>wgRestrictionEdit</code> | ||
| valign="top" |字符串数组 或 无 | | valign="top" |字符串数组 或 无 | ||
| valign="top" | | | valign="top" |如果页面可以编辑(同时不是特殊页面)同时只有部分用户组用户可以编辑,数组包括了编辑这个页面所需的最低用户组。For semi-protected pages, it'd contain <code>["autoconfirmed"]</code>; for fully protected pages <code>["sysop"]</code>. If there are no explicit restrictions, the value is <code>[]</code> (an array with no elements). | ||
这个数组只包含''明确的''保护。名字空间级的保护(比如MediaWiki名字空间,见 $wgNamespaceProtection), 级联保护,或TitleBlacklist扩展的"moveonly"属性带来的"protections",不会显示在这个数组里;这种页面里,数组始终为<code>[]</code>,除非给这个页面的额外保护是专门添加的。 | |||
如果页面不存在,那么这个变量也不存在。 | |||
| valign="top" |MW 1.14+ | | valign="top" |MW 1.14+ | ||
|- | |- | ||
| valign="top" |<code>wgRestrictionMove</code> | | valign="top" |<code>wgRestrictionMove</code> | ||
| valign="top" |字符串数组 | | valign="top" |字符串数组 | ||
| valign="top" | | | valign="top" |如果页面可以移动(同时不是特殊页面)同时只有部分用户组用户可以移动,数组包括了移动这个页面所需的最低用户组。For semi-moveprotected pages, it'd contain <code>["autoconfirmed"]</code>; for fully moveprotected pages <code>["sysop"]</code>. If there are no explicit restrictions, the value is <code>[]</code> (an array with no elements). | ||
这个数组只包含''明确的''保护。名字空间级的保护(比如MediaWiki名字空间,见 $wgNamespaceProtection), 级联保护,或TitleBlacklist扩展的"moveonly"属性带来的"protections",不会显示在这个数组里;这种页面里,数组始终为<code>[]</code>,除非给这个页面的额外保护是专门添加的。 | |||
| valign="top" |MW 1.14+ | | valign="top" |MW 1.14+ | ||
|- | |- | ||
| valign="top" |<code>wgRevisionId</code> | | valign="top" |<code>wgRevisionId</code> | ||
| valign="top" |整数 | | valign="top" |整数 | ||
| valign="top" | | | valign="top" |当前浏览页面的版本的版本ID, 或版本对比页面右侧页面的版本ID(当diffonly=yes时为0, 这是一个bug: T231744)。版本对比页面有,特殊页面和历史页面为 0,其他地方不可用。 | ||
| valign="top" |MW 1.22+ <small>(git:7fa7b71eb3a5dd24e75865162e4c06a4a6012524)</small> | | valign="top" |MW 1.22+ <small>(git:7fa7b71eb3a5dd24e75865162e4c06a4a6012524)</small> | ||
|- | |- | ||
| 第351行: | 第350行: | ||
|} | |} | ||
--> | --> | ||
== mw.html == | == mw.html == | ||
=== mw.html.escape === | |||
HTML转义。 | |||
<pre>mw.html.escape( '< > \' & "' ); // Returns: &lt; &gt; &#039; &amp; &quot;</pre> | |||
== mw.msg == | == mw.msg == | ||
== mw.loader == | == mw.loader == | ||
=== mw.loader.addSource === | |||
== mw.user == | |||
== mw.Api == | |||
* 需要实例化才能使用。 | |||
* 大部分需要导入额外的JS才能使用。 | |||
=== plugins === | |||
* 需要导入对应的JS才能正常使用。 | |||
* '''混入的是mw.Api。''' | |||
; .category | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/category.html#mw-Api-plugin-category 文件] | |||
: getCategories( title : mw.Title|string ) : jQuery.Promise | |||
:: 获取页面的分类列表 | |||
:: 返回 jQuery.Promise | |||
::: done : Function : boolean|mw.Title[] | |||
:: 若没有分类,返回false | |||
: getCategoriesByPrefix( prefix : string ) : jQuery.Promise | |||
:: 获取以此为前缀的分类 | |||
:: 返回 jQuery.Promise | |||
::: done : Function : string[] | |||
:: 返回获取到的分类名 | |||
: isCategory( title : string ) : jQuery.Promise | |||
:: 检查某个分类是否存在 | |||
:: 返回 jQuery.Promise | |||
::: done : Function : boolean | |||
:: 存在返回true,否则返回false | |||
; .edit | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/edit.html#mw-Api-plugin-edit 文件] | |||
: create( title : mw.Title|string , params : Object , content : string ) : jQuery.Promise | |||
:: params : {summary : string} | |||
::: summary: 描述 | |||
:: 返回 jQuery.Promise | |||
::: done : Function : void | |||
: edit( title : mw.Title|string , transform : Function ) : jQuery.Promise | |||
:: | |||
: getEditToken( ) : jQuery.Promise | |||
:: | |||
: newSection( title, header, message, [additionalParams] ) : jQuery.Promise | |||
:: | |||
: postWithEditToken( params, [ajaxOptions] ) : jQuery.Promise | |||
:: | |||
; .login | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/login.html#mw-Api-plugin-login 文件] | |||
: login( username, password ) : jQuery.Promise | |||
; .messages | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/messages.html#mw-Api-plugin-messages 文件] | |||
: getMessages( messages, [options] ) : jQuery.Promise | |||
:: | |||
: loadMessages( messages, [options] ) : jQuery.Promise | |||
:: | |||
: loadMessagesIfMissing( messages, [options] ) : jQuery.Promise | |||
:: | |||
; .options | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/options.html#mw-Api-plugin-options 文件] | |||
: saveOption( name, value ) : jQuery.Promise | |||
:: | |||
: saveOptions( options ) : jQuery.Promise | |||
; .parse | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/parse.html#mw-Api-plugin-parse 文件] | |||
: parse( content, additionalParams ) : jQuery.Promise | |||
; .rollback | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/rollback.html#mw-Api-plugin-rollback 文件] | |||
: rollback( page, user, [params] ) : jQuery.Promise | |||
; .upload | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/upload.html#mw-Api-plugin-upload 文件] | |||
: chunkedUpload( file, data, [chunkSize], [chunkRetries] ) : jQuery.Promise | |||
:: | |||
: chunkedUploadToStash( file, [data], [chunkSize], [chunkRetries] ) : jQuery.Promise | |||
:: | |||
: processIframeResult( iframe ) : Object | |||
:: | |||
: upload( file, data ) : jQuery.Promise | |||
:: | |||
: uploadFromStash( filekey, data ) : jQuery.Promise | |||
:: | |||
: uploadToStash( file, [data] ) : jQuery.Promise | |||
:: | |||
; .user | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/user.html#mw-Api-plugin-user 文件] | |||
: assertCurrentUser( query ) : Object | |||
:: | |||
: getUserInfo( ) : jQuery.Promise | |||
:: | |||
; .watch | |||
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/watch.html#mw-Api-plugin-watch 文件] | |||
: unwatch( pages, [addParams] ) : jQuery.Promise | |||
:: | |||
: watch( pages, [addParams] ) : jQuery.Promise | |||
:: | |||
== mw. | == mw.Debug == | ||
== mw. | == mw.Feedback == | ||
== mw. | == mw.util == | ||
== mw的其他子项 == | == mw的其他子项 == | ||
一些不常用的或较为简单的东西。 | |||
=== mw.hook === | |||
;.add | |||
;.fire | |||
;.remove | |||
自己看源代码(原文如此)。 | |||
=== mw.log === | |||
console.log()的替代品,debug模式下启用。 | |||
=== mw.map === | |||
封装过的查找表,需要实例化才能用。 | |||
;.values | |||
: 一个包含所有变量的对象。如果初始化的时候'global'设为true,返回的其实是window对象。 | |||
;.exists(key) | |||
: 如果存在则返回true,反之返回false。 | |||
;.get(key, fallback) | |||
: 返回按键获取的值,没找到的话会返回第二个参数(如果第二个参数也没有,则返回null)。 | |||
;.set(key, value) | |||
: 创建或修改一个或多个键值。 | |||
=== mw.ui === | |||
* MCBBSWiki没这个。 | |||
** 在MediaWiki1.29后mw.ui完全废弃了,改为使用[[#OOui]]。 | |||
=== mw.Title === | |||
结构页面标题。 | |||
<pre> | |||
var t = new mw.Title( '文件:盐.png' ); // 实例化 | |||
t.getMain(); // "盐.png" | |||
t.getNamespaceId(); // 6 | |||
t.getNamespacePrefix(); // "文件:" | |||
</pre> | |||
=== mw.Uri === | |||
* MCBBSWiki似乎没这个。 | |||
<pre> | |||
new mw.Uri(); // 当前URI | |||
new mw.Uri(URL); // 指定URL的URI | |||
</pre> | |||
=== mw.notify === | |||
<pre> | |||
mw.notify( '这是一个通知' ); // 发送文字通知 | |||
mw.notify( mw.message( 'some-message' ) ); // 用i18n消息发送通知 | |||
mw.notify( $( '<span>这是一个<u>HTML</u>通知</span>' ) ); // 用jQuery实例发送HTML通知(DOM节点也行) | |||
mw.notify( '通知', { title: '标题' } ); // 给通知加一个标题 | |||
mw.notify( '通知', { autoHide: false } ); // 通知不会自行隐藏 | |||
mw.notify( '通知', { tag: 'asd' } ); // 给通知加一个标签 | |||
mw.notify( '通知:另一个', { tag: 'asd' } ); // 这个通知将会覆盖前一个相同标签的通知 | |||
</pre> | |||
== jQuery与插件 == | == jQuery与插件 == | ||
== OOui == | |||
使用这些特性之前,需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/core.html OOui核心]。 | |||
; OO.EmitterList | |||
: | |||
; OO.EventEmitter | |||
: | |||
; OO.Factory | |||
: | |||
; OO.Registry | |||
: | |||
; OO.SortedEmitterList | |||
: | |||
=== OO.ui === | |||
需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/windows.html#OO-ui Windows扩展]。 | |||
== OOui混入 == | |||
使用这些特性之前,需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/core.html OOui核心]和[https://doc.wikimedia.org/oojs-ui/master/js/source/windows.html#OO-ui Windows扩展]。 | |||