local js = require "js" local window = js.global local document = window.document local function sleep(delay) local co = assert(coroutine.running(), "Should be run in a coroutine") window:setTimeout(function() assert(coroutine.resume(co)) end, delay*1000) coroutine.yield() end local menu = document:querySelector("#menu") menu:addEventListener('click', function() if document:getElementById('MenuScreen').className == "Overlay" then document:getElementById('MenuScreen').className = "OverlayShow" document:getElementById('SearchScreen').className = "SearchOverlay" else document:getElementById('MenuScreen').className = "Overlay" end end) local menu = document:querySelector("#osearch") menu:addEventListener('click', function() if document:getElementById('SearchScreen').className == "SearchOverlay" then document:getElementById('SearchScreen').className = "SearchOverlayShow" document:getElementById('MenuScreen').className = "Overlay" else document:getElementById('SearchScreen').className = "SearchOverlay" end end) function callfunction() local mf = coroutine.create(function() end) coroutine.resume(mf) end coroutine.wrap(function() print 'Hey!' sleep(2) print 'Glad to see you here!' end)()