Permalink
Browse files

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...
1 parent 14ff7a0 commit 22829728a950759d708f92d5986e8e53bd6c24e2 @cowboy committed Feb 27, 2012
View
@@ -1,4 +1,4 @@
-Copyright (c) 2011 "Cowboy" Ben Alman
+Copyright (c) 2012 "Cowboy" Ben Alman
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
View
@@ -105,7 +105,11 @@ Bugfix: When the server list is refreshed or sorted, the first server is now bot
v0.3.3
Com center online friends now default to shown, while offline friends default to hidden.
+2/26/2011
+v0.3.4
+Com center online friends are always shown by default, while offline friends are always hidden by default.
+
## License
-Copyright (c) 2011 "Cowboy" Ben Alman
+Copyright (c) 2012 "Cowboy" Ben Alman
Licensed under the MIT license.
<http://benalman.com/about/license/>
@@ -5,7 +5,7 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
var elem = document.createElement("script");
elem.src = "http://localhost:8000/";
@@ -1,6 +1,6 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
cowboy.register("Suppress scrollTop on serverlist refresh");
@@ -1,44 +1,30 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
-cowboy.register("Remember Com center friends list state");
+cowboy.register("Initialize Com center friends list state");
(function() {
- // The comcenter.updateLocalStorage method seems to be called whenever the
- // online and offline friends lists are opened or closed.
- cowboy.hooker.hook(comcenter, "updateLocalStorage", {
- post: function() {
- // Get the current com center friends list state.
- var state = $S("comcenter-surface-friends").getState();
- // Store state for later use.
- localStorage.setItem("cb_show_friends_online", state.showingOnline);
- localStorage.setItem("cb_show_friends_offline", state.showingOffline);
- }
- });
-
// Get the current Battlelog com center friends list state object.
var state = $S("comcenter-surface-friends").getState();
// Fix state, logging if it actually needed to be fixed..
function fix(mode, s) {
// Update the Battlelog state object showingOnline/showingOffline prop.
- state["showing" + mode[0].toUpperCase() + mode.slice(1)] = s;
+ state["showing" + mode] = s;
// If the currently displayed state doesn't reflect the expected state...
+ mode = mode.toLowerCase();
if (Boolean($(".comcenter-friend-" + mode + ":visible").length) !== s) {
- // Log to the console.
- cowboy.log("Com center " + mode + " friends list should have been " +
- (s ? "visible" : "hidden") + " but wasn't, fixing.");
// Actually hide or show the friends list in the DOM.
$("#comcenter-" + mode + "-separator").toggleClass("showing-" + mode, s);
$(".comcenter-friend-" + mode).toggleClass("comcenter-friend-hidden", !s);
}
}
- // Fix both online and offline state. Online defaults to shown, while offline
- // defaults to hidden.
- fix("online", localStorage.getItem("cb_show_friends_online") !== "false");
- fix("offline", localStorage.getItem("cb_show_friends_offline") === "true");
+ // Instead of attempting to store and restore state, always start with Online
+ // friends opened and Offline friends closed. It's just easier that way.
+ fix("Online", true);
+ fix("Offline", false);
// Force Battlelog to update its internal state objects.
comcenter.updateLocalStorage();
@@ -1,6 +1,6 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
cowboy.register("Auto-retry join server");
@@ -1,6 +1,6 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
cowboy.register("Auto-select first server");
View
@@ -1,10 +1,10 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
// Global namespace.
window.cowboy = {
- version: "0.3.3",
+ version: "0.3.4",
registry: [],
register: function(name) {
cowboy.registry.push(name);
View
@@ -1,6 +1,6 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
// ==========================================================================
// Logging
View
@@ -1,5 +1,5 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
cowboy.loaded();
@@ -1,10 +1,10 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
// Global namespace.
window.cowboy = {
- version: "0.3.3",
+ version: "0.3.4",
registry: [],
register: function(name) {
cowboy.registry.push(name);
@@ -18,13 +18,11 @@ window.cowboy = {
// Hooker.
var exports = cowboy.hooker = {};
-/* JavaScript Hooker - v0.2.2 - 11/5/2011
- * http://github.com/cowboy/javascript-hooker
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
+/*! JavaScript Hooker - v0.2.3 - 1/22/2012
+* http://github.com/cowboy/javascript-hooker
+* Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
(function(exports) {
- // Since undefined can be overwritten, an internal reference is kept.
- var undef;
// Get an array from an array-like object with slice.call(arrayLikeObject).
var slice = [].slice;
// Get an "[object [[Class]]]" string with toString.call(value).
@@ -394,43 +392,29 @@ cowboy.register("Auto-select first server");
}
}());
-cowboy.register("Remember Com center friends list state");
+cowboy.register("Initialize Com center friends list state");
(function() {
- // The comcenter.updateLocalStorage method seems to be called whenever the
- // online and offline friends lists are opened or closed.
- cowboy.hooker.hook(comcenter, "updateLocalStorage", {
- post: function() {
- // Get the current com center friends list state.
- var state = $S("comcenter-surface-friends").getState();
- // Store state for later use.
- localStorage.setItem("cb_show_friends_online", state.showingOnline);
- localStorage.setItem("cb_show_friends_offline", state.showingOffline);
- }
- });
-
// Get the current Battlelog com center friends list state object.
var state = $S("comcenter-surface-friends").getState();
// Fix state, logging if it actually needed to be fixed..
function fix(mode, s) {
// Update the Battlelog state object showingOnline/showingOffline prop.
- state["showing" + mode[0].toUpperCase() + mode.slice(1)] = s;
+ state["showing" + mode] = s;
// If the currently displayed state doesn't reflect the expected state...
+ mode = mode.toLowerCase();
if (Boolean($(".comcenter-friend-" + mode + ":visible").length) !== s) {
- // Log to the console.
- cowboy.log("Com center " + mode + " friends list should have been " +
- (s ? "visible" : "hidden") + " but wasn't, fixing.");
// Actually hide or show the friends list in the DOM.
$("#comcenter-" + mode + "-separator").toggleClass("showing-" + mode, s);
$(".comcenter-friend-" + mode).toggleClass("comcenter-friend-hidden", !s);
}
}
- // Fix both online and offline state. Online defaults to shown, while offline
- // defaults to hidden.
- fix("online", localStorage.getItem("cb_show_friends_online") !== "false");
- fix("offline", localStorage.getItem("cb_show_friends_offline") === "true");
+ // Instead of attempting to store and restore state, always start with Online
+ // friends opened and Offline friends closed. It's just easier that way.
+ fix("Online", true);
+ fix("Offline", false);
// Force Battlelog to update its internal state objects.
comcenter.updateLocalStorage();
@@ -5,7 +5,7 @@
/* Battlelog Hacks
* http://benalman.com/
- * Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT */
+ * Copyright (c) 2012 "Cowboy" Ben Alman; Licensed MIT */
var elem = document.createElement("script");
elem.src = "https://raw.github.com/cowboy/battlelog-hacks/master/dist/battlelog-hacks.js";

0 comments on commit 2282972

Please sign in to comment.