gitfs.readObject(commit.tree, function(err, tree) { gitfs.readObject(tree['FrontPage'], function(err, blob) { if (err) throw err; assert.equal(blob, givenCommit.files['FrontPage']); done(); }); });
gitfs.readObject(commitId, function(err, commit) { assert.equal(commit.author.name, givenCommit.user.name); assert.equal(commit.author.email, givenCommit.user.email); assert.equal(commit.author.timezone, givenCommit.user.timezone); assert.equal(commit.committer.name, givenCommit.user.name); assert.equal(commit.committer.email, givenCommit.user.email); assert.equal(commit.committer.timezone, givenCommit.user.timezone); assert.equal(commit.message, givenCommit.message); gitfs.readObject(commit.tree, function(err, tree) { gitfs.readObject(tree['FrontPage'], function(err, blob) { if (err) throw err; assert.equal(blob, givenCommit.files['FrontPage']); done(); }); }); });
exports.printFolder = function (objectExp, dirnameO, debug, objectInterfaceFolder, objectLookup, version) { var resText = "<!DOCTYPE html>" + "<html>" + "<head>" + "<meta charset=='utf-8'>" + "<link rel='stylesheet' href='../libraries/css/bootstrap.min.css'>" + ' <script src="../libraries/js/dropzone.js"></script>\n' + ' <style>\n' + ' #total-progress {\n' + ' opacity: 0;\n' + ' transition: opacity 0.3s linear;\n' + ' }\n' + ' </style>\n' + // "<link rel='stylesheet' href='http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css'>"+ "</head>" + '<body style="height: 100%; weight: 100%; background-color: #ffffff;">' +// background:repeating-linear-gradient(-45deg, #e4f6ff, #e4f6ff 5px, white 5px, white 10px);" >\n'+ "<div class='container' style='width: 750px;height:100vh;'>" + "<div class='panel panel-primary'>" + "<div class='panel-heading'>" + "<h3 class='panel-title'><font size='6'>Hybrid Object - Administration</font> Version: "+version+"</h3> " + "</div>" + "</div>" + "<ul class='list-group'>"; var tempFiles = ""; var objectPath = dirnameO + "/objects"; var tempFiles = fs.readdirSync(objectPath).filter(function (file) { return fs.statSync(objectPath + '/' + file).isDirectory(); }); if (debug) { console.log("----------------------- objects"); for (var keykey in objectExp) { console.log(keykey); } console.log("----------------------- objects"); for (var keykey in objectExp) { console.log(keykey); } console.log("----------------------- object lookup"); for (var keykey in objectLookup) { console.log(keykey + " = " + JSON.stringify(objectLookup[keykey])); } console.log("----------------------- end" + Math.random()); } // remove hidden directories if (typeof tempFiles[0] !== "undefined") { while (tempFiles[0][0] === ".") { tempFiles.splice(0, 1); } for (var i = 0; i < tempFiles.length; i++) { resText += "<li class='list-group-item'>" + "<div class='row'>" + "<div class='col-xs-4'>" + "<font size='5'>" + tempFiles[i] + "</font>" + "</div>" + "<div class='col-xs-8 text-right' style='' >"; if (objectExp.hasOwnProperty(HybridObjectsUtilities.readObject(objectLookup, tempFiles[i])) && fs.existsSync(objectPath + "/" + tempFiles[i] + "/target/target.xml")) { resText += "<button class='btn btn-info' onclick=\"window.location.href='/info/" + tempFiles[i] + "'\" > Info</button> "; } else { resText += "<button class='btn btn-info' disabled='disabled'>Info</button> "; } resText += "<button class='"; if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) { resText += "btn btn-success"; } else { resText += "btn btn-primary"; } resText += "' onclick=\"window.location.href='/target/" + tempFiles[i] + "'\">Add Target</button> " + "<button class='"; if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.htm") || fs.existsSync(objectPath + '/' + tempFiles[i] + "/index.html")) { if (fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.dat") && fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.xml")&& fs.existsSync(objectPath + '/' + tempFiles[i] + "/target/target.jpg")) { resText += "btn btn-success"; } else { resText += "btn btn-warning"; } } else { resText += "btn btn-primary"; } resText += "' onclick=\"window.location.href='/content/" + tempFiles[i] + "'\">Add Interface</button> " + // "</div>"+ // "<div class='col-xs-3'>"+ // " <div>" + ' <button class="btn btn-default" onclick="window.location.href=\'/object/' + tempFiles[i] + '/zipBackup/\'"' + tempFiles[i] + '\'" > ' + 'Download' + '</button> ' + " <form style='display: inline; background-color: #bde9ba;' id='delete" + i + "' action='" + objectInterfaceFolder + "' method='post' style='margin: 0px; padding: 0px'>" + "<input type='hidden' name='folder' value='" + tempFiles[i] + "'>" + "<input type='hidden' name='action' value='delete'>" + " <input type='submit' class='btn btn-danger' value='Delete' onclick=\"return confirm('Do you really want to delete the object " + tempFiles[i] + "?')\"> " + "</form>" + //" </div>"+ "</div>" + "</div></li>"; } } resText += "</ul><div class='row'>" + "<form id='newFolderForm' action='" + objectInterfaceFolder + "' method='post' style='display:inline'>" + "<div class='col-xs-5'>" + "<input type='text' class='form-control' name='folder' id='folder' placeholder='New Object Name'/>" + "<input type='hidden' name='action' value='new'>" + "</div>" + "<div class='col-xs-4' style='display: inline'>" + "<button class='btn btn-warning'>Create New Hybrid Object</button> " + "</div>" + "</form>" + "<div class='col-xs-2' style='display: inline'>" + ' <span class="btn btn-default fileinput-button" id="targetButton">' + ' <span>' + 'Upload Object' + '</span>' + ' </span>' + ' <br><br><span class="fileupload-process">' + ' <div id="total-progress" class="progress progress-striped active" role="progressbar" aria-valuemin="0"' + ' aria-valuemax="100" aria-valuenow="0">' + ' <div class="progress-bar progress-bar-success" style="width:100%;" data-dz-uploadprogress></div>' + ' </div>' + ' </span>' + "</div>" + ' <div class="table table-striped" class="files" id="previews" style="display: none">' + ' <div id="template" class="file-row">' + ' </div>' + ' </div>' + "</div>" + // "<span class='badge' style='background-color: #d58512;'>upload default files</span>"+ ' <script>' + ' var previewNode = document.querySelector("#template");' + ' previewNode.id = "";' + ' var previewTemplate = previewNode.parentNode.innerHTML;' + ' previewNode.parentNode.removeChild(previewNode);' + ' var myDropzone = new Dropzone(document.body, {' + ' url: "/backup",' + ' autoProcessQueue: true,' + ' thumbnailWidth: 80,' + 'headers: { "type": "objectUpload" },'+ ' thumbnailHeight: 80,' + ' parallelUploads: 20,' + ' createImageThumbnails: false,' + ' previewTemplate: previewTemplate,' + ' autoQueue: true,' + ' previewsContainer: "#previews",' + ' clickable: ".fileinput-button"' + ' });' + ' myDropzone.on("addedfile", function (file) {' + ' ' + ' ' + ' });' + ' myDropzone.on("drop", function (file) {' + ' ' + ' myDropzone.enqueueFiles(myDropzone.getFilesWithStatus(Dropzone.ADDED));' + ' });' + ' ' + ' myDropzone.on("totaluploadprogress", function (progress) {' + ' document.querySelector("#total-progress").style.width = progress + "%";' + ' });' + ' myDropzone.on("sending", function (file) {' + ' ' + ' document.querySelector("#total-progress").style.opacity = "1";' + ' ' + ' ' + ' });' + ' ' + ' myDropzone.on("queuecomplete", function (progress) {' + //' document.querySelector("#total-progress").style.opacity = "0";'+ // ' document.getElementById("targetButton").className = "btn btn-success fileinput-button";'+ //'location.reload();'+ ' });' + ' myDropzone.on("success", function (file, responseText) {' + ' console.log(responseText ); if(responseText === "done") { document.querySelector("#total-progress").style.opacity = "0"; ' + // ' document.getElementById("targetButton").className = "btn btn-success fileinput-button";'+ 'location.reload();' + '}' + ' });' + ' </script>'; resText += "</body></html>"; return resText; }
exports.uploadTargetText = function (parm, objectLookup, objectExp) { if(debug) console.log("target content"); var objectName = ""; if (objectExp.hasOwnProperty(HybridObjectsUtilities.readObject(objectLookup, parm))) { objectName = HybridObjectsUtilities.readObject(objectLookup, parm); } else { objectName = parm + HybridObjectsUtilities.uuidTime(); } var text = '<!DOCTYPE html>\n' + '<html>\n' + '<head>\n' + ' <meta charset="utf-8">\n' + ' <link rel="stylesheet" href="../libraries/css/bootstrap.min.css">\n' + ' <link rel="stylesheet" href="../libraries/css/bootstrap-theme.min.css">\n' + ' <script src="../libraries/js/dropzone.js"></script>\n' + ' <style>\n' + ' #total-progress {\n' + ' opacity: 0;\n' + ' transition: opacity 0.3s linear;\n' + ' }\n' + ' </style>\n' + '</head>\n' + '<body style="height:100vh; weight: 100%; background-color: #ffffff; background:repeating-linear-gradient(-45deg, #e4f6ff, #e4f6ff 5px, white 5px, white 10px);" >\n' + '<div class="container" id="container" style="width: 750px;">\n' + ' <div class="panel panel-primary">\n' + ' <div class="panel-heading">\n' + ' <h3 class="panel-title"><font size="6">Hybrid Object - ' + parm + ' - Target <a href="../" style=" color: #ffffff; text-decoration: underline;">back</a></font></h3>\n' + ' </div>\n' + ' </div>\n' + ' <div id="actions" class="row">\n' + ' <div class="col-xs-7">\n' + ' <b>1. Upload your target source image (jpg only, < 0.5 MB)</b><br>' + ' 2. Login to the Vuforia Target Manager.<br>' + ' 3. Create a new or open a Device Databases.<br>' + ' 4. Create a target for your Object and name it exactly:<br><b> ' + objectName + '</b><br>' + ' 5. Make sure that only this one Target is Activated.<br>' + ' 6. Download the database and then upload it here:<br>' + ' (You can just drag and drop the files anywhere in the striped area)' + ' </div>' + ' <div class="col-xs-5">' + ' ' + ' <button class="btn btn-info" id="copy-button" data-clipboard-text="' + objectName + '"' + ' title="Click to copy me.">Copy Object Name to Clipboard' + ' </button>' + ' <script src="../libraries/js/ZeroClipboard.js"></script>' + ' <script>' + ' var client = new ZeroClipboard( document.getElementById("copy-button") );' + '</script>' + ' <br><br><span class="fileupload-process">' + ' <div id="total-progress" class="progress progress-striped active" role="progressbar" aria-valuemin="0"' + ' aria-valuemax="100" aria-valuenow="0">' + ' <div class="progress-bar progress-bar-success" style="width:100%;" data-dz-uploadprogress></div>' + ' </div>' + ' </span>' + ' <span class="btn btn-primary fileinput-button" id="targetButton">' + ' <span> Upload Target zip and jpg Files </span>' + ' </span>' + ' </div>' + ' </div>' + ' <div class="table table-striped" class="files" id="previews" style="visibility: hidden">' + ' <div id="template" class="file-row">' + ' </div>' + ' </div>' + ' <script>' + ' var previewNode = document.querySelector("#template");' + ' previewNode.id = "";' + ' var previewTemplate = previewNode.parentNode.innerHTML;' + ' previewNode.parentNode.removeChild(previewNode);' + ' var myDropzone = new Dropzone(document.body, {' + ' url: "/content/' + parm + '",' + ' autoProcessQueue: true,' + ' thumbnailWidth: 80,' + ' thumbnailHeight: 80,' + 'headers: { "type": "targetUpload" },'+ ' parallelUploads: 20,' + ' createImageThumbnails: false,' + ' previewTemplate: previewTemplate,' + ' autoQueue: true,' + ' previewsContainer: "#previews",' + ' clickable: ".fileinput-button"' + ' });' + ' myDropzone.on("addedfile", function (file) {' + ' ' + ' ' + ' });' + ' myDropzone.on("drop", function (file) {' + ' ' + ' myDropzone.enqueueFiles(myDropzone.getFilesWithStatus(Dropzone.ADDED));' + ' });' + ' ' + ' myDropzone.on("totaluploadprogress", function (progress) {' + ' document.querySelector("#total-progress").style.width = progress + "%";' + ' });' + ' myDropzone.on("sending", function (file) {' + ' ' + ' document.querySelector("#total-progress").style.opacity = "1";' + ' ' + ' ' + ' });' + ' ' + ' myDropzone.on("queuecomplete", function (progress) {' + ' });' + ' myDropzone.on("success", function (file, responseText) {' + ' if(responseText === "done") { document.querySelector("#total-progress").style.opacity = "0"; ' + ' document.getElementById("targetButton").className = "btn btn-success fileinput-button";' + // 'location.reload();' + '}' + ' });' + ' </script>' + '</div>' + '<iframe src="https://developer.vuforia.com/targetmanager/project/checkDeviceProjectsCreated?dataRequestedForUserId=" width="100%" height="1000px" style="left: 15px; position:absolute; width: calc(100% - 30px); background-color: #ffffff; " frameborder="0"></iframe>' + '</body>' + '</html>' + ''; return text; }
exports.uploadInfoContent = function (parm, objectLookup, objectExp, knownObjects, socketsInfo) { var objectName = HybridObjectsUtilities.readObject(objectLookup, parm); //parm + thisMacAddress; var uploadInfoTexttempArray = objectExp[objectName].objectLinks; var uploadInfoTexttempArrayValue = objectExp[objectName].objectValues; var ArduinoINstance = 0; // objectExp[objectName] for (subKey in objectExp) { if (subKey === objectName) { break; } ArduinoINstance++; } var text = '<div id="actions" class="row">\n' + ' <div class="col-xs-6">\n' + ' <table class="table table-striped">\n' + ' <thead>\n' + ' <tr>\n' + ' <th class="info">Index</th>\n' + ' <th class="info">I/O Name</th>\n' + ' <th class="info">Value</th>\n' + ' </tr>\n' + ' </thead>\n' + ' <tbody>\n'; infoCount = 0; for (subKey in uploadInfoTexttempArrayValue) { text += "<tr> <td>" + infoCount + "</td><td>" + subKey + "</td><td>" + uploadInfoTexttempArrayValue[subKey].value + "</td></tr>"; infoCount++; } if (infoCount === 0) { text += "<tr> <td> - </td><td> - </td></tr>"; } text += ' </tbody>\n' + ' </table>\n' + '</div>\n' + '<div class="col-xs-6">\n' + ' <table class="table table-striped">\n' + ' <thead>\n' + ' <tr>\n' + ' <th class="info">General Info</th>\n' + ' <th class="info"></th>\n' + ' </tr>\n' + ' </thead>\n' + ' <tbody>\n' + /* '<tr>\n'+ ' <th scope="row">Arduino Instance</th>\n'+ ' <td>'+ArduinoINstance+'</td>\n'+ ' </tr>\n'+*/ ' <tr>\n' + ' <th scope="row">ip</th>\n' + ' <td>' + objectExp[objectName].ip + '</td>\n' + ' </tr>\n' + ' <tr>\n' + ' <th scope="row">version</th>\n' + ' <td>' + objectExp[objectName].version + '</td>\n' + ' </tr>\n' + ' <tr>\n' + ' <th scope="row">sockets</th>\n' + ' <td>' + socketsInfo.sockets + '</td>\n' + ' </tr>\n' + ' <tr>\n' + ' <th scope="row">connected</th>\n' + ' <td>' + socketsInfo.connected + '</td>\n' + ' </tr>\n' + ' <tr>\n' + ' <th scope="row">notConnected</th>\n' + ' <td>' + socketsInfo.notConnected + '</td>\n' + ' </tr>\n' + ' </tbody>\n' + ' </table>\n' + ' <table class="table table-striped">\n' + ' <thead>\n' + ' <tr>\n' + ' <th class="info">Known Objects</th>\n' + ' <th class="info"> </th>\n' + ' </tr>\n' + ' </thead>\n' + ' <tbody>\n'; infoCount = 0; for (subKey in knownObjects) { text += '<tr><td>' + subKey + '</td><td>' + knownObjects[subKey] + '</td></tr>'; infoCount++; } if (infoCount === 0) { text += "<tr> <td>no Object found</td><td> </td></tr>"; } text += ' </tbody>\n' + ' </table>\n' + '</div>\n' + ' </div>\n' + ' <div id="actions" class="row">\n' + '<div class="col-xs-6">\n' + ' </div>\n' + ' </div>\n' + ' <div id="actions" class="row">\n' + ' <div class="col-xs-12">\n' + ' <table class="table table-striped">\n' + ' <thead>\n' + ' <tr>\n' + ' <th class="info"><small>Active Link ID</small></th>\n' + ' <th class="info"><small>Origin Object</small></th>\n' + ' <th class="info"><small>Origin Possition</small></th>\n' + ' <th class="info"><small>Destination Object</small></td>\n' + ' <th class="info"><small>Destination Possition</small></th>\n' + ' </tr>\n' + ' </thead>\n' + ' <tbody>\n'; infoCount = 0; for (subKey in uploadInfoTexttempArray) { if(uploadInfoTexttempArray[subKey].hasOwnProperty("ObjectNameA")) text += '<tr> <td><font size="2">' + subKey + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].ObjectNameA + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].locationInA + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].ObjectNameB + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].locationInB + '</font></td></tr>\n'; else text += '<tr> <td><font size="2">' + subKey + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].ObjectA + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].locationInA + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].ObjectB + '</font></td><td><font size="2">' + uploadInfoTexttempArray[subKey].locationInB + '</font></td></tr>\n'; infoCount++; } if (infoCount === 0) { text += "<tr> <td>no Link found</td><td> </td><td> </td><td> </td><td> </td></tr>"; } text += ' </tbody>\n' + ' </table>\n' + '</div>\n' + '</div>\n' + ''; return text; // var tempFolderName = tempFiles[i] + macAddress.replace(/:/gi, ''); // fill objectExp with objects named by the folders in objects // objectExp[tempFolderName] = new ObjectExp(); // objectExp[tempFolderName].folder = tempFiles[i]; };
exports.uploadInfoText = function (parm, objectLookup, objectExp, knownObjects, socketsInfo) { var objectName = HybridObjectsUtilities.readObject(objectLookup, parm); //parm + thisMacAddress; var ArduinoINstance = 0; for (subKey in objectExp) { if (subKey === objectName) { break; } ArduinoINstance++; } var text = '<html>\n' + '<head>\n' + '<head>'+ ' <link rel="stylesheet" href="../libraries/css/bootstrap.min.css">\n' + ' <link rel="stylesheet" href="../libraries/css/bootstrap-theme.min.css">\n' + '</head>\n' + '<body style="height:100vh; width: 100%">\n' + '<div class="container" id="container" style="width: 750px;">\n' + ' <div class="panel panel-primary">\n' + '<div class="panel-heading">\n' + '<h3 class="panel-title"><font size="6">Hybrid Object - ' + parm + ' - Info <a href="../" style=" color: #ffffff; text-decoration: underline;">back</a></font></h3>\n' + ' </div>\n' + '</div>\n' + '<div id="changeContent"></div>'+ '<script>' + '/*var myVar = setInterval(loadInfoContent, 100);*/' + 'loadInfoContent();'+ 'function loadInfoContent () {console.log("newtick");'+ 'var con = document.getElementById("changeContent")'+ ' , xhr = new XMLHttpRequest();'+ 'xhr.onreadystatechange = function (e) {'+ ' if (xhr.readyState == 4 && xhr.status == 200) {'+ ' con.innerHTML = xhr.responseText;' + 'setTimeout(loadInfoContent, 10);'+ ' }'+ '}; ' + 'xhr.open("GET", "/infoLoadData/'+parm+'", true);'+ ' xhr.setRequestHeader("Content-type", "text/html");'+ ' xhr.send();'+ '}'+ '</script>'+ '</div>\n' + '</body>\n' + '</html>\n' + ''; return text; // var tempFolderName = tempFiles[i] + macAddress.replace(/:/gi, ''); // fill objectExp with objects named by the folders in objects // objectExp[tempFolderName] = new ObjectExp(); // objectExp[tempFolderName].folder = tempFiles[i]; }