- Posts: 6
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
$(document).ready(function() { if($('.surveys-list').length > 0) { // Build an array of survey titles var titles = []; $('a.surveytitle').each(function(i) { titles.push($(this).text()); }); // Sort the titles array titles.sort(); // Insert the survey links in sorted order $(titles).each(function(i) { var thisText = this; $('a.surveytitle').filter(function() { return $(this).text() == thisText; }).closest('li').appendTo($('.surveys-list')); }); } });
$(document).ready(function(){ if($('div.survey-list').length > 0) { // Create an array of survey titles var surveyTitles = []; $('div.survey-list a.surveytitle').each(function(i) { $(this).attr('data-sid', $(this).attr('href').split('index.php/')[1].split('?')[0]); $(this).attr('data-name', $.trim($(this).text())+' - '+$(this).attr('href').split('index.php/')[1].split('?')[0]); surveyTitles.push($(this).attr('data-name')); }); // Sort the titles surveyTitles.sort(); // Insert the survey links in sorted order $(surveyTitles).each(function(i, val) { var thisLink = $('div.survey-list a.surveytitle').filter(function(e) { return $(this).attr('data-name') == val; }); $('div.survey-list > .container > .row').append($(thisLink).parent()); }); // Handle the public stats links $('div.survey-list a.view-stats').each(function(i) { $(this).attr('data-sid', $(this).attr('href').split('statistics_user/')[1].split('?')[0]); $(this).parent().insertAfter($('div.survey-list a.surveytitle[data-sid="'+$(this).attr('data-sid')+'"]').parent()); }); // Fix up the dividers $('div.survey-list > .container > .row > .col-xs-12, div.survey-list > .container > .row > .col-xs-2').removeClass('vertical-divider right'); var dividerClass = 1; $('div.survey-list > .container > .row > .col-xs-12, div.survey-list > .container > .row > .col-xs-2').each(function(i) { dividerClass++; if(dividerClass % 2 == 0) { $(this).addClass('vertical-divider right'); } }); } });