From ef3d90534a890e647c5794cfc6138f721ee763ff Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Fri, 22 Apr 2016 10:23:22 +0200 Subject: [PATCH] add vel,cog to table addresses #117 --- docroot/table/config.js | 4 ++- docroot/table/index.html | 60 ++++++++++++++++++++++++++++++++++++---- docroot/table/otable.css | 2 ++ 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/docroot/table/config.js b/docroot/table/config.js index de34ce9..cea978c 100644 --- a/docroot/table/config.js +++ b/docroot/table/config.js @@ -10,6 +10,8 @@ config = { batt: "Battery", tid: "TID", cc: "CC", - addr: "Address" + addr: "Address", + vel: "Vel", + cog: "CoG" } }; diff --git a/docroot/table/index.html b/docroot/table/index.html index 08ec585..c07268b 100644 --- a/docroot/table/index.html +++ b/docroot/table/index.html @@ -115,7 +115,7 @@ order: [[ 2, "desc" ]], columnDefs: [ { orderable : true, targets: [0, 1, 3, 4, 5] }, - + { className: 'topic', name: 'topic', @@ -211,6 +211,56 @@ }, "targets" : [6], }, + { + className: 'vel', + name: 'vel', + title: config.column_titles.vel, + visible: true, + data: null, + render: function(data, type, row) { + if (typeof data.vel === 'undefined' || data.vel === null) { + return ''; + } + + try { + var v = parseInt(data.vel, 10); + if (v < 0) { + return ''; + } + } catch(err) { + return ''; + } + + var t = "{{vel}}"; + return Mustache.render(t, data); + }, + "targets" : [7], + }, + { + className: 'cog', + name: 'cog', + title: config.column_titles.cog, + visible: true, + data: null, + render: function(data, type, row) { + if (typeof data.cog === 'undefined' || data.cog === null) { + return ''; + } + + try { + var c = parseInt(data.cog, 10); + if (c < 0) { + return ''; + } + } catch(err) { + return ''; + } + + var t = "{{cog}}"; + return Mustache.render(t, data); + }, + "targets" : [8], + }, { className: 'cc', name: 'cc', @@ -221,7 +271,7 @@ var t = ""; return Mustache.render(t, data); }, - "targets" : [7], + "targets" : [9], }, { className: 'addr', @@ -233,10 +283,10 @@ var t = "{{addr}}"; return Mustache.render(t, data); }, - "targets" : [8], + "targets" : [10], }, ], - + }); @@ -270,7 +320,7 @@ alert(JSON.stringify(o)); } }); - + }); diff --git a/docroot/table/otable.css b/docroot/table/otable.css index bca89ec..548182b 100644 --- a/docroot/table/otable.css +++ b/docroot/table/otable.css @@ -12,6 +12,8 @@ td.topic, td.tid { font-size: 80%; font-family: courier; } td.addr { font-size: 90%; } td.user { font-size: 80%; } td.batt { font-size: 90%; } +td.vel { font-size: 90%; } +td.cog { font-size: 70%; } #togglers ul { list-style-type: none;