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

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


// פונקציה חדשה ופשוטה לבדיקת אותיות עבריות בטקסט
function hasHebrew(text) {
function hasHebrew(text) {
if (!text || typeof text !== 'string') {
if (typeof text !== 'string') {
return false;
return false;
}
}
return /[\u0590-\u05FF]/.test(text);
for (var i = 0; i < text.length; i++) {
var charCode = text.charCodeAt(i);
if (charCode >= 0x05D0 && charCode <= 0x05EA) { // טווח תווי יוניקוד של עברית
return true;
}
}
return false;
}
}


שורה 22: שורה 29:
return '';
return '';


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


if (!forceEnglish && dateArr[0].charAt(0) == '0')
// הסרת ריפוד של אפס מתאריך
dateArr[0] = dateArr[0].substring(1, dateArr[0].length);
if (day.charAt(0) == '0')
 
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);
שורה 1,031: שורה 1,044:
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,809: שורה 1,822:
params.splice(params.indexOf('removeifempty'), 1);
params.splice(params.indexOf('removeifempty'), 1);


// --- התחלה של הוספת הקוד לבדיקת עברית ---
// --- התחלה של הוספת הקוד המתוקן לבדיקת עברית ---
// בודק אם יש אותיות בעברית באחד מהפרמטרים
let foundHebrew = false;
let foundHebrew = false;
let dateParamIndex = -1;
for (let h = 0; h < params.length; h++) {
for (let h = 0; h < params.length; h++) {
if (params[h] && hasHebrew(params[h])) {
if (hasHebrew(params[h])) {
foundHebrew = true;
foundHebrew = true;
break;
}
// זיהוי הפרמטר של התאריך לפי זיהוי חודש עברי
const hebrewMonths = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
if (typeof params[h] === 'string' && hebrewMonths.some(month => params[h].includes(month))) {
dateParamIndex = h;
}
}
}
}


// אם לא נמצאו אותיות בעברית והפרמטר האחרון הוא תאריך
// אם לא נמצאה עברית בכל הפרמטרים, נשנה את פורמט התאריך לאנגלי
const lastParamIndex = params.length - 1;
if (!foundHebrew && dateParamIndex !== -1) {
if (!foundHebrew && lastParamIndex >= 0) {
const hebrewDate = params[dateParamIndex];
const lastParam = params[lastParamIndex];
try {
// מנסה לזהות אם הפורמט הנוכחי הוא תאריך שנוצר על ידי הפונקציה שלנו
const hebrewMonthsMap = {
const hebrewMonths = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
"יאנואר": 1, "פעברואר": 2, "מערץ": 3, "אפריל": 4, "מאי": 5, "יוני": 6, "יולי": 7, "אוגוסט": 8, "סעפטעמבער": 9, "אקטאבער": 10, "נאוועמבער": 11, "דעצעמבער": 12
const isHebrewDate = hebrewMonths.some(month => lastParam.includes(month));
};
 
// פירוק התאריך העברי
if (isHebrewDate) {
const parts = hebrewDate.split(' ');
try {
const day = parts[1].replace(',', '');
// מפרסר את התאריך העברי וממיר אותו לאנגלי
const month = hebrewMonthsMap[parts[0]];
const hebrewDateParts = lastParam.split(' ');
const year = parts[2];
const day = hebrewDateParts[1].replace(',', '');
const month = hebrewMonths.indexOf(hebrewDateParts[0]) + 1;
if (day && month && year) {
const year = hebrewDateParts[2];
params[dateParamIndex] = dateFormat([day, month, year], true); // המרה לאנגלית
const dateArr = [day, month, year];
params[lastParamIndex] = dateFormat(dateArr, true);
} catch (e) {
console.error("Failed to convert Hebrew date to English:", e);
}
}
} catch (e) {
console.error("Failed to convert Hebrew date to English:", e);
}
}
}
}
// --- סוף של הוספת הקוד לבדיקת עברית ---
// --- סוף של הוספת הקוד המתוקן לבדיקת עברית ---
 


if (window.popup_template_canceled && !force_popup) {
if (window.popup_template_canceled && !force_popup) {
שורה 1,889: שורה 1,904:
'אדרעס': 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()]) : ''
'דאטום': date != "Invalid Date" ? dateFormat([''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()], !hasHebrew(ldojson.name || ldojson.headline)) : '' // שינוי כאן: בדיקה אם יש עברית בכותרת
};
};
console.log('data', general);
console.log('data', general);