אונטערשייד צווישן ווערסיעס פון "באַניצער:גאון הירדן/ייבוא ועדכון.js"
קפיצה לניווט
קפיצה לחיפוש
אין תקציר עריכה |
מוטי (שמועס | ביישטייערונגען) (מיותר במרחב מיוחד) |
||
שורה 967: | שורה 967: | ||
if ( | if ( | ||
mw.config.get("wgPageName") != "עמוד_ראשי" && | mw.config.get("wgPageName") != "עמוד_ראשי" && | ||
mw.config.get("wgPageContentModel") != "flow-board" /* && | mw.config.get("wgPageContentModel") != "flow-board" && | ||
mw.config.get("wgNamespaceNumber") !==-1 | |||
/* && | |||
(mw.config.get("wgNamespaceNumber") === 0 || | (mw.config.get("wgNamespaceNumber") === 0 || | ||
mw.config.get("wgNamespaceNumber") === 10) && | mw.config.get("wgNamespaceNumber") === 10) && |
רעוויזיע פון 21:53, 28 פעברואר 2023
$(function () {
mw.messages.set({
"": "הערות פאר בדיקה:",
"checkty-whait-title": "ווארט פאר בדיקה רעזולטאטן...",
"update-success": "אפּדעיט סוקסעספול געענדיגט! ",
images: "נישט פארגעסן צו באקוקן בילדער!",
"no-images": "נישטא קיין בילדער אין דעם ארטיקל.",
"No-Words": "די בדיקה איז סוקסעספול געענדיגט",
"checkty-page-doesnt-exist": " (דער בלאט עקזיסטירט נישט)",
"checkty-search": "זוכט",
"checkty-language-check": 'אינעם ארטיקל ערשיינט דעם אויסדרוק "$1" איין אדער מער מאל. ',
aspaklaria: "הערך עבר סינון! , העדכון מוגבל לעורכי אספקלריה בלבד.",
block: "הייבוא או העדכון נחסם על ידי ספק הרשת",
});
const isUpdate = mw.config.get("wgArticleId") > 0;
const Template = /(\{\{מיון ויקיפדיה\|דף=)(.*)(\|גרסה=)(\d*)/;
const edited = /\{\{(נערך במכלול|נבמ)\}\}/;
var redirect;
const txtr = /\#(הפניה|REDIRECT)\s*?\[\[/;
const section = mw.util.getParamValue("section");
const isSection = location.href.indexOf("section=") > -1;
updatemassage = $("<div>", { text: mw.msg("update-success") });
noimages = $("<div>", { text: mw.msg("no-images") });
images = $("<div>", { text: mw.msg("images") });
const setOf = '<div><span>'+
'<input type="checkbox" id="shemesh" name="shemesh">' +
'<label for="shemesh"> בוט ייבוא</label></span>' +
'<span><select id="selectbut" disabled>' +
'<option value="">בחר</option>' +
'<option value="ספורט">ספורט</option>' +
'<option value="תרבות ובידור">תרבות ובידור</option>' +
'<option value="ספרות">ספרות</option>' +
'<option value="סרטים">סרטים</option>' + '<option value="שחקנים">שחקנים</option>' +
'<option value="מוזיקאים">מוזיקאים</option>' +
'<option value="מוזיקה">מוזיקה</option>' +
'<option value="סופרים">סופרים</option>' +
'<option value="טלוויזיה">טלוויזיה</option>' +'<option value="קולנוע">קולנוע</option>' +
+'<option value="אלבומים">אלבומים</option>' +
+'<option value="משחקי מחשב">משחקי מחשב</option>' + "</select></div>";
if (mw.config.get("wgAction") === "edit" ||mw.config.get("wgAction") === "submit") {
$("#mw-editpage-watch").before(setOf);
const but =
document.getElementById("shemesh");
const selecto = document.getElementById("selectbut");
const eventListen1 = () => {
selecto.disabled = false;
};
const eventListen2 = () => {
getArticle();
};
but.addEventListener("click", eventListen1);
selecto.addEventListener("select", eventListen2);
}
var PageName = mw.config
.get("wgPageName")
.replace("מעדיעװיקי:" , "מדיה_ויקי:")
.replace("מעדיעװיקי_שמועס:" , "שיחת_מדיה_ויקי:")
.replace("הילף:", "עזרה:")
.replace("מוסטער:", "תבנית:")
.replace("קאַטעגאָריע:","קטגוריה:")
.replace("באַניצער:","משתמש:")
.replace("פארטל:","פורטל:")
.replace("סקריפטס","סקריפטים");
/*
if (
document.getElementById("wpTextbox1") &&
Template.exec($("#wpTextbox1").val()) &&
Template.exec($("#wpTextbox1").val())[4] != null
) {
PageName = Template.exec($("#wpTextbox1").val())[2];
}
*/
var apiEndpoint = "https://www.hamichlol.org.il/w/api.php?";
const dataToWiki = {
action: "parse",
page: PageName,
format: "json",
prop: "images|revid|properties|wikitext",
utf8: "1",
origin: "*",
};
const level = getLevel(mw.config.get("wgUserGroups"));
function getLevel(groupsUesr) {
return groupsUesr.indexOf("sysop") !== -1
? 20
: groupsUesr.indexOf("bot") !== -1
? 18
: groupsUesr.indexOf("aspaklarya2") !== -1
? 16
: groupsUesr.indexOf("עורך_אספקלריה") !== -1
? 14
: groupsUesr.indexOf("patroller") !== -1
? 12
: groupsUesr.indexOf("wikiupdate") !== -1
? 10
: groupsUesr.indexOf("wikimport") !== -1
? 8
: 0;
}
if (isSection) {
dataToWiki.section = section;
}
/* if (level > 19) {
apiEndpoint = "/import/get_wik1i.php?";
}
*/
function checkifexist() {
var apiToCheck =
"https://www.hamichlol.org.il/w/api.php?action=parse&page=" +
encodeURIComponent(PageName) +
"&format=json&prop=revid&origin=*";
fetch(apiToCheck)
.then((response) => response.json())
.then( (result)=> {
if (result && result.error && result.error.code == "missingtitle") {
console.log("הדף לא קיים במכלול");
} else if (result && result.parse) {
if (!isUpdate) {
if (level > 7) {
var Btn1 = new OO.ui.ButtonInputWidget({
label: "ייבוא",
title: "ייבוא",
});
$("#wpDiffWidget").after(Btn1.$element.click(getArticle));
if (level > 15 && mw.config.get("wgAction") === "edit") {
apiToCheck =
"https://www.hamichlol.org.il/w/api.php?action=parse&page=" +
encodeURIComponent(PageName) +
"&format=json&prop=text§ion=0&origin=*";
fetch(apiToCheck)
.then((response) => response.json())
.then( (result) =>{
if (result && result.parse) {
var wikitext = result.parse.text;
var rawa = result.parse.text["*"].replace("/wiki/", "/");
var box3 = $($.parseHTML(rawa));
var box2 = $(
'<div class="warningbox mw-warning-with-logexcerpt mw-content-rtl" dir="rtl" lang="he"></div>'
).html(box3);
$(
"#mw-content-text > div.mw-newarticletext.plainlinks"
).html(box2);
}
});
}
}
} else {
var Btn3 = new OO.ui.ButtonInputWidget({
label: "עדכון",
title: "עדכון",
});
if (level > 9) {
$("#wpDiffWidget").after(Btn3.$element.click(getHistory));
}
}
}
});
}
function getArticle() {
if (!$("#checktyResults").length)
$(".editButtons").after(
'<div id="checktyResults"><div class="checktyResultsTitle">פינת ההודעות</div></div>'
);
var texBoxVal = $("#wpTextbox1").val();
if (edited.test(texBoxVal)) {
alert("ערך זה נערך במכלול! נא לשמר עריכות מקומיות.");
}
var request = $.ajax({
url: apiEndpoint,
data: dataToWiki,
dataType: "json",
})
.done(function (result) {
if (result && result.parse) {
var isShort = document.getElementById("shemesh").checked === true;
var select = document.getElementById("selectbut").value;
var textpage = isShort
? getPageText(result.parse.wikitext["*"])
: result.parse.wikitext["*"];
var girsa = result.parse.revid;
var parit = getProperties(result);
var summary = isUpdate
? "עדכון מהמכלול גרסה " + girsa
: "אימפארטירט פון די העברעאישע המכלול, זע ביישטייערער ליסטע";
var added = "";
if (isShort) summary += ', בוט ' + select;
redirect = txtr.test(textpage);
var rating = [
"מיון ויקיפדיה",
"דף=" + result.parse.title,
"גרסה=" + girsa,
"פריט=" + parit,
];
if (isShort) {
var ni = "\n{{בוט " + select + "}}\n";
} else {
var ni =
mw.config.get("wgPageName") === result.parse.title
? "\n{{וח}}\n"
: "\n{{וח|" + result.parse.title + "}}\n";
}
added = ni + "{{" + rating.join("|") + "}}";
if (
mw.config.get("wgNamespaceNumber") === 0 &&
!redirect &&
!isSection
) {
$("#wpTextbox1").val(textpage + added);
} else {
$("#wpTextbox1").val(textpage);
}
if (!redirect && !isSection) $("#wpSummary").val(summary);
if (isSection && $("#wpSummary").val().indexOf("עדכון פסקה") == -1) {
$("#wpSummary").val(
$("#wpSummary").val() + "עדכון פסקה מויקיפדיה גרסה " + girsa
);
}
writeMsg(updatemassage, "check");
check();
}
})
.fail(function (request, exception) {
var msg = errors(request, exception);
mw.notify(msg);
});
}
function getProperties(result) {
var parit = " ";
if (!result.parse.properties[0]) {
parit = " ";
} else if (result.parse.properties[0]["name"] == "wikibase_item") {
parit = result.parse.properties[0]["*"];
} else if (
result.parse.properties[0]["name"] != "wikibase_item" &&
result.parse.properties.length <= 1
) {
parit = " ";
} else if (
result.parse.properties[0]["name"] != "wikibase_item" &&
result.parse.properties.length > 1
) {
for (let pa = 0; pa < result.parse.properties.length; pa++) {
if (result.parse.properties[pa]["name"] == "wikibase_item") {
parit = result.parse.properties[pa]["*"];
} else continue;
}
}
return parit;
}
function getPageText(member) {
var wikiList = [];
var textList;
var regex1 = /==.*==/g;
var regex2 = /\n\n/;
var regex3 = /\[\[קטגוריה\:[^\]]*?\]\]/g;
var categoriesToAdd;
var newText;
var first;
var last = 0;
let parsedText = member;
textList = parsedText.split(regex1);
if (textList.length < 3) {
textList = parsedText.split(regex2);
first = textList[0];
last = textList.length - 1;
categoriesToAdd = textList[last].match(regex3);
newText = first + "\n\n" + categoriesToAdd.join("\n");
} else {
first = textList[0];
last = textList.length - 1;
categoriesToAdd = textList[last].match(regex3);
newText = first + "\n\n" + categoriesToAdd.join("\n");
}
return newText;
}
function check() {
if (!$("#checktyResults").length)
$(".editButtons").after(
'<div id="checktyResults"><div class="checktyResultsTitle">הערות לבדיקה</div></div>'
);
var txt = $("#wpTextbox1").val();
var pic = /(jpg|pdf|ogg|webm|png|jpeg|Jpg|JPG|svg|svg\.png|gif|gallery)/;
var tst = pic.test(txt);
if (tst) {
writeMsg(images, "alert");
} else {
writeMsg(noimages, "check");
}
var api = new mw.Api();
api
.get({
action: "parse",
page: "המכלול:בודק מילים חשודות",
prop: "wikitext",
})
.done(function (data) {
if (!(data && data.parse && data.parse.wikitext)) return;
var DictionaryText = data.parse.wikitext["*"].split("-----")[1];
var genrealWarningWords = DictionaryText.split("\n*");
var checks = [];
for (var i = 0; i < genrealWarningWords.length; i++) {
var regex = new RegExp(
"(\\s|^)[בכלמשהו]*(" + genrealWarningWords[i] + ")",
"g"
);
var splittedWarn = genrealWarningWords[i].split("//");
if (splittedWarn.length !== 2) continue;
checks.push({
test: RegExp(splittedWarn[0], "i"),
});
}
var left = checks.length;
var txt = $("#wpTextbox1").val();
var checkWarnings = $("<div></div>");
for (var x in checks) {
left -= 1;
//console.log(left);
if (checks[x]["test"].test(txt)) {
var m = checks[x]["test"].exec(txt),
langCheckPrefix = "";
if (
m[0].split(" ").length < 4 &&
checks[x]["test"].source.indexOf("\\]") == -1
)
langCheckPrefix = mw.msg("checkty-language-check", m[0]);
checkWarnings.append(createSearchLink(m[0]));
checkWarnings.append(" - " + langCheckPrefix + "<br/>");
}
}
if (checkWarnings.html().length) writeMsg(checkWarnings, "alert");
if (left === 0) {
writeMsg($("<div>").text(mw.msg("No-Words")), "check");
}
});
}
function writeMsg(msg, icon) {
var x;
if (msg instanceof Array) {
if (msg.length === 0) return;
msg = "<div>" + msg.join("<br/>") + "</div>";
}
x = $(msg).css("display", "none").addClass("checktyMsg");
if (icon) {
var iconWidget = new OO.ui.IconWidget({
icon: icon,
});
x.prepend(iconWidget.$element);
}
$("#checktyResults").append(x);
x.show("slow");
return x;
}
function createSearchLink(v) {
var highlightStr = highlightString;
var searchLink = $('<a href="#">חיפוש</a>')
.data({ search: v })
.click(function (e) {
highlightStr($(this).data("search"));
e.preventDefault();
});
return searchLink;
}
function highlightString(toFind) {
var txtArea = $("#wpTextbox1");
// cast to string if this is regex
if (RegExp.prototype.isPrototypeOf(toFind)) {
toFind = toFind.exec(txtArea.val());
if (!toFind) return;
toFind = toFind[0];
}
var nextPlace = txtArea
.val()
.indexOf(toFind, txtArea.textSelection("getCaretPosition") + 1);
if (nextPlace === -1) nextPlace = txtArea.val().indexOf(toFind); //start from begining
if (nextPlace === -1) return; //not found... nothing to do
var origText = txtArea.val();
txtArea.val(origText.substring(0, nextPlace));
txtArea.focus();
txtArea.scrollTop(1000000); //Larger than any real textarea (hopefully)
var curScrollTop = txtArea.scrollTop();
txtArea.val(origText);
if (curScrollTop > 0) {
var HALF_EDIT_BOX_HEIGHT = 200;
txtArea.scrollTop(curScrollTop + HALF_EDIT_BOX_HEIGHT);
}
txtArea.focus().textSelection("setSelection", {
start: nextPlace,
end: nextPlace + toFind.length,
});
}
function aspaklaryaColor() {
var wikiDiffTable = document.querySelectorAll("td.diff-addedline.diff-side-added.diff-side-added");
var URL =
"https://www.hamichlol.org.il/w/index.php?title=" +
encodeURI("המכלול:בדיקת מילים חשודות") +
"&action=raw";
$.get(URL, function (data, status) {
var theWords = data.split("<!-- -->");
//אדום כהה
lula(theWords[1], "#ff5555");
//אדום בהיר
lula(theWords[3], "#ffcccc");
//ירוק
lula(theWords[5], "#99ff99");
//כחול
lula(theWords[7], "#ccccff");
//צהוב
lula(theWords[9], "#eeee99");
function lula(A, Scolor) {
wrapText(".mw-parser-output", "background-Color:" + Scolor, A);
wrapText(wikiDiffTable, "background-Color:" + Scolor, A);
}
function wrapText(selector, style, theWords) {
if(!theWords) return;
theWords = theWords.trim();
var regex = new RegExp(theWords, "g");
var allTextNodes = $(selector)
.find("*")
.contents()
.filter(function () {
return this.nodeType === 3;
});
allTextNodes.each(function () {
var ele = $(this);
var oldTextToColor = ele.text();
var newTextToColor = oldTextToColor.replace(regex, function (m) {
return '<span style="' + style + '">' + m + "</span>";
});
ele.replaceWith(newTextToColor);
});
}
});
}
function getHistory() {
if (!$("#checktyResults").length)
$(".editButtons").after(
'<div id="checktyResults"><div class="checktyResultsTitle">פינת ההודעות</div></div>'
);
var wikiup = 0;
var plussize = 0;
var aspak = [];
var localpagename = mw.config.get("wgPageName");
var params = {
action: "query",
format: "json",
prop: "info|revisions",
indexpageids: true,
titles: decodeURIComponent(localpagename),
utf8: 1,
rvprop: "ids|timestamp|flags|comment|user|size",
rvdir: "newer",
rvlimit: "max",
};
$.getJSON("/w/api.php", params, function (data) {
var revisions = data.query.pages[data.query.pageids[0]].revisions;
if (!revisions) return;
var x = -1;
var edits = 0;
for (rev = 0; rev < revisions.length; rev++) {
x += 1;
var size = revisions[rev].size;
var comment = revisions[rev].comment;
var takzir = /מוויקיפדיה|מויקיפדיה|החלפת טקסט/;
var idkun = takzir.test(comment);
var sinun = /הסרת תוכן|גיור מונח/;
var mesunan = sinun.test(comment);
if (mesunan) {
aspak.push({ תקציר: comment });
}
if (rev > 0 && !idkun) {
edits += 1;
var diff = size - revisions[x - 1].size;
plussize += diff;
}
if (rev > 0 && idkun) {
var wikidiff = size - revisions[x - 1].size;
wikiup += wikidiff;
}
//console.log(edits, comment, plussize, wikiup);
if (rev === revisions.length - 1) {
if (rev > 0 && plussize != 0) {
var all = plussize - wikiup;
writeMsg(
$("<div>").text(
"ערך זה נערך במכלול " +
edits +
" פעמים. ההפרש המירבי בין הגרסאות הוא : " +
all +
" בתים "
)
);
}
if (aspak.length) {
writeMsg($("<div>").text("הערך עבר סינון!"), "alert");
if (level > 12) {
getArticle();
} else {
writeMsg($("<div>").text(mw.msg("aspaklaria")), "alert");
}
} else {
getArticle();
}
}
}
});
}
function editDiffrents() {
aspaklaryaColor();
$("a.image").each(function () {
var eximage = $(this);
var exhref = eximage[0].href;
var exname = exhref.split("org.il/")[1];
var exnami = decodeURIComponent(exname)
.trim()
.replace(/קובץ:/, "");
let picName = decodeURIComponent(exnami.replace(/[ _]/g, " "));
$("#wpTextbox1").val(
$("#wpTextbox1").val().replace(
exnami, picName)
);
eximage.after(createSearchLink(picName));
});
//aspaklaryaColor();
$("tbody>tr").each(function () {
var ag = $(this);
if (
ag[0].cells.length < 3 ||
(ag[0].cells.length === 4 &&
ag[0].cells[1].className != "diff-addedline diff-side-added" &&
ag[0].cells[1].className != "diff-deletedline diff-side-deleted")
)
return;
//console.log (ag);
var oldText = ag.find("td.diff-deletedline.diff-side-deleted.diff-side-deleted").find("div").text().trim();
var newText = ag.find("td.diff-addedline.diff-side-added.diff-side-added").find("div").text().trim();
var newLine = ag.find("td.diff-addedline.diff-side-added.diff-side-added");
var delLine = ag.find("td.diff-deletedline.diff-side-deleted.diff-side-deleted");
var index = ag[0].rowIndex;
if (
ag[0].cells[1].className === "diff-deletedline diff-side-deleted" &&
oldText != "\n" &&
oldText != "" &&
oldText != " " &&
index > 2
) {
ag.before(
$("<a>")
.text("החזרת התוכן")
.click(function () {
console.log("1", oldText);
var ind = index - 1;
var prev = ag[0].parentNode.rows[ind].children[1];
var upLineText = $(prev).text().trim();
if (upLineText === "" || upLineText === undefined) {
ind -= 1;
upLineText = "\n" + upLineText;
}
prev = ag[0].parentNode.rows[ind].children[1];
upLineText = $(prev).text().trim();
var prvDel = ag[0].parentNode.rows[ind].children[1].className;
var prevAdd = ag[0].parentNode.rows[ind].children[3];
if (prvDel === "diff-deletedline diff-side-deleted" && !prevAdd) {
alert("התחל לבטל מתחת לקטע היציב הראשון, כלפי מטה");
return;
} else if (
prvDel === "diff-deletedline diff-side-deleted" &&
prevAdd.className === "diff-addedline diff-side-added"
) {
upLineText = prevAdd.innerText;
}
var reptext = upLineText + "\n" + oldText;
var nowText = $("#wpTextbox1").val();
$("#wpTextbox1").val(
$("#wpTextbox1").val().replace(upLineText, reptext)
);
var afterText = $("#wpTextbox1").val();
if (nowText != afterText) {
$(ag)
.find("td.diff-deletedline.diff-side-deleted.diff-side-deleted")
.removeClass("diff-deletedline.diff-side-deleted")
.addClass("diff-context")
.find("div")
.removeClass("diffchange diffchange-inline")
.find("del")
.removeAttr("class");
$(ag).find("del").unwrap();
$(this).remove();
blockSave();
} else {
alert("לא נמצא");
}
})
);
} /* מכאן בדיקת תמונות*/
var pic = /(jpg|png|PNG|Jpeg|JPEG|jpeg|Jpg|JPG|svg|svg\.png|gif|tif)/;
var tst = pic.test(newText);
if (tst) {
newLine.after(
$("<a>")
.text("הסרת תמונה")
.click(function () {
var nowText = $("#wpTextbox1").val();
$("#wpTextbox1").val(
$("#wpTextbox1")
.val()
.replace(" ", " ")
.replace(newText + "\n", "")
);
var afterText = $("#wpTextbox1").val();
if (nowText != afterText) {
newLine.remove();
$(this).remove();
} else {
alert("לא נמצא");
}
})
);
var newTextPic = newText.replace(
/\|\s?(תמונה|דגל|סמל|תמונה1|תמונה2|תמונת דגל|תמונת סמל)\s?\=/,
""
);
if (
newTextPic.indexOf("קובץ:") === -1 &&
newTextPic.indexOf("file:") === -1 &&
newTextPic.indexOf("File:") === -1
) {
newTextPic = "קובץ:" + newTextPic;
}
if (
newTextPic.indexOf("[[קובץ:") === -1 &&
newTextPic.indexOf("[[file:") === -1 &&
newTextPic.indexOf("[[File:") === -1
) {
newTextPic = "[[" + newTextPic + "|250px]]";
}
var lin =
"/w/api.php?action=parse&format=json&title=" +
encodeURIComponent(mw.config.get("wgPageName")) +
"&text=" +
encodeURIComponent(newTextPic) +
"&utf8=1";
fetch(lin)
.then((response) => response.json())
.then(function (result) {
txt1 = result.parse.text["*"];
if (txt1.indexOf('class="image') > -1) {
newLine.append(txt1).css({ background: "yellow" });
} else {
newLine.css({ background: "red" });
}
}); /*עד כאן בדיקת תמונות*/
} else {
if (newText != "\n" && newText != "" && newText != " ") {
newLine.after(
$("<a>")
.text("הסרת תוכן")
.click(function () {
var nowText = $("#wpTextbox1").val();
$("#wpTextbox1").val(
$("#wpTextbox1")
.val()
.replace(" ", " ")
.replace(newText + "\n", "")
);
var afterText = $("#wpTextbox1").val();
if (nowText != afterText) {
newLine.remove();
$(this).remove();
blockSave();
} else {
alert("לא נמצא");
}
})
);
}
}
if (
ag[0].cells.length === 3 ||
oldText === "\n" ||
oldText === "" ||
oldText === " "
)
return;
ag.before(
$("<a>")
.text("ביטול")
.click(function () {
if (ag[0].cells.length < 4) {
alert("על מנת לבטל מקטע זה, נא להציג הבדלים שוב");
return;
} else if (
(newText === "\n" || newText === "" || newText === " ") &&
index > 2
) {
alert("אין טקסט לבטל");
return;
}
var nowText = $("#wpTextbox1").val();
$("#wpTextbox1").val(
$("#wpTextbox1")
.val()
.replace(" ", " ")
.replace(newText, oldText)
);
var afterText = $("#wpTextbox1").val();
if (nowText != afterText) {
$(ag)
.find("td.diff-deletedline.diff-side-deleted.diff-side-deleted")
.removeClass("diff-deletedline.diff-side-deleted")
.addClass("diff-context")
.find("div")
.removeClass("diffchange diffchange-inline")
.find("del")
.removeAttr("class");
$(ag).find("del").unwrap();
$(ag)
.find("td.diff-addedline.diff-side-added.diff-side-added")
.removeClass("diff-addedline.diff-side-added")
.addClass("diff-context")
.find("div")
.removeClass("diffchange diffchange-inline")
.find("ins")
.removeAttr("class");
$(ag).find("ins").unwrap();
$(this).remove();
blockSave();
} else {
alert("לא נמצא");
}
})
);
});
}
function blockSave(open) {
var saveButton = document.getElementById("wpSave");
if (!saveButton) return;
if (open != "פתח") {
saveButton.disabled = true;
saveButton.value = "לא לסמוך על הסקריפט, חובה לבצע הצגת שינויים נוספת!";
saveButton.style.fontWeight = "normal";
document.getElementById("wpPreview").style.fontWeight = "bold";
} else {
saveButton.disabled = false;
if (saveButton.value != "שמירת השינויים")
saveButton.value = "אשריך שבדקת!";
saveButton.style.fontWeight = "bold";
document.getElementById("wpPreview").style.fontWeight = "bold";
}
}
function freeSave() {
open = "פתח";
blockSave(open);
if (!document.getElementById("editDiffrents")) {
var b144 = '<button id ="editDiffrents">תצוגת הבדלים מתקדמת</button>';
$("#bodyContent").prepend(
$(b144).click(function () {
editDiffrents();
})
);
}
}
function formImport() {
if (document.getElementById("edited")) {
alert("ערך זה נערך במכלול! נא לשמר עריכות מקומיות.");
}
if (window.PageName != undefined) PageName = window.PageName;
var nameOfPage = PageName;
var pointApi = apiEndpoint;
var dataWiki = {
action: "parse",
page: nameOfPage,
format: "json",
prop: "revid|properties|wikitext",
utf8: "1",
origin: "*",
};
var request = $.ajax({
url: pointApi,
data: dataWiki,
dataType: "json",
})
.done(function (result) {
if (result && result.parse) {
var textpage = result.parse.wikitext["*"];
redirect = txtr.test(textpage);
var girsa = result.parse.revid;
var parit = getProperties(result);
var summary = isUpdate
? "עדכון מהמכלול גרסה " + girsa
: "אימפארטירט פון די העברעאישע המכלול, זע ביישטייערער ליסטע";
var added = "";
var rating = [
"מיון ויקיפדיה",
"דף=" + result.parse.title,
"גרסה=" + girsa,
"פריט=" + parit,
];
added = "\n{{וח}}\n" + "{{" + rating.join("|") + "}}";
var corname = mw.config.get("wgPageName").trim().replace(/_/g, " ");
PageName = PageName.trim().replace(/_/g, " ");
if (corname != PageName) {
added =
"\n{{וח|" +
result.parse.title +
"}}\n" +
"{{" +
rating.join("|") +
"}}";
}
if (mw.config.get("wgNamespaceNumber") === 0 && !redirect) {
textpage = textpage + added;
}
var $form = $("<form>");
var actionUrl = "/w/index.php?title=" +
encodeURIComponent(mw.config.get("wgPageName")) +
"&action=submit";
$form
.attr("target", "_blank")
.attr("action", actionUrl)
.attr("enctype", "multipart/form-data")
.attr("method", "post");
var params = [];
params.push(["wpTextbox1", textpage]);
params.push(["wpSummary", summary]);
params.push(["wpAntispam", ""]);
params.push(["wpSection", ""]);
params.push(["wpStarttime", ""]);
params.push(["wpEdittime", ""]);
params.push(["editRevId", ""]);
params.push(["wpScrolltop", "0"]);
params.push(["oldid", "0"]);
params.push(["parentRevId", "0"]);
params.push(["format", "text/x-wiki"]);
params.push(["model", "wikitext"]);
params.push(["mode", "preview"]);
params.push(["wpUltimateParam", "1"]);
if (
mw.config.get("wgCategories") &&
mw.config.get("wgCategories").indexOf("ערכים לפתיחה") != -1
) {
params.push(["wpPreview", "תצוגה מקדימה"]);
} else {
params.push(["wpDiff", "הצגת שינויים"]);
}
params.forEach((item) => {
$("<input>")
.attr("type", "hidden")
.attr("name", item[0])
.val(item[1])
.appendTo($form);
});
$form.appendTo($("body"));
$form.submit();
} else if (
result &&
result.error &&
result.error.code == "missingtitle"
) {
mw.notify("לא קיים");
} else {
mw.notify(result.error.code);
}
})
.fail(function (request, exception) {
// Our error logic here
var msg = errors(request, exception);
mw.notify(msg);
});
}
function errors(request, exception) {
var msg = "";
if (request.status === 0) {
msg = "Not connect.\n Verify Network.";
} else if (request.status == 404) {
msg = "Requested page not found. [404]";
} else if (request.status == 418) {
msg = "הייבוא או העדכון נחסם על ידי ספק הרשת";
} else if (request.status == 500) {
msg = "Internal Server Error [500].";
} else if (exception === "parsererror") {
console.log("Requested JSON parse failed.");
msg = "השרת החזיר תשובה שגויה. ייתכן וקיים תוכן בעייתי בערך.";
} else if (exception === "timeout") {
msg = "Time out error.";
} else if (exception === "abort") {
msg = "Ajax request aborted.";
} else {
msg = "Uncaught Error.\n" + request.responseText;
}
return msg;
}
if ($.inArray(mw.config.get("wgAction"), ["edit", "submit"]) + 1)
$(document).ready(function () {
/* if (
$.inArray(mw.config.get("wgNamespaceNumber"), ["2", "3", "4", "6"]) + 1
)
return;
*/ if (location.href.indexOf("&submit") === -1) checkifexist();
var open;
var diffbut = document.getElementById("wpDiff");
diffbut.addEventListener("click", freeSave);
/* var selectionBut = document.getElementById("selectbut");
selectionBut.addEventListener("select", );
*/
var Btn2 = new OO.ui.ButtonInputWidget({
label: "בדיקת מילים",
title: "בדיקת מילים",
accessKey: "a"
});
var b144 = '<button id ="editDiffrents">תצוגת הבדלים מתקדמת</button>';
$("#wpDiffWidget").after(Btn2.$element.click(check));
var b144 = '<button id ="editDiffrents">תצוגת הבדלים מתקדמת</button>';
$("#bodyContent").prepend(
$(b144).click(function () {
editDiffrents();
})
);
});
if (
mw.config.get("wgPageName") != "עמוד_ראשי" &&
mw.config.get("wgPageContentModel") != "flow-board" &&
mw.config.get("wgNamespaceNumber") !==-1
/* &&
(mw.config.get("wgNamespaceNumber") === 0 ||
mw.config.get("wgNamespaceNumber") === 10) &&
level > 13 &&
mw.config.get("wgAction") === "view"
*/) {
var btnUpDate = mw.util.addPortletLink(
"p-views",
"#",
"עדכון",
"wikiUpdate",
null,
null,
"#ca-history"
); //הפרמטר הרביעי מיועד לצורך הסתרה בקוד הסינון בקומונס
$(btnUpDate).click(function () {
formImport();
});
}
});