mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Fixed #886.
This commit is contained in:
parent
92b29915e2
commit
2ef7bff2c5
4 changed files with 19 additions and 0 deletions
|
@ -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%
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
1
vendor/scripts/lz-string-1.3.3-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue