Skip to content
This repository
tree: 4ee9145280
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

executable file 56 lines (41 sloc) 1.21 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
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()






Something went wrong with that request. Please try again.