 
 String::startsWith = (str) -> @indexOf(str) == 0
 
-# A very simple method for defining a new class (constructor and methods) using a single hash.
-# No support for inheritance is included because we really shouldn't need it.
+# A very simple method for defining a new class (constructor and methods)
+# using a single hash. No support for inheritance is included because we
+# really shouldn't need it.
 # TODO(philc): remove this.
 Class =
   extend: (properties) ->
     newClass = ->
-      this.init.apply(this, arguments) if (this.init)
+      @init.apply(this, arguments) if @init
       null
     newClass.prototype = properties
     newClass.constructor = newClass
     newClass
 
-globalRoot = if window? then window else global
+globalRoot = window ? global
 globalRoot.extend = (hash1, hash2) ->
   for key of hash2
     hash1[key] = hash2[key]

  escapeHtml: (string) -> string.replace(/</g, "&lt;").replace(/>/g, "&gt;")

  # Generates a unique ID
  createUniqueId: (->
    id = 0
    return -> id += 1
  )()

  hasChromePrefix: (url) ->
    chromePrefixes = [ 'about', 'view-source' ]

Utils =
  getCurrentVersion: ->
    # Chromium #15242 will make this XHR request to access the manifest
    # unnecessary
    manifestRequest = new XMLHttpRequest()
    manifestRequest.open("GET", chrome.extension.getURL("manifest.json"), false)
    manifestRequest.send(null)
