webinator-azure.continuous.ie Open in urlscan Pro
13.69.136.90  Public Scan

URL: https://webinator-azure.continuous.ie/webinator/common/js/search.js?scriptVer=18.0.2
Submission: On October 02 via manual from US — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

"use strict";
// Javascript for Thunderstone search
// thunderstone_file_sha1: e594a9b4c824cd07541c23076dd0513d458f5f45

// used when clicking an [X] to unselect a GroupBy
function clearField(id)
{
    var e = document.getElementById(id);
    e.disabled=true;
    jQuery(e).closest("form").submit();
    return false;
}

function tsInitAutocomplete() {
    // bail if jQuery and jQueryUI autocomplete aren't available
    if(typeof(jQuery) !== "function" || typeof(jQuery("#query.queryAutocomplete").autocomplete) !== "function") {
        console.log("Error: JQuery not found and/or autocomplete not present");
        return;
    }
    jQuery(function($) {
        // add autocomplete
        var foldedTerm;
        $("#query.queryAutocomplete").autocomplete({
            source: function(request, response) {
                var action = $("#query").closest("form").attr("action");
                var url = action.substr(0, action.lastIndexOf("/")) + "/autocomplete.json";
                $.ajax({
                    dataType: "jsonp",
                    url: url,
                    data: {
                        foldTerm: "true",
                        pr: $("input[name='pr']").val(),
                        term: request.term
                    },
                    success: function(data) {
                        foldedTerm = data.term;
                        response(data.completions);
                    }
                });
            },
            minLength: 2,
            open: function(e, ui) {
                // drill into the menu and wrap the term and the completions
                // in spans for styling.  Hopefully JQueryUI will start doing this
                // automatically in the future.
                var acData = $(this).data("uiAutocomplete");
                if(acData) {
                    acData.menu.element.find("a,div").each(function() {
                        var a = $(this);
                        var completion = a.text();
                        a.html("");
                        var pos = completion.indexOf(foldedTerm);
                        if(pos === -1) {
                            // couldn't find the term in the suggestion? no hl
                            a.append(document.createTextNode(completion));
                        } else {
                            var node;
                            // add any new suggestion text from before the term
                            if(pos !== 0) {
                                node = $("<span class='ui-autocomplete-completion'/>");
                                node.append(document.createTextNode(completion.substr(0, pos)));
                                a.append(node)
                            }
                            // add the term itself
                            node = $("<span class='ui-autocomplete-term'/>");
                            node.append(document.createTextNode(foldedTerm));
                            a.append(node)
                            // add any new suggestion text from after the term
                            if(pos + foldedTerm.length < completion.length) {
                                node = $("<span class='ui-autocomplete-completion'/>");
                                node.append(document.createTextNode(completion.substr(pos + foldedTerm.length)));
                                a.append(node);
                            }
                        }
                    });
                }
            },

            select: function(event, ui) {
                $("#query").val(ui.item.value)
                    .closest("form").submit();
            }
        });
    });
}

tsInitAutocomplete();