User:Joshurtree/talkthread.js
//<pre><nowiki>
function createMessage(section) {
var edit = document.getElementById('wpTextBox1');
var replyToPos = document.URL.lastIndexOf('replyto=');
edit.value += '{{msg start|id=' + wgArticleId;
if (replyToPos != -1) {
var replyto = document.URL.slice(replyToPos + 8);
edit.value += '|replyto=' + replyto;
document.getElementById('wpSummary').value += 'Reply to ' + replyto;
}
edit.value += '}}\n';
edit.value += '<!--- Insert message here --->\n';
edit.value += '{{msg end|signature=~~~~|username='
+ wgUserName + '|section=' + section + '}}';
}
function addlilink(tabs, url, name, id, title, key){
var na = document.createElement('a');
na.href = url;
na.appendChild(document.createTextNode(name));
var li = document.createElement('li');
if(id) li.id = id;
li.appendChild(na);
tabs.appendChild(li);
if(id)
{
if(key && title)
{
ta[id] = [key, title];
}
else if(key)
{
ta[id] = [key, ''];
}
else if(title)
{
ta[id] = ['', title];
}
}
// re-render the title and accesskeys from existing code in wikibits.js
akeytt();
return li;
}
function addTab(url, name, id, title, key){
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
return addlilink(tabs, url, name, id, title, key);
}
function collapseDescendants() {
alert("collapseDescendants");
}
function showThisThread() {
alert("showThread");
}
function setupCollapsing(collapsed) {
var headers = document.getElementsByName("id");
var collapseDesc = document.createElement("a");
collapseDesc.href = "javascript::collapseDescendants()";
collapseDesc.innerHTML = "↑";
collapseDesc.title = "Collapse descendants";
var showThread = document.createElement("a");
showThread.href = "javascript::showThisThread()";
showThread.innerHTML = "↓";
showThread.title = "Show this thread only";
for (var i = 0; i < headers.length; ++i) {
headers[i].insertBefore(headers[i].firstChild, showThread);
headers[i].insertBefore(headers[i].firstChild, collapseDesc);
}
}
function countSections(url) {
var article = window.open(url, "_blank", "directories=no, height=100, location=no, menubar=no, scrollbars=no, resizable=no, titlebar=no, statusbar=no, toolbar=no, width=no");
return article.document.getElementsByTagName("h2").length + 1;
}
$(function() {
window.alert("test");
var addSection = document.getElementById('ca-addsection');
var section = document.getElementsByName('wpSection');
var edit = document.getElementById('wpTextBox1');
if (addSection && edit == null) {
var name = 'Start thread';
addTab(url, name, 'usStartThread', name, null);
setupCollapsing(false);
} else if (document.URL.indexOf("replyto") != -1) {
createMessage(section[0].value);
} else if (document.URL.indexOf("sectionnum=") != -1) {
var url = document.URL;
var sectionNum =
url.slice(parseInt(url.indexOf("sectionnum=")) + 11);
if (isFinite(sectionNum)) {
var sectionName = prompt("Enter new section name", "");
if (sectionName != null && sectionName != "") {
edit.value += '\n== ' + sectionName + ' ==\n';
document.getElementById("wpSummary").value
+= "/* " + sectionName + " */";
createMessage(sectionNum);
}
}
}
});
//</nowiki></pre>
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.