2009/dap/docs/feat-perms feat-perms.js,1.1,1.2

Update of /sources/public/2009/dap/docs/feat-perms
In directory hutz:/tmp/cvs-serv28350

Modified Files:
	feat-perms.js 
Log Message:
JSLinted.

Index: feat-perms.js
===================================================================
RCS file: /sources/public/2009/dap/docs/feat-perms/feat-perms.js,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- feat-perms.js	3 Mar 2011 11:16:47 -0000	1.1
+++ feat-perms.js	4 Mar 2011 06:54:52 -0000	1.2
@@ -7,13 +7,13 @@
 function Permissions() {
     // private API
     (function () {
-        var isLocalStorage = ('localStorage' in window),
-            isJSON = ('JSON' in window),
-            isEvents = ('addEventListener' in document),
-            isSelector = ('querySelectorAll' in document);
+        var _is_localstorage = (typeof localStorage !== 'undefined') ? true : false,
+            _is_json = (typeof JSON !== 'undefined') ? true : false,
+            _is_eventlistener = (typeof document.addEventListener !== 'undefined') ? true : false,
+            _is_queryselector = (typeof document.querySelectorAll !== 'undefined') ? true : false;
         
         // create fake implementations for challenged browsers
-        if (!isLocalStorage) {
+        if (!_is_localstorage) {
             window.localStorage = {
                 getItem: function (a) { return null; },
                 setItem: function (a, b) {},
@@ -21,25 +21,25 @@
             };
         }
         
-        if (!isJSON) {
+        if (!_is_json) {
             window.JSON = {
                 stringify: function(a) {},
                 parse: function(a) {}
             };
         }
         
-        if (!('permissions_load_error' in window) &&
-            (!isLocalStorage || !isJSON || !isEvents || !isSelector)) {
+        if (!window.permissions_load_error &&
+            (!_is_localstorage || !_is_json || !_is_eventlistener || !_is_queryselector)) {
             window.permissions_load_error = true;
             document.write(
                 '<div id="warning">Warning: Your browser does not support all the features required:<ul>' +
-                '<li>localStorage (' + isLocalStorage + ')</li>' +
-                '<li>JSON (' + (isJSON) + ')</li>' +
-                '<li>DOM2 Events (' + (isEvents) + ')</li>' +
-                '<li>querySelectorAll (' + isSelector + ')</li></ul></div>');
+                '<li>localStorage (' + _is_localstorage + ')</li>' +
+                '<li>JSON (' + _is_json + ')</li>' +
+                '<li>DOM2 Events (' + _is_eventlistener + ')</li>' +
+                '<li>querySelectorAll (' + _is_queryselector + ')</li></ul></div>');
         }
         
-        if (isLocalStorage && isJSON &&
+        if (_is_localstorage && _is_json &&
             localStorage.getItem('feature_permissions') !== null) {
             navigator.feature_permissions = JSON.parse(localStorage.getItem('feature_permissions'));
         } else {
@@ -273,21 +273,19 @@
         
         if (settings_window) {
             settings_window.style.display = 'block';
-            return;
-        }
-        
-        var settings_window = document.createElement('div');
-        
-        settings_window.id = 'settings_window';
-        settings_window.className ='box_shadow_window';
-        settings_window.innerHTML =
-            '<button id="close_settings" class="close_button">X</button>' +
-            '<div id="settings_header">Feature Permission Settings</div>' +
-            '<button onclick="localStorage.removeItem(\'feature_permissions\');' +
-            'document.location.reload(true);">Set to defaults</button>';
+        } else {
+            settings_window = document.createElement('div');
+            settings_window.id = 'settings_window';
+            settings_window.className ='box_shadow_window';
+            settings_window.innerHTML =
+                '<button id="close_settings" class="close_button">X</button>' +
+                '<div id="settings_header">Feature Permission Settings</div>' +
+                '<button onclick="localStorage.removeItem(\'feature_permissions\');' +
+                'document.location.reload(true);">Set to defaults</button>';
             
-        document.body.appendChild(settings_window);
-        _delegateEvents(settings_window);
+            document.body.appendChild(settings_window);
+            _delegateEvents(settings_window);
+        }
     }
     
     function _getResponse(feature_permissions) {

Received on Friday, 4 March 2011 06:54:56 UTC