Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setup window for web ui

  • Loading branch information...
commit be8e470885ff7c273fd90bd3bd05d7224adc635a 1 parent d67cb42
@Detegr authored
View
BIN  ui/web/img/tapi2plogo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
84 ui/web/index.html
@@ -27,43 +27,65 @@
.dirty {
background-color: #EEF;
}
+ #tapi2p_running {
+ display: none;
+ }
</style>
<script src="js/tapi2p.js"></script>
</head>
<body>
<div class="container-narrow">
- <div class="masthead">
- <h3 class="muted">tapi2p</h3>
- </div>
- <div style="padding-top: 10px; padding-bottom: 50px;">
- <ul class="nav nav-pills pull-right">
- <li class="active"><a class="tapi2pbtn" id="chatbtn" href="">Chat</a></li>
- <li><a class="tapi2pbtn" id="peerbtn" href="">Peers</a></li>
- </ul>
- <ul id="tabs-left" class="nav nav-pills pull-left">
- </ul>
- </div>
- <div id="chatdiv" class="divpage">
- <pre id="chat"></pre>
- <input id="chat_input" class="input-block-level form-control" type="text" placeholder="Chat">
- </div>
- <div id="peerdiv" class="divpage">
- <table class="table table-bordered">
- <thead>
- <tr><th>Ip</th><th>Nick</th><th>Status</th></tr>
- </thead>
- <tbody id="peertable">
- </tbody>
- </table>
+ <div id="tapi2p_running">
+ <div class="masthead">
+ <h3 class="muted">tapi2p</h3>
+ </div>
+ <div style="padding-top: 10px; padding-bottom: 50px;">
+ <ul class="nav nav-pills pull-right">
+ <li class="active"><a class="tapi2pbtn" id="chatbtn" href="">Chat</a></li>
+ <li><a class="tapi2pbtn" id="peerbtn" href="">Peers</a></li>
+ </ul>
+ <ul id="tabs-left" class="nav nav-pills pull-left">
+ </ul>
+ </div>
+ <div id="chatdiv" class="divpage">
+ <pre id="chat"></pre>
+ <input id="chat_input" class="input-block-level form-control" type="text" placeholder="Chat">
+ </div>
+ <div id="peerdiv" class="divpage">
+ <table class="table table-bordered">
+ <thead>
+ <tr><th>Ip</th><th>Nick</th><th>Status</th></tr>
+ </thead>
+ <tbody id="peertable">
+ </tbody>
+ </table>
+ </div>
+ <div id="filelistdiv" class="divpage">
+ <table class="table table-bordered">
+ <thead>
+ <tr><th>Filename</th><th>Hash</th></tr>
+ </thead>
+ <tbody id="filetable">
+ </tbody>
+ </table>
+ </div>
</div>
- <div id="filelistdiv" class="divpage">
- <table class="table table-bordered">
- <thead>
- <tr><th>Filename</th><th>Hash</th></tr>
- </thead>
- <tbody id="filetable">
- </tbody>
- </table>
+ <div id="tapi2p_setup">
+ <div class="row">
+ <span class="span1"><h1 class="span2">tapi2p</h1></span>
+ <span class="span9"></span>
+ <span class="span1"><img src="img/tapi2plogo.png" width="48" /></span>
+ </div>
+ <div class="well">
+ <h2>Initial setup</h2>
+ <h3 class="text-muted">Please fill in following information to continue.</h3>
+ <hr/>
+ <input id="username" class="input-block-level form-control" type="text" placeholder="Username">
+ <br/>
+ <input id="port" class="input-block-level form-control" type="number" placeholder="Port" min="1024" max="65535">
+ <br/>
+ <button id="setupbtn" class="btn btn-primary btn-block">Continue</button>
+ </div>
</div>
</div>
</body>
View
57 ui/web/js/tapi2p.js
@@ -21,7 +21,7 @@ $(function()
$peerdiv.show();
$peerbutton.parent().addClass("active");
$peerbutton.removeClass("dirty");
- sendTapi2pCommand(ws, ListPeers, null);
+ sendTapi2pCommand(ws, ListPeers);
return false;
});
$chatbutton.on("click", function()
@@ -62,7 +62,7 @@ var handleMessage=function(ws, $chat, e)
{
case PeerConnected:
case PeerDisconnected:
- sendTapi2pCommand(ws, ListPeers, null);
+ sendTapi2pCommand(ws, ListPeers);
break;
case ListPeers:
parsePeers(ws, d.data);
@@ -91,6 +91,38 @@ var handleMessage=function(ws, $chat, e)
}
$chat.append(d.data + "\n");
break;
+ case Status:
+ if(d.data.status)
+ {
+ $("#tapi2p_setup").hide();
+ $("#tapi2p_running").show();
+ sendTapi2pCommand(ws, Hello);
+ $(window).on("keypress", function(e)
+ {
+ if(e.keyCode==13)
+ {
+ var $chatinput=$("#chat_input");
+ $chat.append("[" + peermap.localhost.nick + "] " + $chatinput.val() + "\n");
+ sendTapi2pCommand(ws, Message, $chatinput.val());
+ $chatinput.val("");
+ }
+ });
+
+ sendTapi2pCommand(ws, ListPeers);
+ }
+ else
+ {
+ $("#setupbtn").click(function()
+ {
+ var data={
+ nick: $("#username").val(),
+ port: parseInt($("#port").val(), 10)
+ };
+ sendTapi2pCommand(ws, Setup, JSON.stringify(data));
+ sendTapi2pCommand(ws, Status);
+ });
+ }
+ break;
}
};
@@ -170,21 +202,7 @@ function parsePeers(ws, data)
var onConnectionOpen=function(ws,e)
{
- sendTapi2pCommand(ws, Hello, null);
-
- var $chat=$("#chat");
- $(window).on("keypress", function(e)
- {
- if(e.keyCode==13)
- {
- var $chatinput=$("#chat_input");
- $chat.append("[" + peermap.localhost.nick + "] " + $chatinput.val() + "\n");
- sendTapi2pCommand(ws, Message, $chatinput.val());
- $chatinput.val("");
- }
- });
-
- sendTapi2pCommand(ws, ListPeers, null);
+ sendTapi2pCommand(ws, Status);
};
// Ugly redefine of EventType enum in core/event.h
@@ -201,6 +219,9 @@ var Metadata = ENUM_BASE++;
var RequestFileListLocal = ENUM_BASE++;
var RequestFileList = ENUM_BASE++;
var FileList = ENUM_BASE++;
+var AddFile = ENUM_BASE++;
+var Setup = ENUM_BASE++;
+var Status = ENUM_BASE++;
var Hello = -1; // Special for web ui only
@@ -213,7 +234,7 @@ function sendTapi2pCommand(ws, cmd, data, ip, port)
{
ws.send(JSON.stringify({
cmd: cmd,
- data: data,
+ data: data ? data : null,
data_len: data ? stringByteCount(data) : 0,
ip: ip ? ip : null,
port: port ? port : null
View
1  ui/web/server/tapi2p_websocket.c
@@ -284,6 +284,7 @@ int main()
event_addlistener(Message, &coreeventhandler, NULL);
event_addlistener(PeerConnected, &coreeventhandler, NULL);
event_addlistener(PeerDisconnected, &coreeventhandler, NULL);
+ event_addlistener(Status, &coreeventhandler, NULL);
eventsystem_start(corefd);
struct libwebsocket_context* ctx;
Please sign in to comment.
Something went wrong with that request. Please try again.