Skip to content

Commit

Permalink
hide message box only created by one self
Browse files Browse the repository at this point in the history
  • Loading branch information
Binux committed Sep 7, 2012
1 parent 7d556f2 commit 16896a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions js/aria2.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,18 @@ if (typeof ARIA2=="undefined"||!ARIA2) var ARIA2=(function(){
}

function main_alert(_class, msg, timeout) {
var msg_id = (new Date()).getTime();
$("#main-alert .alert").attr("class", "alert "+_class);
$("#main-alert .alert-msg").html(msg);
$("#main-alert").show();
if (timeout)
window.setTimeout(function() { $("#main-alert").fadeOut(); }, timeout);
$("#main-alert").data("msg_id", msg_id).show();
if (timeout) {
window.setTimeout(function() {
if($("#main-alert").data("msg_id") == msg_id) {
$("#main-alert").fadeOut();
}
}, timeout);
}
return msg_id;
}

function bind_event(dom) {
Expand Down Expand Up @@ -79,7 +86,7 @@ if (typeof ARIA2=="undefined"||!ARIA2) var ARIA2=(function(){

return {
init: function(path, onready) {
main_alert("alert-info", "connecting...");
var connect_msg_id = main_alert("alert-info", "connecting...");
$("#add-task-option-wrap").empty().append(YAAW.tpl.add_task_option({}));
$("#aria2-gsetting").empty().append(YAAW.tpl.aria2_global_setting({}));

Expand All @@ -90,7 +97,7 @@ if (typeof ARIA2=="undefined"||!ARIA2) var ARIA2=(function(){
ARIA2.request = ARIA2.request_http;
ARIA2.batch_request = ARIA2.batch_request_http;
if (onready) onready();
if ($("#main-alert .alert-msg").html() == "connecting...") {
if ($("#main-alert").data("msg_id") == connect_msg_id) {
$("#main-alert").fadeOut();
}
} else if (jsonrpc_interface.indexOf("ws") == 0 && WebSocket) {
Expand Down Expand Up @@ -124,7 +131,7 @@ if (typeof ARIA2=="undefined"||!ARIA2) var ARIA2=(function(){
ARIA2.request = ARIA2.request_ws;
ARIA2.batch_request = ARIA2.batch_request_ws;
if (onready) onready();
if ($("#main-alert .alert-msg").html() == "connecting...") {
if ($("#main-alert").data("msg_id") == connect_msg_id) {
$("#main-alert").fadeOut();
}
};
Expand Down
2 changes: 1 addition & 1 deletion offline.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
#2012-9-5 12:18
#2012-9-7 16:12

CACHE:
index.html
Expand Down

0 comments on commit 16896a0

Please sign in to comment.