search.js   search.js 
define(["jquery", "api/search", "./combobox"], function($, searchApi) { define(["jquery", "api/remotecontrol", "api/search", "./combobox"], functio n($, rc, searchApi) {
"use strict"; "use strict";
//Private variables //Private variables
var $srch_input; var $srch_input;
var $srch_results; var $srch_results;
var $srch_button; var $srch_button;
var $srch_simbad; var $srch_simbad;
var $srch_tabs; var $srch_tabs;
var $srch_list_objecttype; var $srch_list_objecttype;
var $srch_list_objectlist; var $srch_list_objectlist;
var $srch_list_english; var $srch_list_english;
var $select_SelectionMode;
var $select_clearButton;
var sel_infostring;
var $selectedElem; var $selectedElem;
var objectTypes; var objectTypes;
function fillObjectTypes(data) { function fillObjectTypes(data) {
objectTypes = data; objectTypes = data;
reloadObjectTypes(); reloadObjectTypes();
} }
skipping to change at line 72 skipping to change at line 75
objectTypes.forEach(function(element) { objectTypes.forEach(function(element) {
var op = document.createElement("option"); var op = document.createElement("option");
op.innerHTML = useEnglish ? element.name : element.n ame_i18n; op.innerHTML = useEnglish ? element.name : element.n ame_i18n;
op.value = element.key; op.value = element.key;
$srch_list_objecttype[0].appendChild(op); $srch_list_objecttype[0].appendChild(op);
}); });
parent.prepend($srch_list_objecttype); parent.prepend($srch_list_objecttype);
} }
function selectObjectByName(name) {
searchApi.selectObjectByName(name,
$select_SelectionMode.val());
}
function handleObjectListResults(data) { function handleObjectListResults(data) {
var parent = $srch_list_objectlist.parent(); var parent = $srch_list_objectlist.parent();
$srch_list_objectlist.detach(); $srch_list_objectlist.detach();
data.forEach(function(elem) { data.forEach(function(elem) {
var op = document.createElement("option"); var op = document.createElement("option");
op.innerHTML = elem; op.innerHTML = elem;
$srch_list_objectlist[0].appendChild(op); $srch_list_objectlist[0].appendChild(op);
}); });
skipping to change at line 121 skipping to change at line 129
function submitObjectSelection() { function submitObjectSelection() {
var str = $selectedElem.data("value"); var str = $selectedElem.data("value");
//check if the selection is a simbad result //check if the selection is a simbad result
var pos = $selectedElem.data("viewpos"); var pos = $selectedElem.data("viewpos");
if (pos) { if (pos) {
searchApi.focusPosition(pos); searchApi.focusPosition(pos);
} else { } else {
//post by name //post by name
searchApi.selectObjectByName($selectedElem.data("val ue")); selectObjectByName(str);
} }
$srch_input[0].value = ""; $srch_input[0].value = "";
startSearch(""); startSearch("");
} }
function clearSearchResults() { function clearSearchResults() {
$srch_results.empty(); $srch_results.empty();
$srch_button.button("disable"); $srch_button.button("disable");
$selectedElem = undefined; $selectedElem = undefined;
} }
skipping to change at line 196 skipping to change at line 204
} }
function initControls() { function initControls() {
$srch_input = $("#srch_input"); $srch_input = $("#srch_input");
$srch_results = $("#srch_results"); $srch_results = $("#srch_results");
$srch_simbad = $("#srch_simbad"); $srch_simbad = $("#srch_simbad");
$srch_tabs = $("#srch_tabs"); $srch_tabs = $("#srch_tabs");
$srch_list_objecttype = $("#srch_list_objecttype"); $srch_list_objecttype = $("#srch_list_objecttype");
$srch_list_objectlist = $("#srch_list_objectlist"); $srch_list_objectlist = $("#srch_list_objectlist");
$srch_list_english = $("#srch_list_english"); $srch_list_english = $("#srch_list_english");
$select_SelectionMode = $("#select_SelectionMode");
$select_clearButton = $("#select_clearButton");
sel_infostring = document.getElementById("sel_infostring");
$srch_list_english.change(function(evt) { $srch_list_english.change(function(evt) {
reloadObjectTypes(); reloadObjectTypes();
$srch_list_objectlist.empty(); $srch_list_objectlist.empty();
}); });
$srch_list_objectlist.dblclick(function(evt) { $srch_list_objectlist.dblclick(function(evt) {
var e = $srch_list_objectlist[0]; var e = $srch_list_objectlist[0];
if (e.selectedIndex >= 0) { if (e.selectedIndex >= 0) {
var loc = e.options[e.selectedIndex].text; var loc = e.options[e.selectedIndex].text;
searchApi.selectObjectByName(loc); selectObjectByName(loc);
} }
}); });
$srch_tabs.tabs({ $srch_tabs.tabs({
heightStyle: "content" heightStyle: "content"
}); });
$srch_list_objecttype.combobox({ $srch_list_objecttype.combobox({
select: function(evt, data) { select: function(evt, data) {
//empty the list before searching //empty the list before searching
$srch_list_objectlist.empty(); $srch_list_objectlist.empty();
searchApi.loadObjectList(data.item.value, $s searchApi.loadObjectList(data.item.value, $s
rch_list_english[0].checked, handleObjectListResults); rch_list_english[0].checked,
handleObjectListResults);
} }
}); });
$srch_input.on("input", function() { $srch_input.on("input", function() {
startSearch(this.value); startSearch(this.value);
}).keydown(function(e) { }).keydown(function(e) {
if (e.which == 9) { if (e.which == 9) {
//use tab to switch to next search result //use tab to switch to next search result
selectNextResult(); selectNextResult();
e.preventDefault(); e.preventDefault();
skipping to change at line 255 skipping to change at line 267
primary: "ui-icon-search" primary: "ui-icon-search"
} }
}).click(function(e) { }).click(function(e) {
submitObjectSelection(); submitObjectSelection();
e.preventDefault(); e.preventDefault();
}); });
searchApi.loadObjectTypes(fillObjectTypes); searchApi.loadObjectTypes(fillObjectTypes);
//setup quick select buttons //setup quick select buttons
$("#quickselect").on("click", "button",function(evt){ $("#quickselect").on("click", "button", function(evt) {
console.log("selecting " + evt.target.value);
selectObjectByName(evt.target.value);
});
$("#selection button").click(function(evt) {
console.log("selecting " + evt.target.value); console.log("selecting " + evt.target.value);
searchApi.selectObjectByName(evt.target.value); selectObjectByName(evt.target.value);
}); });
} }
$(rc).on("serverDataReceived", function(evt, data) {
if (data.selectioninfo) {
sel_infostring.innerHTML = data.selectioninfo;
sel_infostring.className = "";
$select_clearButton.show();
} else {
sel_infostring.innerHTML = rc.tr("No current selecti
on");
sel_infostring.className = "bold";
$select_clearButton.hide();
}
});
$(searchApi).on("simbadStateChanged", function(evt, state) { $(searchApi).on("simbadStateChanged", function(evt, state) {
$srch_simbad.text(state); $srch_simbad.text(state);
}); });
$(initControls); $(initControls);
}); });
 End of changes. 10 change blocks. 
7 lines changed or deleted 37 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/