diff --git a/README.md b/README.md new file mode 100644 index 0000000..27d2571 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# jenkins-tinderbox + +### To test locally + +Run `node server.js` then `node run.js` + +Open [tinderbox](http://localhost:3000). diff --git a/run.js b/run.js new file mode 100644 index 0000000..a313c62 --- /dev/null +++ b/run.js @@ -0,0 +1,14 @@ +var express = require('express'); +var fs = require('fs') +var app = express(); + +app.use(express.static(__dirname)); +app.get('/', function(req, res){ + fs.readFile('test.html', function(err, text) { + res.setHeader('Content-Type', 'text/html'); + res.end(text); + }) +}); + +app.listen(3000); +console.log('Listening on port 3000'); diff --git a/script.js b/script.js index 62b65d9..bb0809c 100644 --- a/script.js +++ b/script.js @@ -8,7 +8,8 @@ function getJSON(path, callback) { var xmlhttp = new XMLHttpRequest(); - // var url = "origin" + path; + origin = location.hostname === 'localhost' ? origin.replace('3000','8000') : origin; // use proxy for localhost to avoid CORS + var url = origin + path; xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { @@ -177,4 +178,19 @@ getJSON('/api/json?tree=jobs[name,lastCompletedBuild[result,timestamp,url,descri generateTable(tableData); document.body.appendChild(document.createTextNode("Last updated: " + new Date())); + var cb_id = 'cb_ar'; + var checkbox = document.createElement('input'); + checkbox.id = cb_id; + checkbox.type = 'checkbox'; + checkbox.checked = true; + checkbox.style.marginLeft = '100px'; + document.body.appendChild(checkbox); + document.body.appendChild(document.createTextNode("Auto Refresh")); + + setInterval(function() { + if (document.getElementById(cb_id).checked){ + location.reload(); + } +}, 30000); }); + diff --git a/server.js b/server.js index 19e45f0..2477dff 100644 --- a/server.js +++ b/server.js @@ -6,5 +6,6 @@ var request = require('request'); http.createServer(function (req, res) { res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Authorization"); - req.pipe(request('http://localhost:8180' + req.url)).pipe(res); + req.pipe(request("https://ci.freebsd.org" + req.url)).pipe(res); }).listen(8000); +console.log('Proxy running on port 8000'); diff --git a/test.html b/test.html index b79474f..583c58e 100644 --- a/test.html +++ b/test.html @@ -2,9 +2,9 @@
+