 
   TICKET = "TICKET"
   PROJECT = "PROJECT"
-
-  TICKET_ID      = 0
-  TICKET_SUBJECT = 1
-  TICKET_PRJ_URL = 2
-  TICKET_PRJ_ID  = 3
-  TICKET_SHOW    = 4
+  INDEX = "INDEX"
+
+  TICKET_ID        = 0
+  TICKET_SUBJECT   = 1
+  TICKET_URL_INDEX = 2
+  TICKET_PRJ_ID    = 3
+  TICKET_SHOW      = 4
 
   SHOW = { DEFAULT: 0, NOT: 1, SHOW: 2 }
 

        chrome.storage.sync.get PROJECT, (projects) ->
          if chrome.runtime.lastError? then callback? null; return

          tmp = []
          for t in tickets[TICKET]
            tmp.push {
              id:      t[TICKET_ID]
              subject: t[TICKET_SUBJECT]
              url:   t[TICKET_PRJ_URL]
              project:
                id:    t[TICKET_PRJ_ID]
                name:  projects[PROJECT][t[TICKET_PRJ_URL]][t[TICKET_PRJ_ID]]
              show:    t[TICKET_SHOW]
            }

          callback? tmp


    ###

    ###
    sync: (callback) ->

      urlIndex = []
      projectObj = {}
      for t in tickets
        projectObj[t.url] = projectObj[t.url] or {}
        projectObj[t.url][t.project.id] = t.project.name
      for url, v of projectObj
        urlIndex.push url
      ticketArray = []
      for t in tickets
        for url, i in urlIndex when url is t.url then index = i
        ticketArray.push [t.id, t.subject, index, t.project.id, t.show]

      chrome.storage.sync.set PROJECT: projectObj
      chrome.storage.sync.set INDEX: urlIndex
      chrome.storage.sync.set TICKET: ticketArray, () ->
        if chrome.runtime.lastError?
          callback? false
        else
          callback? true

  }
)
