Fix so that GWTUI js file is not executed under PolyGerrit

When using PolyGerrit, it appears that it loads GWTUI specific
delete-project js files. It dosen't appear to inject "window.Polymer"
into it thus will always equal undefined or false.

To fix this we look for the GERRIT_UI cookie which if the user is using
GWTUI, will have this set.

Change-Id: I2512fe18108799f3a73b00ada8a756eb6e397879
diff --git a/src/main/resources/static/delete-project-with-preserve-disabled.js b/src/main/resources/static/delete-project-with-preserve-disabled.js
index 550ea6c..2065616 100644
--- a/src/main/resources/static/delete-project-with-preserve-disabled.js
+++ b/src/main/resources/static/delete-project-with-preserve-disabled.js
@@ -12,31 +12,44 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-if (!window.Polymer) {
+function _getCookie(name) {
+  var key = name + '=';
+  var result = '';
+  document.cookie.split(';').some(c => {
+    c = c.trim();
+    if (c.indexOf(key, 0) === 0) {
+      result = c.substring(key.length);
+      return true;
+    }
+  });
+  return result;
+}
+
+if (_getCookie('GERRIT_UI') === 'GWT') {
   Gerrit.install(function(self) {
-      function onDeleteProject(c) {
-        var f = c.checkbox();
-        var b = c.button('Delete',
-          {onclick: function(){
-            c.call(
-              {force: f.checked, preserve: false},
-              function(r) {
-                c.hide();
-                window.alert('The project: "'
-                  + c.project
-                  + '" was deleted.'),
-                Gerrit.go('/admin/projects/');
-              });
-          }});
-        c.popup(c.div(
-          c.msg('Are you really sure you want to delete the project: "'
-            + c.project
-            + '"?'),
-          c.br(),
-          c.label(f, 'Delete project even if open changes exist?'),
-          c.br(),
-          b));
-      }
-      self.onAction('project', 'delete', onDeleteProject);
-    });
-}
\ No newline at end of file
+    function onDeleteProject(c) {
+      var f = c.checkbox();
+      var b = c.button('Delete',
+        {onclick: function(){
+          c.call(
+            {force: f.checked, preserve: false},
+            function(r) {
+              c.hide();
+              window.alert('The project: "'
+                + c.project
+                + '" was deleted.'),
+              Gerrit.go('/admin/projects/');
+            });
+        }});
+      c.popup(c.div(
+        c.msg('Are you really sure you want to delete the project: "'
+          + c.project
+          + '"?'),
+        c.br(),
+        c.label(f, 'Delete project even if open changes exist?'),
+        c.br(),
+        b));
+    }
+    self.onAction('project', 'delete', onDeleteProject);
+  });
+}
diff --git a/src/main/resources/static/delete-project.js b/src/main/resources/static/delete-project.js
index 2291279..a72ad60 100644
--- a/src/main/resources/static/delete-project.js
+++ b/src/main/resources/static/delete-project.js
@@ -12,34 +12,47 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-if (!window.Polymer) {
+function _getCookie(name) {
+  var key = name + '=';
+  var result = '';
+  document.cookie.split(';').some(c => {
+    c = c.trim();
+    if (c.indexOf(key, 0) === 0) {
+      result = c.substring(key.length);
+      return true;
+    }
+  });
+  return result;
+}
+
+if (_getCookie('GERRIT_UI') === 'GWT') {
   Gerrit.install(function(self) {
-      function onDeleteProject(c) {
-        var f = c.checkbox();
-        var p = c.checkbox();
-        var b = c.button('Delete',
-          {onclick: function(){
-            c.call(
-              {force: f.checked, preserve: p.checked},
-              function(r) {
-                c.hide();
-                window.alert('The project: "'
-                  + c.project
-                  + '" was deleted.'),
-                Gerrit.go('/admin/projects/');
-              });
-          }});
-        c.popup(c.div(
-          c.msg('Are you really sure you want to delete the project: "'
-            + c.project
-            + '"?'),
-          c.br(),
-          c.label(f, 'Delete project even if open changes exist?'),
-          c.br(),
-          c.label(p, 'Preserve GIT Repository?'),
-          c.br(),
-          b));
-      }
-      self.onAction('project', 'delete', onDeleteProject);
-    });
+    function onDeleteProject(c) {
+      var f = c.checkbox();
+      var p = c.checkbox();
+      var b = c.button('Delete',
+        {onclick: function(){
+          c.call(
+            {force: f.checked, preserve: p.checked},
+            function(r) {
+              c.hide();
+              window.alert('The project: "'
+                + c.project
+                + '" was deleted.'),
+              Gerrit.go('/admin/projects/');
+            });
+        }});
+      c.popup(c.div(
+        c.msg('Are you really sure you want to delete the project: "'
+          + c.project
+          + '"?'),
+        c.br(),
+        c.label(f, 'Delete project even if open changes exist?'),
+        c.br(),
+        c.label(p, 'Preserve GIT Repository?'),
+        c.br(),
+        b));
+    }
+    self.onAction('project', 'delete', onDeleteProject);
+  });
 }