אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Common.js/externalsmaker.js"

ק
רעדאגירונגען דורך שווערמער (שמועס) צוריקגעשטעלט צו דער לעצטער ווערסיע פון תנא קמא
אין תקציר עריכה
צייכן: צוריקגעשטעלט
ק (רעדאגירונגען דורך שווערמער (שמועס) צוריקגעשטעלט צו דער לעצטער ווערסיע פון תנא קמא)
צייכן: צוריקדריי
שורה 3: שורה 3:
window.$ = window.jQuery;
window.$ = window.jQuery;


// פונקציה חדשה ופשוטה לבדיקת אותיות עבריות בטקסט
function dateFormat(dateArr) {
function hasHebrew(text) {
if (typeof text !== 'string') {
return false;
}
for (var i = 0; i < text.length; i++) {
var charCode = text.charCodeAt(i);
if (charCode >= 0x05D0 && charCode <= 0x05EA) { // טווח תווי יוניקוד של עברית
return true;
}
}
return false;
}
 
function dateFormat(dateArr, forceEnglish) {
if (dateArr instanceof Array) {
if (dateArr instanceof Array) {
var m;
var m = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
if (forceEnglish) {
m = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
} else {
m = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
}


if (dateArr.length != 3)
if (dateArr.length != 3)
return '';
return '';


var day = dateArr[0];
dateArr[1] = m[Number(dateArr[1]) - 1];
var month = dateArr[1];
if (Number(dateArr[2]) <= 50)
var year = dateArr[2];
dateArr[2] = 20 + dateArr[2];
else if (Number(dateArr[2]) >= 50 && Number(dateArr[2]) < 100)
// טיפול בפורמט התאריך: אם יש רק 2 ספרות בשנה, מוסיפים 19 או 20
dateArr[2] = 19 + dateArr[2];
if (Number(year) <= 50)
year = '20' + year;
else if (Number(year) >= 50 && Number(year) < 100)
year = '19' + year;


// הסרת ריפוד של אפס מתאריך
if (dateArr[0].charAt(0) == '0')
if (day.charAt(0) == '0' && !forceEnglish)
dateArr[0] = dateArr[0].substring(1, dateArr[0].length);
day = day.substring(1, day.length);
 
dateArr = dateArr[1] + " " + dateArr[0] + ", " + dateArr[2];
// המרה לפורמט הרצוי
return m[Number(month) - 1] + " " + day + ", " + year;
}
}
return jQuery.trim(dateArr);
return jQuery.trim(dateArr);
שורה 629: שורה 604:
{ str: '' },
{ str: '' },
{ telem: "#fullRecordView th:contains(בתוך):first + td", match: /\((.*?)\)/, func: function (yh) { return yh.substring(0, yh.length - 1) + '"' + yh.substr(yh.length - 1); } },
{ telem: "#fullRecordView th:contains(בתוך):first + td", match: /\((.*?)\)/, func: function (yh) { return yh.substring(0, yh.length - 1) + '"' + yh.substr(yh.length - 1); } },
{ telem: "#fullRecordView th:contains(בתוך):first + td", match: /(\d+\-\d+)/ },
{ telem: "#fullRecordView th:contains(מס' מערכת):first + td", prefix: "רמבי=" }
{ telem: "#fullRecordView th:contains(מס' מערכת):first + td", prefix: "רמבי=" }
]
]
שורה 729: שורה 705:
{
{
attr: ['meta[property="article:published_time"]', 'content'],
attr: ['meta[property="article:published_time"]', 'content'],
func: function(s) { return dateFormat(new Date(s).toLocaleDateString('he').split('.'), false); }, // just for after 22:00 articles as https://www.hayadan.org.il/colluns-astronauts-are-not-celebs-2307093
func: function(s) { return dateFormat(new Date(s).toLocaleDateString('he').split('.')); }, // just for after 22:00 articles as https://www.hayadan.org.il/colluns-astronauts-are-not-celebs-2307093
}
}
]
]
שורה 1,043: שורה 1,019:
params: [
params: [
{ str: 'חרדים10' },
{ str: 'חרדים10' },
{ attr: ['meta[name="author"]', "content"], remove: ['חרדים 10'] },
{ attr: ['meta[name="author"]', 'content'], remove: ['חרדים 10'] },
{ attr: ['meta[property="og:title"]', "content"] },
{ attr: ['meta[property="og:title"]', 'content'] },
{ url: 1, match: /news\/(\d+)/ },
{ url: 1, match: /news\/(\d+)/ },
{ attr: ['meta[property="article:published_time"]', "content"], date: ['-', '210'] }
{ attr: ['meta[property="article:published_time"]', 'content'], date: ['-', '210'] }
]
]
},
},
שורה 1,604: שורה 1,580:
var curParam = data[i].params[j][k],
var curParam = data[i].params[j][k],
removed = false; params[j] = '';
removed = false; params[j] = '';
// --- התחלה של הוספת הקוד המתוקן לבדיקת עברית לפני העיבוד ---
// בדיקה מקדימה אם יש עברית באחד מהפרמטרים הראשונים (שם האתר והמחבר)
let foundHebrewBefore = false;
if (j <= 1) { // בודק רק את 2 הפרמטרים הראשונים, שהם לרוב שם האתר ושם המחבר
if (typeof curParam.str != "undefined" && hasHebrew(curParam.str)) {
foundHebrewBefore = true;
} else if (typeof curParam.ldjson != "undefined" && curParam.ldjson.key === 'author') {
const author = $.map($(ldjson.author), function(a) { return a.name; }).join(VE);
if (hasHebrew(author)) {
foundHebrewBefore = true;
}
} else if (typeof curParam.telem != "undefined" && hasHebrew(jQuery('html').find(curParam.telem).first().text().trim())) {
foundHebrewBefore = true;
}
}
// --- סוף של הוספת הקוד המתוקן לבדיקת עברית לפני העיבוד ---


if (typeof curParam.str != "undefined") {
if (typeof curParam.str != "undefined") {
שורה 1,746: שורה 1,705:
}
}
}
}
// שינוי כאן: בדיקה אם forceEnglish צריכה להיות true
var shouldForceEnglish = !hasHebrew(params.join(' ')); // בודק האם יש עברית בכל הפרמטרים שנאספו עד כה
if (typeof curParam.date != "undefined") {
if (typeof curParam.date != "undefined") {
if (!(curParam.date instanceof Array))
if (!(curParam.date instanceof Array))
שורה 1,757: שורה 1,713:
params[j] = params[j].split(curParam.date[0]);
params[j] = params[j].split(curParam.date[0]);
params[j] = [params[j][curParam.date[1][0]], params[j][curParam.date[1][1]], params[j][curParam.date[1][2]]];
params[j] = [params[j][curParam.date[1][0]], params[j][curParam.date[1][1]], params[j][curParam.date[1][2]]];
params[j] = dateFormat(params[j], shouldForceEnglish); // העברת הפרמטר החדש
params[j] = dateFormat(params[j]);
}
}
}
}
שורה 1,766: שורה 1,722:
mm = (today.getMonth() + 1).toString(),
mm = (today.getMonth() + 1).toString(),
yy = today.getFullYear().toString().slice(-2);
yy = today.getFullYear().toString().slice(-2);
params[j] = dateFormat([dd, mm, yy], shouldForceEnglish); // העברת הפרמטר החדש
params[j] = dateFormat([dd, mm, yy]);
}
}
}
}
שורה 1,886: שורה 1,842:
'אדרעס': location.href,
'אדרעס': location.href,
'זייטל': (ldojson.publisher||ldojson_website[0]).name,
'זייטל': (ldojson.publisher||ldojson_website[0]).name,
'דאטום': date != "Invalid Date" ? dateFormat([''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()], !hasHebrew(ldojson.name || ldojson.headline)) : '' // שינוי כאן: בדיקה אם יש עברית בכותרת
'דאטום': date != "Invalid Date" ? dateFormat([''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()]) : ''
};
};
console.log('data', general);
console.log('data', general);