diff src/DML/MainVisBundle/Resources/assets/marionette/App.95-jasmine.js @ 0:493bcb69166c

added public content
author Daniel Wolff
date Tue, 09 Feb 2016 20:54:02 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/DML/MainVisBundle/Resources/assets/marionette/App.95-jasmine.js	Tue Feb 09 20:54:02 2016 +0100
@@ -0,0 +1,44 @@
+"use strict";
+
+App.addInitializer(function(options){
+    var _this = this;
+    
+    if (!_.isUndefined(options.enableJasmine)) {
+        var $document = $(document);
+        if (!options.enableJasmine) {
+            // turn jasmine on
+            $document.bind("keydown", "j", function(event) {
+                var url = location.protocol+'//'+location.host+location.pathname;
+                if (url.indexOf('?') > -1) {
+                    url += '&jasmine';
+                } else {
+                    url += '?jasmine';
+                }
+                window.location.href = url;
+            });
+        } else {
+            executeJasmine();
+            // turn jasmine off
+            $document.bind("keydown", "shift+j", function(event) {
+                var url = location.protocol+'//'+location.host+location.pathname;
+                
+                _.each(["jasmine", "catch"], function(variable) {
+                    url = url
+                        .replace(new RegExp("\\?" + variable + "[=]?[a-zA-Z%0-9]*&", "g"), "?")
+                        .replace(new RegExp("\\?" + variable + "[=]?[a-zA-Z%0-9]*$", "g"), "")
+                        .replace(new RegExp("\\&" + variable + "[=]?[a-zA-Z%0-9]*&", "g"), "&")
+                        .replace(new RegExp("\\&" + variable + "[=]?[a-zA-Z%0-9]*$", "g"), "");
+                });
+
+                url = url
+                    .replace(/\?+/, "?")
+                    .replace(/\?$/, "");
+
+                window.location.href = url;
+            });
+        }
+
+
+        
+    }
+});