FANDOM


-- constructor
function Class(members)
	members = members or {}
	local mt = {
		__metatable = members;
		__index     = members;
	}
 
	local function new(_, init)
		return setmetatable(init or {}, mt)
	end
 
	local function copy(obj, ...)
		local newobj = obj:new(unpack(arg))
		for n, v in pairs(obj) do
			newobj[n] = v
		end
		return newobj
	end
 
	members.new  = members.new  or new
	members.copy = members.copy or copy
 
	return mt
end
 
-- make table a class that inherits library methods
-- make t a new table object
require 'Class'
Class(table)
t = table:new()
 
--[[
-- unicode to utf-8
-- tehtmi @ http://stackoverflow.com/questions/26071104
do
	local string_char = string.char
	function utf8(cp)
		if cp < 128 then
			return string_char(cp)
		end
		local s = ""
		local prefix_max = 32
		while true do
			local suffix = cp % 64
			s = string_char(128 + suffix) .. s
			cp = (cp - suffix) / 64
			if cp < prefix_max then
				return string_char((256 - (2 * prefix_max)) + cp) .. s
			end
		prefix_max = prefix_max / 2
		end
	end
end
]]
 
--[[
local str = {}
 
-- reverse a UTF-8 string
function str.reverse ( frame )
	local new_args = str._getParameters( frame.args, { 's' } )
	local s = new_args['s'] or ''
	local len = mw.ustring.len( s )
	local result = {}
 
	for i = len, 1, -1 do
		-- strings are immutable in Lua, so use a table ...
		table.insert( result, mw.ustring.sub( s, i, i ) )
	end
 
	-- ... and implode/join it
	return table.concat( result )
end
 
function str._getParameters( frame_args, arg_list )
	local new_args = {}
	local index = 1
	local value
 
	for i, arg in ipairs( arg_list ) do
		value = frame_args[arg]
		if value == nil then
			value = frame_args[index];
			index = index + 1
		end
		new_args[arg] = value
	end
 
	return new_args
end
 
return str
]]
 
--[[
local p = {}
 
-- return the page ID of the specified page
function p.main(frame)
	local title = frame:getParent().args[1]
	if title == nil then
		-- no parameter; use current page
		title = mw.title.getCurrentTitle()
	else
		-- assume parameter is an existing page
		title = mw.title.new(title, 0)
	end
	-- if page doesn't exist, id = 0
	return title.id
end
 
return p
]]

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.