Jump to content

Module:PhoneTracking

From Wikivoyage

Documentation for this module may be created at Module:PhoneTracking/doc

local i = {}
 
function i.PhoneTracking(frame)
    local output = '';
    local phone = frame.args["phone"] or '';
    local phonetidy = mw.ustring.gsub(phone, '-', ' ');
    phonetidy = mw.ustring.gsub(phonetidy, '  ', ' ');
    if mw.ustring.sub(phonetidy, 1, 3) == '+1 ' then
        local phonearea = mw.ustring.sub(phonetidy, 1, 6);
        --if phonearea == '+1 800' or phonearea == '+1 888' or phonearea == '+1 877' or phonearea == '+1 866' or phonearea == '+1 855' or phonearea == '+1 844' then
        if mw.ustring.match(phonetidy,'+1 800') ~= nil or mw.ustring.match(phonetidy,'+1 888') ~= nil or mw.ustring.match(phonetidy,'+1 877') ~= nil or mw.ustring.match(phonetidy,'+1 866') ~= nil or mw.ustring.match(phonetidy,'+1 855') ~= nil or mw.ustring.match(phonetidy,'+1 844') ~= nil then
            output = output .. '[[' .. 'Category:Listing with tollfree number in phone parameter]]';
        end
    end
    if mw.title.getCurrentTitle().namespace ~= 0 then
        output = '';
    end
    return output;
end
 
return i;