Change button color to green or red when you click on them and succss et

error
This commit is contained in:
Julien Duponchelle 2015-08-05 23:03:28 +02:00
parent 52f7715d6b
commit e657dc0960
3 changed files with 18 additions and 3 deletions

View File

@ -17,7 +17,7 @@
{% endif %}
{% for version in device["versions"] | reverse %}
<h2>{{ device["name"] }} {{version["name"]}}</h2>
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.install("{{device|jsonify|b64encode}}", "{{version["name"]}}")'>Install</button>
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.button(function() { return gns3.install("{{device|jsonify|b64encode}}", "{{version["name"]}}") })'>Install</button>
<h3>Require files</h3>
{% for image in version.images.values() %}
<h4>{{image["filename"]}}</h4>
@ -27,7 +27,7 @@
Download url: <a href="{{image["download_url"]}}">{{image["download_url"]}}</a><br />
{% if "direct_download_url" in image %}
Direct download url: <a href="{{image["direct_download_url"]}}">{{image["direct_download_url"]}}</a><br />
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.download("{{device|jsonify|b64encode}}", "{{image["md5sum"]}}")'>Download</button>
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.button(function() { return gns3.download("{{device|jsonify|b64encode}}", "{{image["md5sum"]}}") })'>Download</button>
{% endif %}
<hr />
{% endfor %}

View File

@ -2,7 +2,7 @@
{% block script %}
function importDevice() {
gns3.importDevice();
gns3.button(function() { return gns3.importDevice(); });
return false;
}

View File

@ -26,6 +26,21 @@
var notif = $("#notif")
notif.append("<div class=\"alert alert-success alert-dismissible fade in\" role=\"alert\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>" + msg + "</div>")
});
/*
Deactivate the button after success click
*/
gns3.button = function(callback) {
var button = event.target;
$(button).removeClass("btn-primary");
if (callback()) {
$(button).addClass("btn-success");
button.onclick = null;
}
else {
$(button).addClass("btn-danger");
}
}
</script>
<script>