treconomics_project/static/javascripts/ajax_search.js
/*
Checks data supplied as part of the URL hash and performs a search if it is acceptable.
*/
Checks data supplied as part of the URL hash and performs a search if it is acceptable.
Checks data supplied as part of the URL hash and performs a search if it is acceptable .
function doHashSearch() {
    var page_interface = $('#interface_type');
    var query = getHashValue('query');
    var page = getHashValue('page');
    if (query) {
        if (!page || isNaN(page)) {
            page = 1;
        }
        if (/\S/.test(query)) {  
            var queryField = $('#query');
            if (parseInt(page_interface.val()) != 1) {
                query = query.replace(/\+/g, ' ');
                queryField.val(query);
                var formSerialized = $('form').serialize();
                formSerialized += '&page=' + page;
                processRequest(formSerialized, true);
            }
            else {
                $.ajax({
                    url: APP_ROOT + 'searcha_querystring/',
                    success: function(data) {
                        interface1Querystring = data['querystring'];
                        interface1Querystring += '&page=' + page;
                        interface1Querystring += '&noDelay=true';
                        interface1Querystring += '&csrfmiddlewaretoken=' + $('input[name=csrfmiddlewaretoken]').val();
                        processRequest(interface1Querystring, true);
                    }
                });
            }
        }
    }
}
function doHashSearch ( ) { var page_interface = $ ( '#interface_type' ) ; var query = getHashValue ( 'query' ) ; var page = getHashValue ( 'page' ) ; if ( query ) { if ( ! page || isNaN ( page ) ) { page = 1 ; } if ( / \S / . test ( query ) ) { var queryField = $ ( '#query' ) ; if ( parseInt ( page_interface . val ( ) ) != 1 ) { query = query . replace ( / \+ / g , ' ' ) ; queryField . val ( query ) ; var formSerialized = $ ( 'form' ) . serialize ( ) ; formSerialized += '&page=' + page ; processRequest ( formSerialized , true ) ; } else { $ . ajax ( { url : APP_ROOT + 'searcha_querystring/' , success : function ( data ) { interface1Querystring = data [ 'querystring' ] ; interface1Querystring += '&page=' + page ; interface1Querystring += '&noDelay=true' ; interface1Querystring += '&csrfmiddlewaretoken=' + $ ( 'input[name=csrfmiddlewaretoken]' ) . val ( ) ; processRequest ( interface1Querystring , true ) ; } } ) ; } } } }
Checks data supplied as part of the URL hash and performs a search if it is acceptable.
Checks data supplied as part of the URL hash and performs a search if it is acceptable .
// Check if string contains at least one non-whitespace character // With an interface of 1, we have to pull the previous querystring from the server!