Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 0829466527
Fetching contributors…

Cannot retrieve contributors at this time

executable file 55 lines (40 sloc) 1.2 kb
adminMenu = $ "#adminMenu"
logoutButton = $ "#logoutButton"
loginMenu = $ "#loginMenu"
loginButton = $ "#loginButton"
usernameInput = $ "#usernameInput"
passwordInput = $ "#passwordInput"
form_login = $ "form_login"
setCookie = (name, value) ->
c_value = escape value
c_name = escape name
document.cookie = "#{c_name}=#{c_value};"
console.log("Setting cookie to '#{c_name}=#{value};'")
console.log "Cookies is '#{document.cookie}'"
getCookie = (name) ->
cookies = document.cookie.split(";")
console.log "cookies found #{cookies}"
for c in cookies
cookie = c.split "="
if name == cookie[0]
return unescape cookie[1]
isAdmin = () ->
return getCookie("status") == "Admin"
setLogInControl = () ->
if isAdmin()
adminMenu.css {display: "block"}
loginMenu.css {display: "none"}
else
adminMenu.css {display: "none"}
loginMenu.css {display: "block"}
### Old Testing controls
logoutButton.click ->
setCookie "status", "User"
setLogInControl()
loginButton.click ->
form_login.submit ->
alert "Done"
setLogInControl()
###
# Check for the admin cookie and set the status...
setLogInControl()
Jump to Line
Something went wrong with that request. Please try again.