Commit 54584cbc authored by HERBERT Ryan's avatar HERBERT Ryan Committed by Vidjil Team

builder.js, model.js resolving refactor issues

Passed parameters where appropriate, fixed function references and
adapted model function getStrTime to have a more permissive default
behaviour
parent ab7af7a4
......@@ -212,18 +212,18 @@ Builder.prototype = {
var divParent = elem.parentNode;
divParent.innerHTML = "";
var input = this.create_edit_input();
var id = "edit_value";
var input = this.create_edit_input(id, self.m.getStrTime(self.m.t, data));
divParent.appendChild(input);
divParent.onclick = "";
var a = create_save_button();
var a = this.create_save_button(id, data);
divParent.appendChild(a);
$('#edit_value')
.select();
$(input).select();
},
create_edit_input: function () {
var input = this.setupInput("edit_value", "", "text", self.m.getStrTime(self.m.t, data));
create_edit_input: function (id, value) {
var input = this.setupInput(id, "", "text", value);
input.style.width = "200px";
input.style.border = "0px";
input.style.margin = "0px";
......@@ -242,13 +242,14 @@ Builder.prototype = {
return input;
},
create_save_button: function () {
create_save_button: function (target_id, data) {
var self = this;
var a = document.createElement('a');
a.className = "button";
a.appendChild(document.createTextNode("save"));
a.id = "btnSave";
a.onclick = function () {
self.m.samples[data][self.m.t] = document.getElementById("edit_value").value
self.m.samples[data][self.m.t] = document.getElementById(target_id).value
self.build_top_container()
self.build_info_container()
self.m.update()
......
......@@ -1445,6 +1445,8 @@ Model.prototype = {
switch (format) {
case "name":
case "names":
//TODO resolve thid hack
case "short_name":
if (typeof this.samples.names != 'undefined' && this.samples.names[timeID] != ""){
result = this.samples.names[timeID]
......@@ -1483,6 +1485,12 @@ Model.prototype = {
}
}
}
break;
default:
if (typeof this.samples[format] != 'undefined') {
result = this.samples[format][timeID];
}
break;
}
return result
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment