Commit 93eebcdd authored by fred's avatar fred

make it possible to set initially enabled toggles with a ?q parameter

parent 7eb23040
var urlParams;
(window.onpopstate = function () {
var match,
pl = /\+/g, // Regex for replacing addition symbol with a space
search = /([^&=]+)=?([^&]*)/g,
decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
query = window.location.search.substring(1);
urlParams = {};
while (match = search.exec(query))
urlParams[decode(match[1])] = decode(match[2]);
})();
$(function() {
doLog = function(aTextToLog, type){
......@@ -335,6 +348,17 @@ $(function() {
$('[data-toggle].icon-check-empty').each(function(){
$(this).trigger('uncheck');
});
initial_enabled_toggles = {};
if (typeof(urlParams.q) == 'string') {
urlParams.q.split('|').forEach(function(a) { initial_enabled_toggles[a] = 1; })
}
$('[data-toggle]').each(function() {
if ($(this).data('toggle').substring(1) in initial_enabled_toggles) {
$(this).trigger('click');
}
});
if ($('input#id_q').val() == '') {
$('input#id_q').focus();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment