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
|
function error(str){
if(str.indexOf("ERROR")>-1){
$('.error-div').html(str);
$('.main-container').hide();
$('.main-pager').hide();
$('.error-div').show();
return true;
}else{
$('.error-div').hide();
$('.main-container').show();
$('.main-pager').show();
return false;
}
}
function getConf(url){
var conf = {};
$.ajax({
url: url,
async: false,
success: function(data){
conf = data;
}
});
return conf;
}
function updateData(formData){
}
function redirect(url){
window.location = url;
}
function isRecord(str){
return str.slice(0,2) == "r:";
}
function hasMoreThanNChars(str, count){
var c = parseInt(count);
if(str.length > c){
return str.slice(0, c) + "...";
}else{
return str;
}
}
Handlebars.registerHelper("substract", function(from, value){
return parseInt(from) - parseInt(value);
});
Handlebars.registerHelper("append_new", function(value){
return value;
});
Handlebars.registerHelper("is_record", function(value){
var str = value.toString();
if (isRecord(str)){
return "<a href='/html/data.html?op=search&showid=yes&recids="+str.slice(2)+"'></a>";
}else{
return str;
}
});
Handlebars.registerHelper("show_first_n", function(value, count){
var str = value.toString();
if (isRecord(str)){
var record = str.slice(2);
return "<a href='/html/data.html?op=search&showid=yes&recids="+record+"'>"+record+"</a>";
}else{
return hasMoreThanNChars(str, count);
}
});
|