HAL.Views.QueryUriDialog = Backbone.View.extend({ initialize: function(opts) { this.href = opts.href; this.uriTemplate = uritemplate(this.href); _.bindAll(this, 'submitQuery'); _.bindAll(this, 'renderPreview'); }, className: 'modal fade', events: { 'submit form': 'submitQuery', 'keyup textarea': 'renderPreview', 'change textarea': 'renderPreview' }, submitQuery: function(e) { e.preventDefault(); var input; try { input = JSON.parse(this.$('textarea').val()); } catch(err) { input = {}; } this.$el.modal('hide'); window.location.hash = this.uriTemplate.expand(this.cleanInput(input)); }, renderPreview: function(e) { var input, result; try { input = JSON.parse($(e.target).val()); result = this.uriTemplate.expand(this.cleanInput(input)); } catch (err) { result = 'Invalid json input'; } this.$('.preview').html(result); }, extractExpressionNames: function (template) { var names = []; for (var i=0; i