This repository has been archived by the owner on Sep 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
input.js
90 lines (73 loc) · 2.65 KB
/
input.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
$("#channel").focus();
(function ($) {
Input = Backbone.Model.extend({
channel: null,
name: null,
mic: null,
provided: null,
stand: null,
});
InputList = Backbone.Collection.extend({
initialize: function (models, options) {
this.bind("add", options.view.addInputTr);
}
});
AppView = Backbone.View.extend({
el: $("body"),
initialize: function () {
this.input_list = new InputList( null, { view: this });
},
events: {
"click #add-input": "createInput",
"keypress" : "createOnEnter"
},
createInput: function () {
var input_channel = $("#channel").val();
var input_name = $("#name").val();
var input_mic = $("#mic").val();
var input_provided = $("#provided").is(":checked");
var input_stand = $("#stand").val();
var provided_string = this.displayBoolean(input_provided);
var input_model = new Input({ channel: input_channel ,
name: input_name,
mic: input_mic,
provided: provided_string,
stand: input_stand, });
this.input_list.add( input_model );
// TODO: Extract this:
$(".field").val("");
$("#provided").attr("checked", false);
$("#channel").focus();
},
createOnEnter: function (event) {
if ( event.which == 13 ) {
this.createInput();
}
},
addInputTr: function (model) {
$("#input-list").append("<tr class='input'></tr>");
$("#input-list tr:last").append("<td>" + model.get('channel') + "</td>");
$("#input-list tr:last").append("<td>" + model.get('name') + "</td>");
$("#input-list tr:last").append("<td>" + model.get('mic') + model.get('provided') + "</td>");
$("#input-list tr:last").append("<td>" + model.get('stand') + "</td>");
},
displayBoolean: function(param) {
if (param === true){
return "*"
}
else {
return " "
}
}
});
var appview = new AppView;
})($);
// Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-38110744-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();