Skip to content

Commit

Permalink
added qs scraping and the search bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Silivestru committed Jul 7, 2012
1 parent b511a3a commit 1b3e379
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 58 deletions.
8 changes: 0 additions & 8 deletions app.js
Expand Up @@ -14,14 +14,6 @@ app.get('/', function (req, res) {
res.sendfile(__dirname + '/public/index.html');
});

app.get('/:id/*?', function (req, res) {
var path = __dirname + "/dump" + req.originalUrl.split("?")[0];
//HACK: we need to handle files that are not html
var data = fs.readFileSync(path, 'utf8');
data += "<script src='/js/detect.js'></script>";
res.send(data);
});

var port = process.env.PORT || 3000;
app.listen(port, function(){
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
Expand Down
5 changes: 0 additions & 5 deletions dump/guid_1234/index.html

This file was deleted.

10 changes: 10 additions & 0 deletions public/css/style.css
Expand Up @@ -12,3 +12,13 @@ body {
a {
color: #00B7FF;
}

#address {
width:80%;
height: auto;
font-size: 2em;
}

#go {
font-size: 2em;
}
30 changes: 18 additions & 12 deletions public/index.html
@@ -1,23 +1,29 @@
<html>
<head>
<title>emulate.phonegap.com</title>
<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="css/style.css" />
<script src="js/index.js"></script>
</head>
<body>
<div class="header">
<img src="/images/cordova_bot.png" alt="" />
<section class="header">
<img src="images/cordova_bot.png" alt="" />
+
<img src="/images/ripple.png" alt="" />
<img src="images/ripple.png" alt="" />
=
<img src="/images/FUCK-YEAH.jpg" alt="" />
</div>
<img src="images/FUCK-YEAH.jpg" alt="" />
</section>

<div>
This is a quick prototype of some thoughts on emulate.phonegap.com
</div>
<section id="navigate" style="display: none">
<input id="address" type="text" />
<button id="go">GO</button>
</section>

<div>
<a href="/guid_1234/index.html?enableripple=true">Link to sample hosted app</a>
</div>
<section id="browser-warning" style="display: none">
OMFG, you needz to be on chrome
</section>

<section id="ripple-warning" style="display: none">
OMFG, you needz the ripples
</section>
</body>
</html>
17 changes: 0 additions & 17 deletions public/js/detect.js

This file was deleted.

56 changes: 56 additions & 0 deletions public/js/index.js
@@ -0,0 +1,56 @@
var netherworld = {
hasRipplez: function () {
return document.getElementById("tinyhippos-injected");
},

goto: function (uri) {
//TODO: Test if window.chrome exists on chromium
if (window.chrome && netherworld.hasRipplez()) {
//TODO: ensure that enableripple=cordova

if (!uri.match("enableripple")) {
uri += uri.match(/\?/) ? "&enableripple=cordova" : "?enableripple=cordova";
}

if (!uri.match("^http")) {
uri = "http://" + uri;
}
console.log(uri);

//window.location.href = uri;
}
},

show: function (id) {
document.getElementById(id).setAttribute("style", "");
},

hide: function (id) {
document.getElementById(id).setAttribute("style", "display: none");
}

};

window.addEventListener("load", function () {
if (!window.chrome) {
console.log("asdf");
netherworld.show("browser-warning");
}
else if (!netherworld.hasRipplez()) {
console.log("ffda");
netherworld.show("ripple-warning");
}
else {
netherworld.show("navigate");

if (window.location.search) {
var uri = decodeURI(window.location.search.split("=")[1]);
netherworld.goto(uri);
}
}

document.getElementById("go").addEventListener("click", function () {
var address = document.getElementById("address");
netherworld.goto(address.value);
});
});
8 changes: 0 additions & 8 deletions routes/index.js

This file was deleted.

2 changes: 0 additions & 2 deletions views/index.jade

This file was deleted.

6 changes: 0 additions & 6 deletions views/layout.jade

This file was deleted.

0 comments on commit 1b3e379

Please sign in to comment.