Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Load local jquery.js copy (has to work offline), along with some minm…

…al changes, eg. proper contenttype for json response.
  • Loading branch information...
commit 92b9c9b6d095fcc701855df723c6b44c947750e5 1 parent 0a43d22
@jzaefferer authored
Showing with 6,513 additions and 9 deletions.
  1. +6,490 −0 jquery.js
  2. +7 −3 netcontrol.js
  3. +16 −6 ui.html
View
6,490 jquery.js
6,490 additions, 0 deletions not shown
View
10 netcontrol.js
@@ -1,7 +1,7 @@
var http = require('http');
var parse = require('url').parse;
var fs = require('fs');
-var client = http.createClient(80, '192.168.50.121');
+var client = http.createClient(80, '192.168.0.2');
function update(name, value, callback) {
var request = client.request('/ctrl.cgi?' + name + '=' + value);
@@ -34,16 +34,20 @@ if (process.argv.length == 3) {
} else {
var http = require('http');
var port = 8124;
- var ui = fs.readFileSync("ui.html", "utf-8");
+ var ui = fs.readFileSync("ui.html", "utf-8"),
+ jquery = fs.readFileSync("jquery.js", "utf-8");
http.createServer(function (req, res) {
var params = parse(req.url, true);
console.log(JSON.stringify(params));
if (params.pathname == "/") {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(ui);
+ } else if (params.pathname.match("jquery.js$")) {
+ res.writeHead(200, {'Content-Type': 'text/javascript'});
+ res.end(jquery);
} else {
update(params.query.name, params.query.value, function(sockets) {
- res.writeHead(200, {'Content-Type': 'text/json'});
+ res.writeHead(200, {'Content-Type': 'application/json'});
res.end(JSON.stringify(sockets));
});
}
View
22 ui.html
@@ -2,9 +2,7 @@
<html>
<head>
<title>netcontrol.js</title>
- <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js"></script>
+ <script src="jquery.js"></script>
<script type="text/javascript">
$(function() {
var anchors = $("a").click(function(event) {
@@ -23,8 +21,20 @@
</script>
</head>
<body>
- <a href="F0">0</a>
- <a href="F1">0</a>
- <a href="F2">0</a>
+ <ul>
+ <li>
+ Mixer
+ <a href="F0">0</a>
+ </li>
+ <li>
+ Radiowecker
+ <a href="F1">0</a>
+ </li>
+ <li>
+ Irgendwas anderes
+ <a href="F2">0</a>
+ </li>
+
+ </ul>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.