משתמש:Yonidebest/monobook.js/archive.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
//
// מאפשר לבצע ארכוב אוטומטי
// נכתב על ידי [[User:Yonidebest]]
//
var defualtPrefixArchive = 'ארכיון';
// load the talk page in edit mode
function archiveUserPageStage1() {
var archivename = document.getElementById('archivename').value;
var numberoftalks = document.getElementById('numberoftalks').value;
if (!archivename || archivename == '') {
alert("יש למלא את שם הארכיון.");
return;
}
if (!numberoftalks || numberoftalks == '') numberoftalks = 'all';
document.location = 'http://he.wikipedia.org/w/index.php?title=User Talk:' + encodeURIComponent(wgUserName) + '&action=edit&archivestage=2&archivename=' + encodeURIComponent(archivename) + '&numberoftalks=' + numberoftalks;
}
// remove the text that needs to be archived and send it to new window.
function archiveUserPageStage2() {
if (getParamValue('archivestage') != '2') return;
var numberoftalks = getParamValue('numberoftalks');
var tempText = document.editform.wpTextbox1.value;
var rx = new RegExp('[^=]==[^=]*==[^=]', 'g');
var m;
// find the first section
m = rx.exec(tempText);
var firstSectionIndex = m.index;
// find the last section to archive
var lastSectionIndex;
if (numberoftalks == 'all')
lastSectionIndex = tempText.length - 1;
else {
var numberOfSections = 0;
while (numberOfSections < numberoftalks) {
m = rx.exec(tempText);
if (m) {
numberOfSections++;
lastSectionIndex = m.index;
} else {
lastSectionIndex = tempText.length - 1;
break;
}
}
}
// get archiveText, load archive and save this page
var archiveText = tempText.substring(firstSectionIndex, lastSectionIndex);
var prefixArchive = (defualtPrefixArchive && defualtPrefixArchive != '') ? encodeURIComponent(defualtPrefixArchive) : '';
var url = 'http://he.wikipedia.org/w/index.php?title=User Talk:' + encodeURIComponent(wgUserName) + '/' + prefixArchive + getParamValue('archivename') + '&action=edit&archivestage=3';
archiveWindow = window.open(url, '_blank');
while (archiveWindow.title != 'מארכב את דף השיחה...') { }
archiveWindow.editform.wpTextbox1.value += '\n' + archiveText;
archiveWindow.editform.wpSummary.value = 'ארכוב אוטומטי';
archiveWindow.editform.wpSave.click();
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(archiveText, "");
document.editform.wpSummary.value = 'ארכוב אוטומטי';
document.editform.wpSave.click();
}
// save the archive page
function archiveUserPageStage3() {
if (getParamValue('archivestage') != '3') return;
window.title = 'מארכב את דף השיחה...';
}
function navArchiveToggle() {
var divBody = document.getElementById('p-archiveBody1');
if (divBody.style.display == 'none') // show content
divBody.style.display = 'block';
else { // hide content
divBody.style.display = 'none';
}
}
function initArchiveUserPage() {
if (wgNamespaceNumber != 3 || wgUserName != wgTitle) return;
var navArchiveMain = document.createElement('DIV');
navArchiveMain.className = 'portal';
var h5ArchiveTitle = document.createElement('H5');
var aLink = document.createElement('A');
aLink.appendChild(document.createTextNode('ארכוב'));
aLink.href = 'javascript:navArchiveToggle();';
h5ArchiveTitle.appendChild(aLink);
navArchiveMain.appendChild(h5ArchiveTitle);
try { // for IE
var divArchiveBody = document.createElement('<DIV ID="p-archiveBody1"></DIV>');
} catch (e) { // for FF
var divArchiveBody = document.createElement('DIV');
divArchiveBody.id = 'p-archiveBody1';
};
divArchiveBody.className = 'body';
divArchiveBody.style.padding = '5px';
divArchiveBody.innerHTML = 'שם הארכיון:<br /><input id="archivename" type="text" size="15" /><br />מספר השיחות לארכוב:<br /><input id="numberoftalks" type="text" size="15" /><br /><a href="javascript:archiveUserPageStage1()" title="ארכב עכשיו">ארכב עכשיו</a>';
navArchiveMain.appendChild(divArchiveBody);
var pToolBox = document.getElementById('p-tb');
pToolBox.parentNode.appendChild(navArchiveMain);
navArchiveToggle();
}
$(initArchiveUserPage);
$(archiveUserPageStage2);
$(archiveUserPageStage3);