Site Notice
hello, world
Difference between revisions of "MediaWiki:Gadget-WikiForum/theme.default.js"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
Line 1: | Line 1: | ||
/** | /** | ||
− | * @ | + | * @function theme.default 标准的官方主题 |
− | * @ | + | * @param {Object} ctx |
− | * @ | + | * @param {jQuery<Element>} ctx.fn.newThreadArea |
− | * | + | * @param {jQuery<Element>} ctx.fn.newReplyArea |
+ | * @param {Object} ctx.meta | ||
* | * | ||
− | * @ | + | * @param {Function} next |
− | |||
*/ | */ | ||
+ | mw.hook('WikiForum.theme').add(next => { | ||
+ | var allForumsContainer = ctx => { | ||
+ | return $('<div>', { class: 'wiki-forum-all-container' }) | ||
+ | } | ||
− | + | var forumContainer = ctx => { | |
− | + | return $('<div>', { class: 'wiki-forum', 'data-forumid': ctx.forumid }) | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | var forumContainer = | ||
− | return $('<div>', { | ||
− | |||
− | |||
− | } | ||
− | var firstThread = | + | var firstThread = ctx => { |
− | return $('<div>', { | + | return $('<div>', { class: 'forum-thread forum-first' }).append( |
− | + | $('<div>', { class: 'forum-before' }).append( | |
− | + | $('<h3>', { class: 'forum-title', text: ctx.title }), | |
− | + | $('<div>', { class: 'forum-user' }).append( | |
− | + | $('<span>', { class: 'forum-user-link' }).append( | |
− | + | $('<a>', { | |
− | + | text: ctx.meta.userAuthor, | |
− | + | href: mw.util.getUrl('User:' + ctx.meta.userAuthor), | |
− | + | }) | |
− | + | ) | |
− | + | ) | |
− | + | ), | |
− | + | $('<div>', { class: 'forum-content', html: ctx.content }), | |
− | + | $('<div>', { class: 'forum-after' }).append( | |
− | + | $('<i>', { | |
− | + | class: 'post-date', | |
− | + | text: new Date(ctx.meta.timePublish).toLocaleString(), | |
− | + | }) | |
− | + | ), | |
− | + | ctx.fn.newThreadArea | |
− | + | ) | |
− | + | } | |
− | |||
− | } | ||
− | var normalThread = | + | var normalThread = ctx => { |
− | return $('<div>', { | + | return $('<div>', { class: 'forum-thread' }).append( |
− | + | $('<div>', { class: 'forum-before' }).append( | |
− | + | $('<div>', { class: 'forum-user' }).append( | |
− | + | $('<span>', { class: 'forum-user-link' }).append( | |
− | + | $('<a>', { | |
− | + | text: ctx.meta.userAuthor, | |
− | + | href: mw.util.getUrl('User:' + ctx.meta.userAuthor), | |
− | + | }) | |
− | + | ) | |
− | + | ) | |
− | + | ), | |
− | + | $('<div>', { class: 'forum-content', html: ctx.content }), | |
− | + | $('<div>', { class: 'forum-after' }).append( | |
− | + | $('<i>', { | |
− | + | class: 'post-date', | |
− | + | text: new Date(ctx.meta.timePublish).toLocaleString(), | |
− | + | }), | |
− | + | ctx.fn.newReplyArea | |
− | + | ) | |
− | + | ) | |
− | } | + | } |
− | next && next({ | + | next && |
− | + | next({ | |
− | + | allForumsContainer, | |
− | + | forumContainer, | |
− | + | // beforeForum, | |
− | }) | + | firstThread, |
− | + | normalThread, | |
− | + | // afterForum, | |
− | + | }) | |
+ | }) |
Revision as of 22:09, 28 December 2020
/**
* @function theme.default 标准的官方主题
* @param {Object} ctx
* @param {jQuery<Element>} ctx.fn.newThreadArea
* @param {jQuery<Element>} ctx.fn.newReplyArea
* @param {Object} ctx.meta
*
* @param {Function} next
*/
mw.hook('WikiForum.theme').add(next => {
var allForumsContainer = ctx => {
return $('<div>', { class: 'wiki-forum-all-container' })
}
var forumContainer = ctx => {
return $('<div>', { class: 'wiki-forum', 'data-forumid': ctx.forumid })
}
var firstThread = ctx => {
return $('<div>', { class: 'forum-thread forum-first' }).append(
$('<div>', { class: 'forum-before' }).append(
$('<h3>', { class: 'forum-title', text: ctx.title }),
$('<div>', { class: 'forum-user' }).append(
$('<span>', { class: 'forum-user-link' }).append(
$('<a>', {
text: ctx.meta.userAuthor,
href: mw.util.getUrl('User:' + ctx.meta.userAuthor),
})
)
)
),
$('<div>', { class: 'forum-content', html: ctx.content }),
$('<div>', { class: 'forum-after' }).append(
$('<i>', {
class: 'post-date',
text: new Date(ctx.meta.timePublish).toLocaleString(),
})
),
ctx.fn.newThreadArea
)
}
var normalThread = ctx => {
return $('<div>', { class: 'forum-thread' }).append(
$('<div>', { class: 'forum-before' }).append(
$('<div>', { class: 'forum-user' }).append(
$('<span>', { class: 'forum-user-link' }).append(
$('<a>', {
text: ctx.meta.userAuthor,
href: mw.util.getUrl('User:' + ctx.meta.userAuthor),
})
)
)
),
$('<div>', { class: 'forum-content', html: ctx.content }),
$('<div>', { class: 'forum-after' }).append(
$('<i>', {
class: 'post-date',
text: new Date(ctx.meta.timePublish).toLocaleString(),
}),
ctx.fn.newReplyArea
)
)
}
next &&
next({
allForumsContainer,
forumContainer,
// beforeForum,
firstThread,
normalThread,
// afterForum,
})
})