Sha256: 5202c15595bf00ad72aa5ac23140fe172b696da14890b4075d0977e4afc8ecb9
Contents?: true
Size: 1.45 KB
Versions: 12
Compression:
Stored size: 1.45 KB
Contents
# ソースコードを表現するモデル Smalruby.SourceCode = Backbone.Model.extend defaults: filename: null data: null initialize: -> unless @get('filename') filename = Smalruby.Views.MainMenuView.getFilename() if filename.length == 0 c = Smalruby.Collections.CharacterSet.first() if c filename = "#{c.get('name')}.rb" else filename = '1.rb' @set('filename', filename) if @get('filename').match(/\.xml$/) data = Smalruby.dumpXml() else if window.blockMode data = Blockly.Ruby.workspaceToCode() else data =window.textEditor.getSession().getDocument().getValue() @set('data', data) run: -> @post_('run') check: -> @post_('check') save2: -> @post_('') write: (force = false) -> action = 'write' action += '?force=1' if force @delete_(action) post_: (action) -> dfr = $.Deferred() $.ajax url: "/source_codes/#{action}" type: 'POST' data: source_code: filename: @get('filename') data: @get('data') dataType: 'json' success: (data, textStatus, jqXHR) -> dfr.resolve(data) error: dfr.reject dfr.promise() delete_: (action) -> dfr = $.Deferred() $.ajax url: "/source_codes/#{action}" type: 'DELETE' dataType: 'json' success: (data, textStatus, jqXHR) -> dfr.resolve(data) error: dfr.reject dfr.promise()
Version data entries
12 entries across 12 versions & 1 rubygems