This commit is contained in:
Nick Winter 2014-08-27 17:54:16 -07:00
parent 92b29915e2
commit 2ef7bff2c5
4 changed files with 19 additions and 0 deletions

View file

@ -21,6 +21,11 @@
margin-left: 5px
input[type="file"]
display: none
#thang-type-file-size
width: 350px
float: left
margin: 20px 10px
.treema-row img
max-width: 100%

View file

@ -86,6 +86,7 @@ block outer_content
span.glyphicon.glyphicon-remove
span.spl Clear Data
input#real-upload-button(type="file")
#thang-type-file-size= fileSizeString
div#thang-type-treema
.clearfix
div#display-col.well

View file

@ -56,6 +56,7 @@ module.exports = class ThangTypeEditView extends RootView
@thangType.saveBackups = true
@listenToOnce @thangType, 'sync', ->
@files = @supermodel.loadCollection(new DocumentFiles(@thangType), 'files').model
@updateFileSize()
@refreshAnimation = _.debounce @refreshAnimation, 500
getRenderData: (context={}) ->
@ -64,6 +65,7 @@ module.exports = class ThangTypeEditView extends RootView
context.animations = @getAnimationNames()
context.authorized = not me.get('anonymous')
context.recentlyPlayedLevels = storage.load('recently-played-levels') ? ['items']
context.fileSizeString = @fileSizeString
context
getAnimationNames: ->
@ -197,6 +199,16 @@ module.exports = class ThangTypeEditView extends RootView
@treema.set('raw', @thangType.get('raw'))
@updateSelectBox()
@refreshAnimation()
@updateFileSize()
updateFileSize: ->
file = JSON.stringify(@thangType.attributes)
compressed = LZString.compress(file)
size = (file.length / 1024).toFixed(1) + "KB"
compressedSize = (compressed.length / 1024).toFixed(1) + "KB"
gzipCompressedSize = compressedSize * 1.65 # just based on comparing ogre barracks
@fileSizeString = "Size: #{size} (~#{compressedSize} gzipped)"
@$el.find('#thang-type-file-size').text @fileSizeString
# animation select

1
vendor/scripts/lz-string-1.3.3-min.js vendored Normal file

File diff suppressed because one or more lines are too long