Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto refresh #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# jenkins-tinderbox

### To test locally

Run `node server.js` then `node run.js`

Open [tinderbox](http://localhost:3000).
15 changes: 15 additions & 0 deletions run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var path = require('path');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment to this one explaining what it is (i.e., that it is for testing)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that the 'path' module is not necessary. Nothing following is using that.

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');
18 changes: 17 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
});

3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
2 changes: 1 addition & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html>
<head>
<link rel="stylesheet" href="style.css" />
<title>FreeBSD CI TinderBox</title>
</head>
<body>

<script src="script.js"></script>
</body>
</html>