|
11 | 11 | <script type="text/javascript">"use strict";
|
12 | 12 | var onGet;
|
13 | 13 | var onPut;
|
| 14 | +var setServer; |
14 | 15 | const valueGetElement = function(o) {
|
15 | 16 | const d = window.atob(o.data);
|
16 | 17 | return d;
|
17 | 18 | };
|
18 | 19 | $(function() {
|
19 | 20 | var request = undefined;
|
| 21 | + var server; |
20 | 22 | const getTools = $("#getTools");
|
21 | 23 | const getBtn = $("#getBtn");
|
22 | 24 | const getDropdown = $("#getDropdown");
|
|
69 | 71 | clearGetRequest();
|
70 | 72 | group.empty().append($('<li class="list-group-item list-group-item-danger"/>').text("Error loading content."));
|
71 | 73 | };
|
72 |
| - request.open(method, "http://127.0.0.1:8080/" + input, true); |
| 74 | + request.open(method, server + input, true); |
73 | 75 | request.send(null);
|
74 | 76 | setGetRequest();
|
75 | 77 | return false;
|
|
79 | 81 | const key = $("#getKey").val();
|
80 | 82 | const value = $("#putValue").val();
|
81 | 83 | $.ajax({
|
82 |
| - url: 'http://127.0.0.1:8080/' + key, |
| 84 | + url: server + key, |
83 | 85 | type: 'POST',
|
84 | 86 | data: JSON.stringify({
|
85 | 87 | data:window.btoa(value)
|
|
99 | 101 | return false;
|
100 | 102 | };
|
101 | 103 |
|
| 104 | + const serverValue = $("#serverValue"); |
| 105 | + const serverStatus = $("#serverStatus"); |
| 106 | + const serverBtn = $("#serverBtn"); |
| 107 | + setServer = function(event) { |
| 108 | + server = 'http://'+serverValue.val() + '/'; |
| 109 | + serverStatus.empty(); |
| 110 | + serverBtn.button('loading'); |
| 111 | + $.getJSON(server, function(data){ |
| 112 | + serverStatus.append('<b>Node</b> ').append(data.node_id); |
| 113 | + }).fail(function(error) { |
| 114 | + serverStatus.html("<div class='alert alert-danger' style='margin-bottom: 0px;'><span class='glyphicon glyphicon-remove' aria-hidden='true'></span> Can't access node</div>"); |
| 115 | + }).always(function(error) { |
| 116 | + serverBtn.button('reset'); |
| 117 | + }); |
| 118 | + return false; |
| 119 | + }; |
| 120 | + setServer(); |
102 | 121 | });
|
103 | 122 | </script>
|
104 | 123 | </head>
|
105 | 124 | <body>
|
106 |
| - <div class="container"> |
107 |
| - <header class="page-header"><h1>OpenDHT tester</h1></header> |
108 |
| - <div class="row"> |
109 |
| - <div class="col-sm-8"> |
110 |
| - <div class="panel panel-default" id="dhtResult"> |
| 125 | + <div class="container" style="max-width: 730px;"> |
| 126 | + <header class="page-header"> |
| 127 | + <div class="row"> |
| 128 | + <div class="col-sm-5"> |
| 129 | + <h1>OpenDHT tester</h1> |
| 130 | + </div> |
| 131 | + <div class="col-sm-7"> |
| 132 | + <div class="well well-sm" style="margin-top:10px; margin-bottom:0px;"> |
| 133 | + <form id="serverForm" class="form-inline" onsubmit="return setServer();" style="margin-bottom:4px;"> |
| 134 | + <div class="input-group"> |
| 135 | + <input type="text" class="form-control" id="serverValue" placeholder="Proxy server" value="127.0.0.1:8080"/> |
| 136 | + <span class="input-group-btn"> |
| 137 | + <button id="serverBtn" type="submit" class="btn btn-default" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i>"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> |
| 138 | + </span> |
| 139 | + </div> |
| 140 | + </form> |
| 141 | + <div id="serverStatus"><i class='fa fa-circle-o-notch fa-spin'></i></div> |
| 142 | + </div> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + </header> |
| 146 | + <div class="panel panel-default" id="dhtResult"> |
111 | 147 | <div class="panel-heading">
|
112 | 148 | <div class="row">
|
113 |
| - <div class="col-sm-6"> |
| 149 | + <div class="col-xs-6"> |
114 | 150 | <form class="form-inline" onsubmit="return onGet('GET');">
|
115 | 151 | <div class="input-group">
|
116 | 152 | <input type="text" class="form-control" id="getKey" placeholder="Key" aria-label="Key" />
|
117 |
| - <!--<span class="input-group-addon" id="getStatus"><i class='fa fa-circle-o-notch fa-spin'></i></span>--> |
118 | 153 | <span class="input-group-btn" id="getTools">
|
119 | 154 | <button id="getBtn" class="btn btn-default" data-loading-text="<i class='fa fa-circle-o-notch fa-spin'></i>" type="submit">Get</button>
|
120 | 155 | <button id="getDropdown"type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="caret"></span> <span class="sr-only">Toggle Dropdown</span> </button>
|
|
127 | 162 | </div>
|
128 | 163 | </form>
|
129 | 164 | </div>
|
130 |
| - <div class="col-sm-6"> |
| 165 | + <div class="col-xs-6"> |
131 | 166 | <form class="form-inline" onsubmit="return onPut();">
|
132 | 167 | <div class="input-group">
|
133 | 168 | <input type="text" class="form-control input-group-input" id="putValue" placeholder="Value" />
|
|
137 | 172 | </div>
|
138 | 173 | </form>
|
139 | 174 | </div>
|
140 |
| - </div> |
141 | 175 | </div>
|
142 | 176 | </div>
|
143 | 177 | </div>
|
144 |
| - </div> |
145 | 178 | </div>
|
146 | 179 | </body>
|
147 | 180 | </html>
|
0 commit comments