Skip to content

new feature: show connection history according to json file #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# empty file
.idea
12 changes: 12 additions & 0 deletions connection_history.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"name": "default",
"url":"ws://192.168.4.1:8266/",
"password":"1234"
},
{
"name": "small",
"url":"ws://192.168.1.49:8266/",
"password":"123456"
}
]
5 changes: 5 additions & 0 deletions jquery.min.js

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions webrepl.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
font: 20px/1.5 sans-serif;
}

#url { width: 90%; }
#button { width: 8%; }

/*
.terminal {
float: left;
Expand All @@ -39,6 +42,7 @@
background: #888;
}
</style>
<script src="jquery.min.js"></script>
<script src="term.js"></script>
<script src="FileSaver.js"></script>
</head>
Expand All @@ -49,6 +53,10 @@
<input type="text" name="webrepl_url" id="url" value="ws://192.168.4.1:8266/" />
<input type="submit" id="button" value="Connect" onclick="button_click(); return false;" />
</form>
<div id="connection_history">
connection history:
</div>

<div id="term">
</div>
</div>
Expand Down Expand Up @@ -128,6 +136,24 @@
}
}

$.getJSON("connection_history.json", function (data){
var conn = document.getElementById("connection_history");
$.each(data, function (infoIndex, info){
var new_conn = document.createElement("input");
new_conn.type = "submit";
new_conn.value = info["name"];
new_conn.onclick = function() {
if (connected) {
alert("Already connected, click 'Disconnect' first!")
return;
}
document.getElementById('url').value = info["url"];
button_click();
}
conn.appendChild(new_conn);
})
})

function button_click() {
if (connected) {
ws.close();
Expand Down