Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
823be968
Commit
823be968
authored
Sep 05, 2014
by
Renzo Lucioni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused analytics JS left over by 3rd party auth changes
parent
58e6dcf7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
6 additions
and
85 deletions
+6
-85
common/static/js/spec/utility_spec.js
+0
-23
common/static/js/src/utility.js
+0
-50
lms/templates/login.html
+5
-5
lms/templates/register.html
+1
-1
lms/templates/widgets/segment-io.html
+0
-6
No files found.
common/static/js/spec/utility_spec.js
View file @
823be968
...
...
@@ -16,26 +16,3 @@ describe('utility.rewriteStaticLinks', function () {
).
toBe
(
'<img src="http://www.mysite.org/static/foo.x"/>'
)
});
});
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'
}));
});
});
common/static/js/src/utility.js
View file @
823be968
...
...
@@ -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
,
...
...
lms/templates/login.html
View file @
823be968
...
...
@@ -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
)
{
...
...
lms/templates/register.html
View file @
823be968
...
...
@@ -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
)
{
...
...
lms/templates/widgets/segment-io.html
View file @
823be968
% if settings.FEATURES.get('SEGMENT_IO_LMS'):
<!-- begin Segment.io -->
<
%!
from
django
.
core
.
urlresolvers
import
reverse
%
>
<script
type=
"text/javascript"
>
// Asynchronously load Segment.io's analytics.js library
window
.
analytics
||
(
window
.
analytics
=
[]),
window
.
analytics
.
methods
=
[
"identify"
,
"track"
,
"trackLink"
,
"trackForm"
,
"trackClick"
,
"trackSubmit"
,
"page"
,
"pageview"
,
"ab"
,
"alias"
,
"ready"
,
"group"
,
"on"
,
"once"
,
"off"
],
window
.
analytics
.
factory
=
function
(
t
){
return
function
(){
var
a
=
Array
.
prototype
.
slice
.
call
(
arguments
);
return
a
.
unshift
(
t
),
window
.
analytics
.
push
(
a
),
window
.
analytics
}};
for
(
var
i
=
0
;
i
<
window
.
analytics
.
methods
.
length
;
i
++
){
var
method
=
window
.
analytics
.
methods
[
i
];
window
.
analytics
[
method
]
=
window
.
analytics
.
factory
(
method
)}
window
.
analytics
.
load
=
function
(
t
){
var
a
=
document
.
createElement
(
"script"
);
a
.
type
=
"text/javascript"
,
a
.
async
=!
0
,
a
.
src
=
(
"https:"
===
document
.
location
.
protocol
?
"https://"
:
"http://"
)
+
"d2dq2ahtl5zl1z.cloudfront.net/analytics.js/v1/"
+
t
+
"/analytics.min.js"
;
var
n
=
document
.
getElementsByTagName
(
"script"
)[
0
];
n
.
parentNode
.
insertBefore
(
a
,
n
)},
window
.
analytics
.
SNIPPET_VERSION
=
"2.0.8"
,
...
...
@@ -9,11 +7,7 @@
analytics
.
page
();
%
if
user
.
is_authenticated
():
// Access the query string, stripping the leading "?"
var
queryString
=
window
.
location
.
search
.
substring
(
1
);
window
.
identifyUser
(
"${user.id}"
,
"${user.email}"
,
"${user.username}"
);
%
endif
// Get current page URL
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment