Module:MergedMap/sandbox

require('strict')
local pushpinModule = require ('Module:MergedMapGetPushPin')
local OSMModule = require ('Module:MergedMapGetOSM')
local im = require ('Module:InfoboxImage')
local imf3 = require ('Module:Infobox mapframe/sandbox3')
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
local getArgs = require('Module:Arguments').getArgs

local p = {}

function p.parseCustomWikitext(customWikitext)
	-- infoboxImage will format an image if given wikitext containing an
	-- image, or else pass through the wikitext unmodified
	return infoboxImage({
		args = {
			image = customWikitext
		}
	})
end
function p.ltrim(s)
  return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

function p.main(frame, args)
	local caption_list = {}
	local args = getArgs(frame)
	
	
	if args.useWikidata == nil then
		args.useWikidata = true
	end
	local maps = {}
	local mapNamesList = {}
	local queryString
	if args['mapQuery'] then
		queryString = args['mapQuery']
	elseif args[1] then
		queryString = args[1]
	end
	
	
		
			
	
	
	
	if queryString then
			queryString = p.ltrim (queryString) 
			for mapname in string.gmatch(queryString, '[^#]+') do
				if mapname == "OSM" then
					if args['mapframe-switcher'] == "zooms" then
						local OSMCustomText 
						if args['mapframe-zoom'] then 
							OSMCustomText = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] ..  ' |zoom = ' .. args['mapframe-zoom'] .. ' }}')
						else 
							OSMCustomText = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] ..  '}}')
						end
						OSMCustomText = frame:preprocess(OSMCustomText)
						maps[#maps + 1] =   OSMCustomText
						mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap'

						local OSMCustomTextZoomIn = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] ..  '|zoom = 13}}')
						OSMCustomTextZoomIn = frame:preprocess(OSMCustomTextZoomIn)
						maps[#maps + 1] =  OSMCustomTextZoomIn 
						mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap in Zoom in' 

						local OSMCustomTextZoomOut = p.parseCustomWikitext('{{Infobox mapframe|id= ' .. args['mapframeId'] ..  '|zoom = 1}}')
						OSMCustomTextZoomOut = frame:preprocess(OSMCustomTextZoomOut)
						maps[#maps + 1] =  OSMCustomTextZoomOut 
						mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap in Zoom out' 
					else
						local OSMArgs = args
						OSMArgs['mapframe-width'] = 270
						frame.args['mapframe-zoom'] = 1
						maps[#maps + 1] = '<div>' .. OSMModule.main(frame, OSMArgs) .. '</div>' 
						local count = 0
						for mapname in string.gmatch(queryString, '[^#]+') 
							do count = count + 1 end
						if count == 1 then
							mapNamesList[#mapNamesList + 1] = 'OpenStreetMap' 
						else
							mapNamesList[#mapNamesList + 1] = 'Show OpenStreetMap' 
						end
					end
				elseif string.match(mapname, "OSM%d") then
					local OSMCustomText = args[mapname]
					maps[#maps + 1] = OSMCustomText
					local OSMNumeber = string.match(mapname, "%d")
					mapNamesList[#mapNamesList + 1] = args['OSM' .. OSMNumeber .. 'Caption'] or  mapname
				elseif string.match(mapname, "File%d") then
					local FileCustomText = args[mapname]
					maps[#maps + 1] = FileCustomText
					local FileNumeber = string.match(mapname, "%d")
					mapNamesList[#mapNamesList + 1] = args['File' .. FileNumeber .. 'Caption'] or  mapname
				elseif string.match(mapname, "customMap%d") then 
					local customMapText = args[mapname]
					
					local ImageURL = args[mapname]
					local imageArgs = {}
					imageArgs['image'] = ImageURL
					frame.args['image'] = ImageURL
					frame.args['maxsize'] = 270
					maps[#maps + 1] = '<div>' .. im.InfoboxImage (frame) .. '</div>'
					local CustomNumeber = string.match(mapname, "%d")
					local myString = 'Show satellite map'
					if tonumber(CustomNumeber) > 1 then
						myString = myString .. CustomNumeber
					end
					mapNamesList[#mapNamesList + 1] = args['customMap' .. CustomNumeber .. 'Caption'] or myString
				else
					
					local pushpinArgs = {}
					local pushpinMapName = mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1')
		
					pushpinArgs[1] =  mapname
					pushpinArgs['alt']= args.alt
					pushpinArgs['coordinates']= args.coordinates
					pushpinArgs['label']= args.label
					pushpinArgs['relief']= args.relief or 'yes'
					pushpinArgs['float']= 'center'
					pushpinArgs['width']= 270
					frame.args = pushpinArgs
					maps[#maps + 1] = '<div style= "text-align: left;">' .. pushpinModule.main(frame, pushpinArgs) .. '</div>'
					mapNamesList[#mapNamesList + 1] = 'Show in ' .. mapname
				end
			end
				
	end

	local root = mw.html.create('div'):addClass('switcher-container')
	
	for i =1, #maps do
			local span = root
				:tag('div')
					:wikitext(maps[i])
						:tag('span')
						:addClass('switcher-label')
						:wikitext(mapNamesList[i])
						:css('display', 'none')
			if i == 1 then
					span:attr('data-switcher-default', '')
			end
	end
	return '<div class="center"><div style = "width: 270px;">' ..  tostring(root) .. '</div></div>'
	
end
return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.