-- Domain Completion
-- This is compatible with macro version.
--[[

for accel.cfg

%ifplugin luamacro
CTRL VK_RETURN = luamacro(domComplete0)
CTRL ALT VK_RETURN = luamacro(domComplete1)
CTRL SHIFT VK_RETURN = luamacro(domComplete2)
%endif

]]

local dc = "kmeleon.plugins.macros.domComplete"
function DCgo(n)
	local prefix = km.getpref(TYPE_STRING, dc..tostring(n)..".prefix")
	local suffix = km.getpref(TYPE_STRING, dc..tostring(n)..".suffix")
	local url = km.GetGlobalVar(TYPE_STRING, "URLBAR")
	if url and url ~= "" then
		url = (prefix or "") .. url .. (suffix or "")
		km.SetGlobalVar(TYPE_STRING, "URLBAR", url)
		km.id("ID_NAV_GO")
	end
end

function domComplete0() 
	local prefix = "www."
	local suffix = ".com"
	local url = km.GetWindowVar(Window_UrlBar)
	if url and url ~= "" then
		url = (prefix or "") .. url .. (suffix or "")
		-- km.SetGlobalVar(TYPE_STRING, "URLBAR", url)
		-- km.id("ID_NAV_GO")
		NavigateTo(url,OPEN_NORMAL)
	end
end
function domComplete1() 
	local prefix = "www."
	local suffix = ".net"
	local url = km.GetWindowVar(Window_UrlBar)
	if url and url ~= "" then
		url = (prefix or "") .. url .. (suffix or "")
		km.SetGlobalVar(TYPE_STRING, "URLBAR", url)
		km.id("ID_NAV_GO")
	end
end
function domComplete2()
	local prefix = "www."
	local suffix = ".org"
	local url = km.GetWindowVar(Window_UrlBar)
	if url and url ~= "" then
		url = (prefix or "") .. url .. (suffix or "")
		km.SetGlobalVar(TYPE_STRING, "URLBAR", url)
		km.id("ID_NAV_GO")
	end
end
	
