OSDN Git Service

docs: fix js error when there's no api level cookie saved.
authorScott Main <smain@google.com>
Tue, 3 Nov 2009 02:05:41 +0000 (18:05 -0800)
committerScott Main <smain@google.com>
Tue, 3 Nov 2009 02:05:41 +0000 (18:05 -0800)
currently, if there's no api level cookie saved, then
the selectedLevelItem variable will be undefined and will
throw an error at the end of the buildApilevelSelector function.
Now, userApiLevel is set to the max level in this case.

tools/droiddoc/templates/assets/android-developer-reference.js

index b96e136..6299596 100644 (file)
@@ -26,6 +26,7 @@ function buildApiLevelSelector() {
   var maxLevel = SINCE_DATA.length;
   var userApiLevelEnabled = readCookie(API_LEVEL_ENABLED_COOKIE);
   var userApiLevel = readCookie(API_LEVEL_COOKIE);
+  userApiLevel = userApiLevel == 0 ? maxLevel : userApiLevel; // If there's no cookie (zero), use the max by default
 
   if (userApiLevelEnabled == 0) {
     $("#apiLevelSelector").attr("disabled","disabled");