// generates an temporary html page and opens it for viewing // similar to how BOSS does its reports spacing(); divider(); console.log("This program and the file must be in the same directory."); ask("Enter the filename (type quit to quit)", /.+/, function(filename) { // quit if they typed quit if (filename === "quit") { console.log("Goodbye."); quit(); } // otherwise try opening the file else { fs = require("fs"); // check if the file exists fs.exists(filename, function(exists) { // if the file exists if (exists) { readFile(filename); } // if the file does not exist else { console.log("That file does not exist."); quit(); } }); } }); // end ask // reads the file function readFile(filename) { fs.stat(filename, function(error, stats) { fs.open(filename, "r", function(error, fd) { var buffer = new Buffer(stats.size); fs.read(fd, buffer, 0, buffer.length, null, function(error, bytesRead, buffer) { // grab the data var data = buffer.toString("utf8", 0, buffer.length); // close fs fs.close(fd); // check if our appdata folder exists // todo: don't hardcode the appdata folder var appdataFolder = "C:\\Users\\Lord Kai\\AppData\\Roaming\\.ourappdatafolder\\"; fs.stat(appdataFolder, function(error, stats) { // create the folder then move on if(error) { fs.mkdir(appdataFolder,function(error) { if(!error || (error && error.code === 'EEXIST')){ createHTML(data, appdataFolder); } else { console.log(error); quit(); } }); } // don't do anything, just move on else { createHTML(data, appdataFolder); } }); // end appdata folder check }); // end read }); // end open }); // end stat } // creates HTML from our file and outputs it into a temporary HTML file function createHTML(data, appdataFolder) { // find out what we should do with something (just an example) ask("Enter something we can use", /.+/, function(something) { var html = "