Skip to content

Commit

Permalink
For #94 - added extended info to the mobile UI
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalidze committed Feb 25, 2015
1 parent e39b380 commit ab76742
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/webapp/m/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@
<div class="col-66">{{address}}</div>
</div>
{{/if}}
{{#if other}}
{{#each other}}
<div class="row">
<div class="col-33">{{@key}}</div>
<div class="col-66">{{this}}</div>
</div>
{{/each}}
{{/if}}
</div>
</script>
<!-- Path to your app js-->
Expand Down
25 changes: 25 additions & 0 deletions src/main/webapp/m/js/traccar-mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,31 @@ function drawDeviceDetails(deviceId, position) {
if (position == undefined) {
deviceDetails.html('<div class="content-block">No data available</div>');
} else {
// parse 'other' field
if (window.DOMParser) {
parser = new DOMParser();
xmlDoc = parser.parseFromString(position.other, "text/xml");
// Internet Explorer
} else {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(position.other);
}

if (xmlDoc.documentElement == null) {
position.other = null;
} else {
position.other = {};
var nodes = xmlDoc.documentElement.childNodes;
for (i = 0; i < nodes.length; i++) {
if (nodes[i].textContent == null) {
position.other[nodes[i].nodeName] = nodes[i].nodeValue;
} else {
position.other[nodes[i].nodeName] = nodes[i].textContent;
}
}
}

var source = $$('#device-details-template').html();
var template = Handlebars.compile(source);

Expand Down

0 comments on commit ab76742

Please sign in to comment.