Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updating to v0.3.4: Com center online friends are always shown by def…

…ault, while offline friends are always hidden by default.
  • Loading branch information...
commit 22829728a950759d708f92d5986e8e53bd6c24e2 1 parent 14ff7a0
Ben Alman authored February 26, 2012
2  LICENSE-MIT
... ...
@@ -1,4 +1,4 @@
1  
-Copyright (c) 2011 "Cowboy" Ben Alman
  1
+Copyright (c) 2012 "Cowboy" Ben Alman
2 2
 
3 3
 Permission is hereby granted, free of charge, to any person
4 4
 obtaining a copy of this software and associated documentation
6  README.md
Source Rendered
@@ -105,7 +105,11 @@ Bugfix: When the server list is refreshed or sorted, the first server is now bot
105 105
 v0.3.3
106 106
 Com center online friends now default to shown, while offline friends default to hidden.
107 107
 
  108
+2/26/2011
  109
+v0.3.4
  110
+Com center online friends are always shown by default, while offline friends are always hidden by default.
  111
+
108 112
 ## License
109  
-Copyright (c) 2011 "Cowboy" Ben Alman  
  113
+Copyright (c) 2012 "Cowboy" Ben Alman  
110 114
 Licensed under the MIT license.  
111 115
 <http://benalman.com/about/license/>
2  dev/battlelog-hacks-dev.user.js
@@ -5,7 +5,7 @@
5 5
 
6 6
 /* Battlelog Hacks
7 7
  * http://benalman.com/
8  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  8
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
9 9
 
10 10
 var elem = document.createElement("script");
11 11
 elem.src = "http://localhost:8000/";
2  dev/src/bh-ajaxnavigation-scrolltop.js
... ...
@@ -1,6 +1,6 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 cowboy.register("Suppress scrollTop on serverlist refresh");
6 6
 
30  dev/src/bh-comcenter-friends.js
... ...
@@ -1,44 +1,30 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5  
-cowboy.register("Remember Com center friends list state");
  5
+cowboy.register("Initialize Com center friends list state");
6 6
 
7 7
 (function() {
8  
-  // The comcenter.updateLocalStorage method seems to be called whenever the
9  
-  // online and offline friends lists are opened or closed.
10  
-  cowboy.hooker.hook(comcenter, "updateLocalStorage", {
11  
-    post: function() {
12  
-      // Get the current com center friends list state.
13  
-      var state = $S("comcenter-surface-friends").getState();
14  
-      // Store state for later use.
15  
-      localStorage.setItem("cb_show_friends_online", state.showingOnline);
16  
-      localStorage.setItem("cb_show_friends_offline", state.showingOffline);
17  
-    }
18  
-  });
19  
-
20 8
   // Get the current Battlelog com center friends list state object.
21 9
   var state = $S("comcenter-surface-friends").getState();
22 10
 
23 11
   // Fix state, logging if it actually needed to be fixed..
24 12
   function fix(mode, s) {
25 13
     // Update the Battlelog state object showingOnline/showingOffline prop.
26  
-    state["showing" + mode[0].toUpperCase() + mode.slice(1)] = s;
  14
+    state["showing" + mode] = s;
27 15
     // If the currently displayed state doesn't reflect the expected state...
  16
+    mode = mode.toLowerCase();
28 17
     if (Boolean($(".comcenter-friend-" + mode + ":visible").length) !== s) {
29  
-      // Log to the console.
30  
-      cowboy.log("Com center " + mode + " friends list should have been " +
31  
-        (s ? "visible" : "hidden") + " but wasn't, fixing.");
32 18
       // Actually hide or show the friends list in the DOM.
33 19
       $("#comcenter-" + mode + "-separator").toggleClass("showing-" + mode, s);
34 20
       $(".comcenter-friend-" + mode).toggleClass("comcenter-friend-hidden", !s);
35 21
     }
36 22
   }
37 23
 
38  
-  // Fix both online and offline state. Online defaults to shown, while offline
39  
-  // defaults to hidden.
40  
-  fix("online", localStorage.getItem("cb_show_friends_online") !== "false");
41  
-  fix("offline", localStorage.getItem("cb_show_friends_offline") === "true");
  24
+  // Instead of attempting to store and restore state, always start with Online
  25
+  // friends opened and Offline friends closed. It's just easier that way.
  26
+  fix("Online", true);
  27
+  fix("Offline", false);
42 28
 
43 29
   // Force Battlelog to update its internal state objects.
44 30
   comcenter.updateLocalStorage();
2  dev/src/bh-launcher-retry.js
... ...
@@ -1,6 +1,6 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 cowboy.register("Auto-retry join server");
6 6
 
2  dev/src/bh-serverguidesort-select.js
... ...
@@ -1,6 +1,6 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 cowboy.register("Auto-select first server");
6 6
 
4  dev/src/intro.js
... ...
@@ -1,10 +1,10 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 // Global namespace.
6 6
 window.cowboy = {
7  
-  version: "0.3.3",
  7
+  version: "0.3.4",
8 8
   registry: [],
9 9
   register: function(name) {
10 10
     cowboy.registry.push(name);
2  dev/src/log.js
... ...
@@ -1,6 +1,6 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 // ==========================================================================
6 6
 // Logging
2  dev/src/outro.js
... ...
@@ -1,5 +1,5 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 cowboy.loaded();
40  dist/battlelog-hacks.js
... ...
@@ -1,10 +1,10 @@
1 1
 /* Battlelog Hacks
2 2
  * http://benalman.com/
3  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  3
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
4 4
 
5 5
 // Global namespace.
6 6
 window.cowboy = {
7  
-  version: "0.3.3",
  7
+  version: "0.3.4",
8 8
   registry: [],
9 9
   register: function(name) {
10 10
     cowboy.registry.push(name);
@@ -18,13 +18,11 @@ window.cowboy = {
18 18
 // Hooker.
19 19
 var exports = cowboy.hooker = {};
20 20
 
21  
-/* JavaScript Hooker - v0.2.2 - 11/5/2011
22  
- * http://github.com/cowboy/javascript-hooker
23  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
  21
+/*! JavaScript Hooker - v0.2.3 - 1/22/2012
  22
+* http://github.com/cowboy/javascript-hooker
  23
+* Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
24 24
 
25 25
 (function(exports) {
26  
-  // Since undefined can be overwritten, an internal reference is kept.
27  
-  var undef;
28 26
   // Get an array from an array-like object with slice.call(arrayLikeObject).
29 27
   var slice = [].slice;
30 28
   // Get an "[object [[Class]]]" string with toString.call(value).
@@ -394,43 +392,29 @@ cowboy.register("Auto-select first server");
394 392
   }
395 393
 }());
396 394
 
397  
-cowboy.register("Remember Com center friends list state");
  395
+cowboy.register("Initialize Com center friends list state");
398 396
 
399 397
 (function() {
400  
-  // The comcenter.updateLocalStorage method seems to be called whenever the
401  
-  // online and offline friends lists are opened or closed.
402  
-  cowboy.hooker.hook(comcenter, "updateLocalStorage", {
403  
-    post: function() {
404  
-      // Get the current com center friends list state.
405  
-      var state = $S("comcenter-surface-friends").getState();
406  
-      // Store state for later use.
407  
-      localStorage.setItem("cb_show_friends_online", state.showingOnline);
408  
-      localStorage.setItem("cb_show_friends_offline", state.showingOffline);
409  
-    }
410  
-  });
411  
-
412 398
   // Get the current Battlelog com center friends list state object.
413 399
   var state = $S("comcenter-surface-friends").getState();
414 400
 
415 401
   // Fix state, logging if it actually needed to be fixed..
416 402
   function fix(mode, s) {
417 403
     // Update the Battlelog state object showingOnline/showingOffline prop.
418  
-    state["showing" + mode[0].toUpperCase() + mode.slice(1)] = s;
  404
+    state["showing" + mode] = s;
419 405
     // If the currently displayed state doesn't reflect the expected state...
  406
+    mode = mode.toLowerCase();
420 407
     if (Boolean($(".comcenter-friend-" + mode + ":visible").length) !== s) {
421  
-      // Log to the console.
422  
-      cowboy.log("Com center " + mode + " friends list should have been " +
423  
-        (s ? "visible" : "hidden") + " but wasn't, fixing.");
424 408
       // Actually hide or show the friends list in the DOM.
425 409
       $("#comcenter-" + mode + "-separator").toggleClass("showing-" + mode, s);
426 410
       $(".comcenter-friend-" + mode).toggleClass("comcenter-friend-hidden", !s);
427 411
     }
428 412
   }
429 413
 
430  
-  // Fix both online and offline state. Online defaults to shown, while offline
431  
-  // defaults to hidden.
432  
-  fix("online", localStorage.getItem("cb_show_friends_online") !== "false");
433  
-  fix("offline", localStorage.getItem("cb_show_friends_offline") === "true");
  414
+  // Instead of attempting to store and restore state, always start with Online
  415
+  // friends opened and Offline friends closed. It's just easier that way.
  416
+  fix("Online", true);
  417
+  fix("Offline", false);
434 418
 
435 419
   // Force Battlelog to update its internal state objects.
436 420
   comcenter.updateLocalStorage();
2  dist/battlelog-hacks.user.js
@@ -5,7 +5,7 @@
5 5
 
6 6
 /* Battlelog Hacks
7 7
  * http://benalman.com/
8  
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
  8
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
9 9
 
10 10
 var elem = document.createElement("script");
11 11
 elem.src = "https://raw.github.com/cowboy/battlelog-hacks/master/dist/battlelog-hacks.js";

0 notes on commit 2282972

Please sign in to comment.
Something went wrong with that request. Please try again.