deiga/new-Roydon

View on GitHub
app/assets/javascripts/pages.js.coffee

Summary

Maintainability
Test Coverage
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

$ ->
  url = location.href
  name = url.substring(url.lastIndexOf('/')+1)
  nameArr = name.split('.')
  name = nameArr[0]
  if name.length > 0
    $('#navilist > li').removeClass 'selected'
    element = document.getElementById(name)
    if element != null
      element.className += ' selected'
  else
    $('#navilist > li').removeClass 'selected'
    element = document.getElementById("index")
    if element != null
      element.className += ' selected'