Merge pull request #57 from cloudflare/reset-fix

Fix settings reset button
This commit is contained in:
Łukasz Mierzwa
2017-04-18 09:36:49 -07:00
committed by GitHub
3 changed files with 18 additions and 5 deletions

View File

@@ -74,6 +74,8 @@ var Config = (function() {
reset = function() {
// this is not part of options map
Cookies.remove("defaultFilter.v2");
$.each(options, function(name, option) {
Cookies.remove(option.Cookie);
});
@@ -108,6 +110,7 @@ var Config = (function() {
// reset settings button action
$(params.ResetSelector).on('click', function(elem) {
Config.Reset();
QueryString.Remove('q');
location.reload();
});

View File

@@ -9,8 +9,7 @@ var QueryString = (function() {
q = q.split('&');
for (var i = 0; i < q.length; i++) {
hash = q[i].split('=');
vars.push(hash[1]);
vars[hash[0]] = hash[1];
vars[hash[0]] = hash.slice(1).join('=');
}
}
return vars;
@@ -39,9 +38,20 @@ var QueryString = (function() {
}
remove = function(key) {
var baseUrl = [location.protocol, '//', location.host, location.pathname].join(''),
q = QueryString.Parse();
if (q[key] != undefined) {
delete q[key];
window.history.replaceState({}, "", baseUrl + "?" + $.param(q));
}
}
return {
Parse: parse,
Set: update
Set: update,
Remove: remove
}
}());

File diff suppressed because one or more lines are too long