בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,364
רעדאגירונגען
(אפדעיט) |
(אפדעיט) |
||
| (איין צווישנדיגע ווערסיע פונעם זעלבן באַניצער נישט געוויזן) | |||
| שורה 467: | שורה 467: | ||
end | end | ||
local function | local function removeSpanTagsAndKeepText(html) | ||
local pattern = '<span[^>]*>(.-)</span>' | |||
local cleanedHtml = html | |||
repeat | |||
local newHtml, count = string.gsub(cleanedHtml, pattern, "%1") | |||
if count > 0 then | |||
cleanedHtml = newHtml | |||
else | |||
break -- Exit the loop when no more span tags are found | |||
end | |||
until false | |||
return cleanedHtml | |||
end | |||
-- | local function isNumber(str) | ||
if str == nil or str == "" then return false end | |||
-- Remove thousands separators (commas) and replace any commas with periods | |||
local r = string.gsub(str, ",", "") | |||
r = string.gsub(r, "%.", ".") | |||
return tonumber(r) | |||
end | |||
local function extractFirstNumber(inputString) | |||
if inputString == nil or inputString == "" then return inputString end | |||
local number = inputString:match("[%d,.]+") | |||
if number then | |||
return tonumber(number) | |||
else | |||
return inputString -- No number found, return the original text | |||
end | |||
end | end | ||
| שורה 494: | שורה 507: | ||
local parenthesis = require('Module:סוגריים') | local parenthesis = require('Module:סוגריים') | ||
local timeProperty = { ' | local timeProperty = { 'P585', 'P580', 'P582' } | ||
local options = { | local options = { | ||
['qualifiers'] = timeProperty, | ['qualifiers'] = timeProperty, | ||
['allowMulti'] = true, | ['allowMulti'] = true, | ||
['seperator'] = ';' | ['seperator'] = ';', | ||
['sort'] = timeProperty | |||
} | } | ||
local entityId = frame:getParent().args['qid'] or mw.wikibase.getEntityIdForCurrentPage() | local entityId = frame:getParent().args['qid'] or mw.wikibase.getEntityIdForCurrentPage() | ||
local res = propertyLink.getPropertyByOptions(property, entityId, options) | local res = propertyLink.getPropertyByOptions(property, entityId, options) | ||
return parenthesis.remove_parents_internal( | if res == nil or res == "" then | ||
return nil | |||
end | |||
local resArray = splitString(res, ";") | |||
local latestData = resArray[#resArray] | |||
latestData = removeSpanTagsAndKeepText(latestData) | |||
local lastData = parenthesis.remove_parents_internal(latestData) | |||
local lastDate = parenthesis.only_parents_contents_internal(latestData) | |||
local resData = lastData | |||
local resDate = lastDate | |||
if isNumber(extractFirstNumber(lastData)) then | |||
for i = #resArray, 1, -1 do | |||
local ins = resArray[i] | |||
ins = removeSpanTagsAndKeepText(ins) | |||
local insData = parenthesis.remove_parents_internal(ins) | |||
local insDate = parenthesis.only_parents_contents_internal(ins) | |||
if lastDate ~= insDate then | |||
break | |||
end | |||
if extractFirstNumber(resData) < extractFirstNumber(insData) then | |||
resData = insData | |||
end | |||
end | |||
end | |||
return resData, resDate | |||
end | |||
function returnLatestArea(frame) | |||
local area, latestAreaDate = returnLatestData(frame, 'P2046') | |||
return area | |||
end | end | ||
| שורה 524: | שורה 566: | ||
['חלוקה מנהלית']=adminDistTranslateWrapper, | ['חלוקה מנהלית']=adminDistTranslateWrapper, | ||
['צבע רקע לפי חלוקה מנהלית']=adminDistTranslateColorWrapper, | ['צבע רקע לפי חלוקה מנהלית']=adminDistTranslateColorWrapper, | ||
['שטח']=returnLatestArea, | |||
['ראש העיר']=returnLatestMayor, | ['ראש העיר']=returnLatestMayor, | ||
['אוכלוסייה']=returnLatestPopulation, | ['אוכלוסייה']=returnLatestPopulation, | ||
['תאריך אוכלוסייה']=returnLatestPopulationDate | ['תאריך אוכלוסייה']=returnLatestPopulationDate | ||
} | } | ||
רעדאגירונגען