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

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


function dateFormat(dateArr) {
function hasHebrew(text) {
if (!text || typeof text !== 'string') {
return false;
}
return /[\u0590-\u05FF]/.test(text);
}
 
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)
שורה 16: שורה 28:
dateArr[2] = 19 + dateArr[2];
dateArr[2] = 19 + dateArr[2];


if (dateArr[0].charAt(0) == '0')
if (!forceEnglish && dateArr[0].charAt(0) == '0')
dateArr[0] = dateArr[0].substring(1, dateArr[0].length);
dateArr[0] = dateArr[0].substring(1, dateArr[0].length);


שורה 705: שורה 717:
{
{
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('.')); }, // 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('.'), false); }, // just for after 22:00 articles as https://www.hayadan.org.il/colluns-astronauts-are-not-celebs-2307093
}
}
]
]
שורה 1,713: שורה 1,725:
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]);
params[j] = dateFormat(params[j], false);  
}
}
}
}
שורה 1,722: שורה 1,734:
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]);
params[j] = dateFormat([dd, mm, yy], false);  
}
}
}
}
שורה 1,796: שורה 1,808:
while (params.indexOf('removeifempty') > -1)
while (params.indexOf('removeifempty') > -1)
params.splice(params.indexOf('removeifempty'), 1);
params.splice(params.indexOf('removeifempty'), 1);
// --- התחלה של הוספת הקוד לבדיקת עברית ---
// בודק אם יש אותיות בעברית באחד מהפרמטרים
let foundHebrew = false;
for (let h = 0; h < params.length; h++) {
if (params[h] && hasHebrew(params[h])) {
foundHebrew = true;
break;
}
}
// אם לא נמצאו אותיות בעברית והפרמטר האחרון הוא תאריך
const lastParamIndex = params.length - 1;
if (!foundHebrew && lastParamIndex >= 0) {
const lastParam = params[lastParamIndex];
// מנסה לזהות אם הפורמט הנוכחי הוא תאריך שנוצר על ידי הפונקציה שלנו
const hebrewMonths = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
const isHebrewDate = hebrewMonths.some(month => lastParam.includes(month));
if (isHebrewDate) {
try {
// מפרסר את התאריך העברי וממיר אותו לאנגלי
const hebrewDateParts = lastParam.split(' ');
const day = hebrewDateParts[1].replace(',', '');
const month = hebrewMonths.indexOf(hebrewDateParts[0]) + 1;
const year = hebrewDateParts[2];
const dateArr = [day, month, year];
params[lastParamIndex] = dateFormat(dateArr, true);
} 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) {