mirror of
https://github.com/Luzifer/past3.git
synced 2024-11-10 00:40:00 +00:00
Track opened file through URL hash
This commit is contained in:
parent
c86cc33de5
commit
c64f4a3ac3
1 changed files with 12 additions and 10 deletions
22
app.coffee
22
app.coffee
|
@ -33,6 +33,16 @@ $ ->
|
||||||
$('#file-url').bind 'click', () ->
|
$('#file-url').bind 'click', () ->
|
||||||
$(this).select()
|
$(this).select()
|
||||||
|
|
||||||
|
$(window).bind 'hashchange', () ->
|
||||||
|
if window.location.hash.length > 1
|
||||||
|
filename = window.location.hash.substring(1)
|
||||||
|
getFile filename
|
||||||
|
|
||||||
|
$('.file-list-item').removeClass 'active'
|
||||||
|
$(".file-list-item").each () ->
|
||||||
|
if $(this).data('file') == filename
|
||||||
|
$(this).addClass 'active'
|
||||||
|
|
||||||
signinCallback = (authResult) ->
|
signinCallback = (authResult) ->
|
||||||
if authResult.Zi.id_token
|
if authResult.Zi.id_token
|
||||||
|
|
||||||
|
@ -44,6 +54,7 @@ signinCallback = (authResult) ->
|
||||||
AWS.config.credentials.get () ->
|
AWS.config.credentials.get () ->
|
||||||
$('#signin').modal 'hide'
|
$('#signin').modal 'hide'
|
||||||
listFiles()
|
listFiles()
|
||||||
|
$(window).trigger 'hashchange'
|
||||||
|
|
||||||
renderButton = () ->
|
renderButton = () ->
|
||||||
gapi.signin2.render 'signInButton',
|
gapi.signin2.render 'signInButton',
|
||||||
|
@ -101,7 +112,7 @@ loadFileList = (err, data) ->
|
||||||
for obj in data.Contents
|
for obj in data.Contents
|
||||||
key = obj.Key.replace getFilePrefix(), ''
|
key = obj.Key.replace getFilePrefix(), ''
|
||||||
|
|
||||||
li = $("<a href='#' class='list-group-item file-list-item'><span class='badge'></span> #{key}</a>")
|
li = $("<a href='##{key}' class='list-group-item file-list-item'><span class='badge'></span> #{key}</a>")
|
||||||
li.find('.badge').text formatDate(obj.LastModified)
|
li.find('.badge').text formatDate(obj.LastModified)
|
||||||
li.data 'file', key
|
li.data 'file', key
|
||||||
|
|
||||||
|
@ -109,7 +120,6 @@ loadFileList = (err, data) ->
|
||||||
li.addClass 'active'
|
li.addClass 'active'
|
||||||
|
|
||||||
li.appendTo $('#fileList')
|
li.appendTo $('#fileList')
|
||||||
li.bind 'click', openFileClick
|
|
||||||
|
|
||||||
saveFileCallback = (err, data) ->
|
saveFileCallback = (err, data) ->
|
||||||
if err
|
if err
|
||||||
|
@ -142,14 +152,6 @@ getMimeType = (filename) ->
|
||||||
|
|
||||||
return mime
|
return mime
|
||||||
|
|
||||||
openFileClick = () ->
|
|
||||||
getFile $(this).data('file')
|
|
||||||
|
|
||||||
$('.file-list-item').removeClass 'active'
|
|
||||||
$(this).addClass 'active'
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
||||||
filenameInput = () ->
|
filenameInput = () ->
|
||||||
setEditorMime $(this).val()
|
setEditorMime $(this).val()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue