From 4e3ce33fda02425e9bb6218da13c25eac2555112 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 1 Apr 2014 13:20:13 +0100 Subject: [PATCH] Mv team-local getParameterByName function to mkws.getParameterByName So it can be accessed from both the team and individual widgets. --- src/mkws-core.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mkws-core.js b/src/mkws-core.js index e63d32e..de050e0 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -106,6 +106,16 @@ mkws.objectWithParent = function(parent) { }; +// This function is taken from a StackOverflow answer +// http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144 +mkws.getParameterByName = function(name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); +} + + mkws.registerWidgetType = function(name, fn) { mkws.widgetType2function[name] = fn; mkws.log("registered widget-type '" + name + "'"); -- 1.7.10.4