summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/url_utility.js.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/lib/utils/url_utility.js.coffee')
-rw-r--r--app/assets/javascripts/lib/utils/url_utility.js.coffee52
1 files changed, 0 insertions, 52 deletions
diff --git a/app/assets/javascripts/lib/utils/url_utility.js.coffee b/app/assets/javascripts/lib/utils/url_utility.js.coffee
deleted file mode 100644
index e8085e1c2e4..00000000000
--- a/app/assets/javascripts/lib/utils/url_utility.js.coffee
+++ /dev/null
@@ -1,52 +0,0 @@
-((w) ->
-
- w.gl ?= {}
- w.gl.utils ?= {}
-
- # Returns an array containing the value(s) of the
- # of the key passed as an argument
- w.gl.utils.getParameterValues = (sParam) ->
- sPageURL = decodeURIComponent(window.location.search.substring(1))
- sURLVariables = sPageURL.split('&')
- sParameterName = undefined
- values = []
- i = 0
- while i < sURLVariables.length
- sParameterName = sURLVariables[i].split('=')
- if sParameterName[0] is sParam
- values.push(sParameterName[1])
- i++
- values
-
- # #
- # @param {Object} params - url keys and value to merge
- # @param {String} url
- # #
- w.gl.utils.mergeUrlParams = (params, url) ->
- newUrl = decodeURIComponent(url)
- for paramName, paramValue of params
- pattern = new RegExp "\\b(#{paramName}=).*?(&|$)"
- if not paramValue?
- newUrl = newUrl.replace pattern, ''
- else if url.search(pattern) isnt -1
- newUrl = newUrl.replace pattern, "$1#{paramValue}$2"
- else
- newUrl = "#{newUrl}#{(if newUrl.indexOf('?') > 0 then '&' else '?')}#{paramName}=#{paramValue}"
-
- # Remove a trailing ampersand
- lastChar = newUrl[newUrl.length - 1]
-
- if lastChar is '&'
- newUrl = newUrl.slice 0, -1
-
- newUrl
-
- # removes parameter query string from url. returns the modified url
- w.gl.utils.removeParamQueryString = (url, param) ->
- url = decodeURIComponent(url)
- urlVariables = url.split('&')
- (
- variables for variables in urlVariables when variables.indexOf(param) is -1
- ).join('&')
-
-) window