Commit a2f1deac authored by Bruno Guillaume's avatar Bruno Guillaume
Browse files

put some code behind setTimeout(…,0) because of strange update problem of clust1 codeMirror area

parent b75bab23
......@@ -281,7 +281,7 @@ function deal_with_get_parameters() {
get_custom = getParameterByName("custom");
$.get('./data/shorten/' + get_custom, function(pattern) {
cmEditor.setValue(pattern);
search_pattern();
setTimeout(search_pattern, 0); // hack: else clust1_cm value is not taken into account.
});
}
......@@ -326,20 +326,28 @@ function right_pane(base) {
$.get(dir + "/right_pane.html", function(data) {
$('#right-pane').html(data);
$(".inter").click(function() {
var file = $(this).attr('snippet-file');
clustering = $(this).attr('clustering');
app.clust1 = "no"; // default value
const clustering = $(this).attr('clustering');
if (clustering) {
app.clust1 = "key";
app.clust1_key = clustering;
} else {
app.clust1 = "no";
}
const whether = $(this).attr('whether');
if (whether) {
app.clust1 = "whether";
// setValue is behind timeout to ensure proper cm update
setTimeout(function() { // hack for correct update of clust1_cm
clust1_cm.setValue(whether);
}, 0)
}
// Update of the textarea
$.get(dir + "/" + file, function(pattern) {
cmEditor.setValue(pattern);
});
const file = dir + "/" + $(this).attr('snippet-file');
$.get(file, function(pattern) {
cmEditor.setValue(pattern);
})
.error(function() {
direct_error("Cannot find file `" + file + "`")
});
});
});
}
......
var app = new Vue({
el: '#app',
data: {
clust1: "no", // 3 possible values: no, key or whether
// Init value on whether to ensure nice initialisation.
clust1: "whether", // 3 possible values: no, key or whether
clust1_key: "",
clust1_whether: "",
......@@ -10,16 +11,23 @@ var app = new Vue({
});
$(document).ready(function() {
setTimeout(start, 0); // hack for correct init of clust1_cm
})
function start() {
const get_cluster = getParameterByName("clustering");
const whether = getParameterByName("whether");
if (get_cluster.length > 0) {
app.clust1 = "key";
app.clust1_key = get_cluster;
}
const whether = getParameterByName("whether");
if (whether.length > 0) {
} else if (whether.length > 0) {
app.clust1 = "whether";
app.clust1_whether = whether;
setTimeout(function() {
clust1_cm.setValue(whether); // hack for correct init of clust1_cm
}, 0)
} else {
app.clust1 = "no";
}
})
\ No newline at end of file
}
\ No newline at end of file
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