Permalink
Browse files

Add peer page for web ui

  • Loading branch information...
1 parent a96d34d commit 7d3f3925544260544b43e09c6e2b2cff44887f14 @Detegr committed Feb 28, 2014
Showing with 42 additions and 0 deletions.
  1. +25 −0 ui/web/index.html
  2. +17 −0 ui/web/js/tapi2p-backbone.js
View
@@ -68,6 +68,9 @@ <h2>Chat securely with your peers</h2>
<h1>Peers</h1>
<h2>Following peers are online in tapi2p</h2>
</div>
+ <p style="text-align: center;">
+ <a href="#newpeer" class="pure-button pure-button-primary">Add a new peer</a>
+ </p>
<table class="pure-table pure-table-horizontal peertable">
<thead>
<% if(peerList.length > 0) { %>
@@ -95,6 +98,28 @@ <h2>Following peers are online in tapi2p</h2>
</tbody>
</table>
</script>
+ <script type="text/template" id="tapi2p-newpeer-template">
+ <div class="header">
+ <h1>Add a new peer</h1>
+ <h2>Fill in following fields to add a new peer</h2>
+ </div>
+ <form class="pure-form pure-form-stacked" style="margin-top: 1em;">
+ <fieldset>
+ <legend>Connection information</legend>
+ <label for="nick">Nickname (optional)</label>
+ <input class="pure-input-1" type="text" id="nick" placeholder="Nickname (optional)"></input>
+ <label for="ip">Ip address</label>
+ <input class="pure-input-1" type="text" id="ip" placeholder="Ip address" required></input>
+ <label for="port">Port number</label>
+ <input class="pure-input-1" type="number" id="port" placeholder="Port number" min="1" max="65535" required></input>
+
+ <legend style="margin-top: 1em;">Encryption key</legend>
+ <textarea style="width: 100%;" rows="18" id="publickey" required></textarea>
+
+ <button class="pure-button pure-button-primary pure-input-1" style="margin-top: 1em;">Add peer</button>
+ </fieldset>
+ </form>
+ </script>
<script type="text/template" id="tapi2p-files-template">
<div class="header">
<h1>Files</h1>
@@ -105,6 +105,21 @@ var PeerView = Backbone.View.extend({
}
});
+var NewPeerView = Backbone.View.extend({
+ el: $("#tapi2p-main"),
+ tagName: "div",
+ className: "tapi2p-newpeer",
+ initialize: function() {
+ this.render();
+ },
+ render: function() {
+ if(!this.$el.is(":visible")) return this;
+
+ var template=_.template($("#" + this.className + "-template").html(), {});
+ this.$el.html(template);
+ }
+});
+
var FileView = Backbone.View.extend({
el: $("#tapi2p-main"),
model: fileModel,
@@ -136,6 +151,7 @@ var Router = Backbone.Router.extend({
"": "root",
"chat" : "chat",
"peers": "peers",
+ "newpeer": "newpeer",
"error": "error",
"files": "files",
"downloads": "downloads"
@@ -146,6 +162,7 @@ var r=new Router();
r
.on("route:chat", render(ChatView))
.on("route:peers", render(PeerView))
+.on("route:newpeer", render(NewPeerView))
.on("route:error", render(ErrorView))
.on("route:downloads", render(DownloadsView))
.on("route:files", render(FileView));

0 comments on commit 7d3f392

Please sign in to comment.