From 823be968439cd37884c738d5cb381f3481b796d4 Mon Sep 17 00:00:00 2001 From: Renzo Lucioni Date: Fri, 5 Sep 2014 15:46:23 -0400 Subject: [PATCH] Remove unused analytics JS left over by 3rd party auth changes --- common/static/js/spec/utility_spec.js | 23 ------------ common/static/js/src/utility.js | 50 --------------------------- lms/templates/login.html | 10 +++--- lms/templates/register.html | 2 +- lms/templates/widgets/segment-io.html | 6 ---- 5 files changed, 6 insertions(+), 85 deletions(-) diff --git a/common/static/js/spec/utility_spec.js b/common/static/js/spec/utility_spec.js index c268d816dc..c44d36e893 100644 --- a/common/static/js/spec/utility_spec.js +++ b/common/static/js/spec/utility_spec.js @@ -16,26 +16,3 @@ describe('utility.rewriteStaticLinks', function () { ).toBe('') }); }); - -describe('utility.appendParameter', function() { - it('creates and populates query string with provided parameter', function() { - expect(appendParameter('/cambridge', 'season', 'fall')).toBe('/cambridge?season=fall') - }); - it('appends provided parameter to existing query string parameters', function() { - expect(appendParameter('/cambridge?season=fall', 'color', 'red')).toBe('/cambridge?season=fall&color=red') - }); - it('appends provided parameter to existing query string with a trailing ampersand', function() { - expect(appendParameter('/cambridge?season=fall&', 'color', 'red')).toBe('/cambridge?season=fall&color=red') - }); - it('overwrites existing parameter with provided value', function() { - expect(appendParameter('/cambridge?season=fall', 'season', 'winter')).toBe('/cambridge?season=winter'); - expect(appendParameter('/cambridge?season=fall&color=red', 'color', 'orange')).toBe('/cambridge?season=fall&color=orange'); - }); -}); - -describe('utility.parseQueryString', function() { - it('converts a non-empty query string into a key/value object', function() { - expect(JSON.stringify(parseQueryString('season=fall'))).toBe(JSON.stringify({season:'fall'})); - expect(JSON.stringify(parseQueryString('season=fall&color=red'))).toBe(JSON.stringify({season:'fall', color:'red'})); - }); -}); diff --git a/common/static/js/src/utility.js b/common/static/js/src/utility.js index 2ea5da08fc..beecb549cb 100644 --- a/common/static/js/src/utility.js +++ b/common/static/js/src/utility.js @@ -41,56 +41,6 @@ window.rewriteStaticLinks = function(content, from, to) { return content.replace(regex, replacer); }; -// Appends a parameter to a path; useful for indicating initial or return signin, for example -window.appendParameter = function(path, key, value) { - // Check if the given path already contains a query string by looking for the ampersand separator - if (path.indexOf("?") > -1) { - var splitPath = path.split("?"); - var parameters = window.parseQueryString(splitPath[1]); - // Check if the provided key already exists in the query string - if (key in parameters) { - // Overwrite the existing key's value with the provided value - parameters[key] = value; - - // Reconstruct the path, including the overwritten key/value pair - var reconstructedPath = splitPath[0] + "?"; - for (var k in parameters) { - reconstructedPath = reconstructedPath + k + "=" + parameters[k] + "&"; - } - // Strip the trailing ampersand - return reconstructedPath.slice(0, -1); - } else { - // Check for a trailing ampersand - if (path[path.length - 1] != "&") { - // Append signin parameter to the existing query string - return path + "&" + key + "=" + value; - } else { - // Append signin parameter to the existing query string, excluding the ampersand - return path + key + "=" + value; - } - } - } else { - // Append new query string containing the provided parameter - return path + "?" + key + "=" + value; - } -}; - -// Convert a query string to a key/value object -window.parseQueryString = function(queryString) { - var parameters = {}, queries, pair, i, l; - - // Split the query string into key/value pairs - queries = queryString.split("&"); - - // Break the array of strings into an object - for (i = 0, l = queries.length; i < l; i++) { - pair = queries[i].split('='); - parameters[pair[0]] = pair[1]; - } - - return parameters -}; - window.identifyUser = function(userID, email, username) { analytics.identify(userID, { email: email, diff --git a/lms/templates/login.html b/lms/templates/login.html index 3b73266407..a4dc5159a4 100644 --- a/lms/templates/login.html +++ b/lms/templates/login.html @@ -61,16 +61,16 @@ next = decodeURIComponent(next); } if (next && !isExternal(next)) { - location.href=appendParameter(next, "signin", "return"); + location.href=next; } else if(json.redirect_url){ - location.href=appendParameter(json.redirect_url, "signin", "return"); + location.href=json.redirect_url; } else { - location.href=appendParameter("${reverse('dashboard')}", "signin", "return"); + location.href="${reverse('dashboard')}"; } } else if(json.hasOwnProperty('redirect')) { var u=decodeURI(window.location.search); if (!isExternal(json.redirect)) { // a paranoid check. Our server is the one providing json.redirect - location.href=appendParameter(json.redirect+u, "signin", "return"); + location.href=json.redirect+u; } // else we just remain on this page, which is fine since this particular path implies a login failure // that has been generated via packet tampering (json.redirect has been messed with). } else { @@ -105,7 +105,7 @@ function thirdPartySignin(event, url) { event.preventDefault(); - window.location.href = appendParameter(url, "signin", "return"); + window.location.href = url; } (function post_form_if_pipeline_running(pipeline_running) { diff --git a/lms/templates/register.html b/lms/templates/register.html index 365fb17ff5..d58e12d55f 100644 --- a/lms/templates/register.html +++ b/lms/templates/register.html @@ -55,7 +55,7 @@ $('#register-form').on('ajax:success', function(event, json, xhr) { var url = json.redirect_url || "${reverse('dashboard')}"; - location.href = appendParameter(url, "signin", "initial"); + location.href = url; }); $('#register-form').on('ajax:error', function(event, jqXHR, textStatus) { diff --git a/lms/templates/widgets/segment-io.html b/lms/templates/widgets/segment-io.html index 818fd74cc0..69faa673be 100644 --- a/lms/templates/widgets/segment-io.html +++ b/lms/templates/widgets/segment-io.html @@ -1,7 +1,5 @@ % if settings.FEATURES.get('SEGMENT_IO_LMS'): -<%! from django.core.urlresolvers import reverse %> -