Skip to content

Commit 83f051b

Browse files
committed
added firmware information on list item click
1 parent 3dc0161 commit 83f051b

3 files changed

Lines changed: 90 additions & 17 deletions

File tree

nw-miniblip/index.html

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
editor.setOptions({
2626
fontSize: "15pt"
2727
});
28+
29+
//open source links in a new browser
30+
$('a[target=_blank]').on('click', function(){
31+
require('nw.gui').Shell.openExternal( this.href );
32+
return false;
33+
});
2834
});
2935
</script>
3036

@@ -42,13 +48,34 @@
4248

4349
<div id = "main">
4450

45-
<div id = "firmware-list">
46-
<h1> FIRMWARES </h1>
47-
<div id = "list"> </div>
48-
</div>
51+
<div id = "firmware-upload-section">
52+
53+
<div id="action">
54+
<div class="info">
55+
<div class="heading">
56+
<div class="name"></div>
57+
<div class="author"></div>
58+
<div class="source"><a target = "_blank" href="">source</a></div>
59+
</div>
60+
<div id="description"></div>
61+
</div>
62+
63+
<button id = "upload"> upload firmware </button>
64+
</div>
65+
66+
67+
68+
69+
<div id = "firmware-list">
70+
<h1> FIRMWARES </h1>
71+
<div id = "list"> </div>
72+
</div>
73+
74+
<div id = "board">
75+
<img src="./images/miniblip_board.png">
76+
<h1 id = "info"> MINIBLIP no ha sido detectada </h1>
77+
</div>
4978

50-
<div id = "board">
51-
<img src="./images/miniblip_board.png">
5279
</div>
5380

5481
<div id="editor-container">

nw-miniblip/javascript/main.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ function get_list_firmwares_remote() {
5252

5353
$.get(url, function(data) {
5454
var obj = $.parseJSON(data);
55+
56+
5557
$.each(obj, function(i, value) {
56-
add_item_to_firmware_list(obj[i], true);
58+
add_item_to_firmware_list(value, true);
5759
});
5860

5961
});
@@ -74,26 +76,39 @@ function get_remote_firmware_url(name) {
7476

7577
function add_item_to_firmware_list(obj, isRemote) {
7678
console.log("added " + obj.name);
77-
var file_url = "";
79+
var file_url = "";
80+
7881
if (isRemote) {
7982
file_url = get_remote_firmware_url(obj.name);
8083
console.log(file_url);
8184
} else {
8285
file_url = get_local_firmware_path(obj.name);
8386
}
8487

85-
$("#firmware-list #list").append('<div class="item" id = '+obj.id +'><div class="name">' + obj.name +'</div><div class="author">'+obj.author+'</div></div>');
86-
$("#firmware-list #" + obj.id).click(function() {
8788

88-
if (isRemote) {
89-
download_firmware(file_url, function() {
90-
//upload_firmware(file_url, "/dev/sdb");
91-
});
92-
} else {
93-
upload_firmware(file_url, "/dev/sdb");
94-
}
89+
$item = $('<div class="item" id = '+obj.id +'><div class="name">' + obj.name +'</div><div class="author">'+obj.author+'</div></div>');
90+
91+
$("#firmware-list #list").append($item)
92+
93+
$item.click(function() {
94+
var $div = $("#firmware-upload-section #action");
95+
96+
$div.fadeOut("500", function() {
97+
$div.find(".name").text(obj.name);
98+
$div.find(".author").text(obj.author);
99+
$div.find(".source a").attr("href", obj.source);
100+
$(this).fadeIn("500");
101+
102+
});
95103

104+
if (isRemote) {
105+
download_firmware(file_url, function() {
106+
//upload_firmware(file_url, "/dev/sdb");
96107
});
108+
} else {
109+
upload_firmware(file_url, "/dev/sdb");
110+
}
111+
});
97112
}
98113

99114
function get_list_firmwares_local() {

nw-miniblip/styles/main.less

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@ body {
105105
}
106106

107107

108+
#firmware-upload-section {
109+
110+
#action {
111+
position: fixed;
112+
bottom: 0;
113+
left: 355px;
114+
width: 425px;
115+
padding: 10px;
116+
border-radius: 2px 2px 0px 0px;
117+
display: none;
118+
119+
#heading {
120+
font-weight: 800;
121+
font-size: 2em;
122+
}
123+
124+
#upload {
125+
float: right;
126+
padding: 12px;
127+
}
128+
}
129+
130+
}
131+
108132
#firmware-list {
109133
float: left;
110134
width: 200px;
@@ -124,6 +148,7 @@ body {
124148
.item {
125149
border-bottom: 1px dotted black;
126150
padding: 11px;
151+
cursor: pointer;
127152

128153
.name {
129154
font-weight: bold;
@@ -175,6 +200,12 @@ body {
175200
opacity: 0.5;
176201
margin-top: 15%;
177202
}
203+
204+
#info {
205+
margin-top: 10px;
206+
font-size: 1.2em;
207+
color: gray;
208+
}
178209
}
179210

180211
.disabled {

0 commit comments

Comments
 (0)