Skip to content

Commit

Permalink
Some JS for populating the devide list page
Browse files Browse the repository at this point in the history
*Needs reworking to be applicable to the current entry format
  • Loading branch information
arc12012 committed Nov 9, 2016
1 parent 4868f9f commit dc0300e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion html/deviceListing.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</style>
</head>
<body>
<table data-table="list">
<table id="list">
<tr>
<th>Name</th>
<th>Device Type</th>
Expand Down
31 changes: 27 additions & 4 deletions html/deviceListing.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
var tableHtml = processDeviceData(harvestDevices);
alert(tableHtml);
document.getElementById("list").innerHTML = tableHtml;

console.log(harvestDevices());


function processDeviceData(devices) {
// returns html table entries using data from harvestDevices()
// this is to be inserted into the table with the data-table attribut 'list', which can be found in deviceListing.html
var html="";
for (var i = 0; i<devices.length; i++) {
html+="<tr>";
for (var j = 0; j < devices[i].length; j++) {
// if(i==0) html+="<th>";
// else
html+="<td>";
html+=devices[i][j];
// if(i==0) html+="</th>";
// else
html+="</td>"
console.log(html);
}
html+="</tr>";
}
return html;
}
function harvestDevices() {
// returns array of arrays (currently dummy data)
// each array corresponds to a line item in device listing table
var array = [
["Name","Device Type","Version/OS","Location"],
["Name1","Type1","Version1","Location1"],
["Name2","Type2","Version2","Location2"],
["Name3","Type3","Version3","Location3"],
["Name4","Type4","Version4","Location4"]
];
];
return array;
}

0 comments on commit dc0300e

Please sign in to comment.