-
Notifications
You must be signed in to change notification settings - Fork 0
/
forwarder.js
43 lines (37 loc) · 954 Bytes
/
forwarder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Urls = new Meteor.Collection('urls');
if (Meteor.isClient) {
Router.route('/forward', {
before: function(){
var url = Urls.findOne().url;
if (!(typeof url == "undefined")) {
document.write("forwarding");
setTimeout(function() { window.location.replace(url); }, 2000);
}
else {
document.write("No forward url defined defined");
}
}
});
Router.route('/', function(){
this.render('home');
});
Template.home.helpers({
url: function () {
return Urls.findOne().url;
}
});
Template.home.events({
'keyup input': function (event,template) {
var url = template.find("input").value
var _id = Urls.findOne()._id;
Urls.update(_id, {$set: {url: url}});
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
Urls.remove({});
Urls.insert({url: "http://"});
});
}