//helpers methods to disable, enable, and uncheck radio buttons and checkboxes (function( $ ){ //disable an element $.fn.disable = function() { return this.attr('disabled', 'disabled'); }; })( jQuery ); (function( $ ){ //enable an element $.fn.enable = function() { return this.removeAttr('disabled'); }; })( jQuery ); (function( $ ){ //uncheck an element $.fn.uncheck = function() { return this.removeAttr('checked'); }; })( jQuery ); (function( $ ){ //check an element $.fn.check = function() { return this.attr('checked', 'checked'); }; })( jQuery ); (function( $ ){ //(pre-)check the only active database checkbox $.onedb = function(selector) { active_dbs = $(".databases input[type=checkbox]").not(":disabled") if (active_dbs.length == 1){ active_dbs.check() } return active_dbs; }; })( jQuery ); (function( $ ){ //highlight an element $.fn.highlight = function() { return this.addClass('focussed'); }; })( jQuery ); (function( $ ){ //unhighlight an element $.fn.unhighlight = function() { return this.removeClass('focussed'); }; })( jQuery ); (function ($) { $.fn.poll = function () { var that, val, tmp; that = this; (function ping () { tmp = that.val(); if (tmp != val){ val = tmp; that.change(); } setTimeout(ping, 100); }()); return this; }; }(jQuery)); /* SS - SequenceServer's JavaScript module Define a global SS (acronym for SequenceServer) object containing the following methods: main(): Initializes SequenceServer's various modules. */ //define global SS object var SS; if (!SS) { SS = {}; } //SS module (function () { SS.decorate = function (name) { return name.match(/(.?)(blast)(.?)/).slice(1).map(function (token, _) { if (token) { if (token !== 'blast'){ return '' + token + ''; } else { return token; } } }).join(''); } /* ask each module to initialize itself */ SS.main = function () { SS.blast.init(); } }()); //end SS module $(document).ready(function(){ // poll the sequence textbox for a change in user input $('#sequence').poll(); // start SequenceServer's event loop SS.main(); var notification_timeout; $('#sequence').on('sequence_type_changed', function (event, type) { clearTimeout(notification_timeout); $(this).parent('.control-group').removeClass('error'); $('.notifications .active').hide().removeClass('active'); if (type) { $('#' + type + '-sequence-notification').show('drop', {direction: 'up'}).addClass('active'); notification_timeout = setTimeout(function () { $('.notifications .active').hide('drop', {direction: 'up'}).removeClass('active'); }, 5000); if (type === 'mixed') { $(this).parent('.control-group').addClass('error'); } } }); $('body').click(function () { $('.notifications .active').hide('drop', {direction: 'up'}).removeClass('active'); }); $('.databases').on('database_type_changed', function (event, type) { switch (type) { case 'protein': $('.databases.nucleotide input:checkbox').uncheck().disable(); break; case 'nucleotide': $('.databases.protein input:checkbox').uncheck().disable(); break; default: $('.databases input:checkbox').enable(); break; } }); $('form').on('blast_method_changed', function (event, methods){ // reset $('#methods .dropdown-menu').html(''); $('#method').disable().val('').html('blast'); $('#methods').removeClass('btn-group').children('.dropdown-toggle').hide(); if (methods) { var method = methods.shift(); $('#method').enable().val(method).html(SS.decorate(method)); if (methods.length >=1) { $('#methods').addClass('btn-group'). children('.dropdown-toggle').show(); var methods_list = $.map(methods, function (method, _) { return "