「MediaWiki:Forum.js」の版間の差分
編集の要約なし |
編集の要約なし |
||
| 233行目: | 233行目: | ||
headers: { 'Content-Type': 'application/json' }, | headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | body: JSON.stringify({ | ||
title: mw.config.get('wgPageName'), | title: mw.config.get('wgPageName'), | ||
text: newText, | |||
summary: `${msg.deletesummary} #${postId}` | |||
}) | }) | ||
}).then(r => r.json()).then(data => { | }).then(r => r.json()).then(data => { | ||
| 241行目: | 241行目: | ||
location.reload(); | location.reload(); | ||
} else { | } else { | ||
mw.notify(msg. | mw.notify(msg.deleteerror); | ||
} | } | ||
}).catch(() => { | }).catch(() => { | ||
mw.notify(msg. | mw.notify(msg.deleteerror); | ||
}); | }); | ||
}, | }, | ||
| 313行目: | 311行目: | ||
const anonParam = isAnon ? '|anon=1' : ''; | const anonParam = isAnon ? '|anon=1' : ''; | ||
content += `{{post|${mw.forum.username}|1|{{subst:#timel:Y/m/d H:i:s}}|4=${document.querySelector('#wpTextbox1').value}${anonParam}}}`; | content += `{{post|${mw.forum.username}|1|{{subst:#timel:Y/m/d H:i:s}}|4=${document.querySelector('#wpTextbox1').value}${anonParam}}}`; | ||
fetch('/mediawiki/forum-proxy.php', { | |||
method: 'POST', | |||
title: `${mw.forum.toppage}/${document.querySelector('#f-threadname').value}`, | headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ | |||
title: `${mw.forum.toppage}/${document.querySelector('#f-threadname').value}`, | |||
text: content, | |||
}). | summary: msg.createthreadsummary, | ||
location.href = `${mw.config.get('wgArticlePath').replace('$1', mw.forum.toppage)}/${document.querySelector('#f-threadname').value}`; | protect: true | ||
}). | }) | ||
}).then(r => r.json()).then(data => { | |||
if (data.result === 'Success') { | |||
location.href = `${mw.config.get('wgArticlePath').replace('$1', mw.forum.toppage)}/${document.querySelector('#f-threadname').value}`; | |||
} else { | |||
mw.notify(msg.posterror); | |||
} | |||
}).catch(() => { | |||
mw.notify(msg.posterror); | mw.notify(msg.posterror); | ||
}); | }); | ||
| 379行目: | 384行目: | ||
const anonParam = isAnon ? '|anon=1' : ''; | const anonParam = isAnon ? '|anon=1' : ''; | ||
// プロキシ経由でBot名義に編集する | |||
const postBody = { | |||
title: mw.config.get('wgPageName'), | title: mw.config.get('wgPageName'), | ||
summary: summary | |||
}; | |||
if (fedit) { | |||
postBody.text = source.replace(new RegExp(`\\{\\{post\\|(.*?)\\|${fedit}\\|(.*?)\\|4=((.|\n)*?)}}`), `{{post|$1|${fedit}|$2|4=${document.querySelector('#wpTextbox1').value}}}`); | |||
} else { | |||
}). | postBody.appendtext = `\n{{post|${mw.forum.username}|${lp}|{{subst:#timel:Y/m/d H:i:s}}|4=${document.querySelector('#wpTextbox1').value}${document.querySelector('#f-reply-cb').checked ? '|re=' + document.querySelector('#f-reply').value : ''}${anonParam}}}`; | ||
if (fedit) { | } | ||
fetch('/mediawiki/forum-proxy.php', { | |||
method: 'POST', | |||
headers: { 'Content-Type': 'application/json' }, | |||
body: JSON.stringify(postBody) | |||
}).then(r => r.json()).then(data => { | |||
if (data.result === 'Success') { | |||
if (fedit) { | |||
location.href = `${mw.util.getUrl()}#post-${fedit}`; | |||
} else { | |||
location.reload(); | |||
} | |||
} else { | } else { | ||
mw.notify(msg.posterror); | |||
document.querySelector('#f-post').disabled = false; | |||
} | } | ||
}). | }).catch(() => { | ||
mw.notify(msg.posterror); | mw.notify(msg.posterror); | ||
document.querySelector('#f-post').disabled = false; | document.querySelector('#f-post').disabled = false; | ||