Permalink
Browse files

hide message box only created by one self

  • Loading branch information...
1 parent 7d556f2 commit 16896a01d173bd4f2c67ecfb8bf29905ba2f30d4 Binux committed Sep 7, 2012
Showing with 14 additions and 7 deletions.
  1. +13 −6 js/aria2.js
  2. +1 −1 offline.appcache
View
@@ -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) {
@@ -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({}));
@@ -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) {
@@ -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();
}
};
View
@@ -1,5 +1,5 @@
CACHE MANIFEST
-#2012-9-5 12:18
+#2012-9-7 16:12
CACHE:
index.html

0 comments on commit 16896a0

Please sign in to comment.