mainui.js   mainui.js 
/* jshint expr: true */ /* jshint expr: true */
define(["jquery", "settings", "globalize", "api/remotecontrol", "api/action define(["jquery", "settings", "globalize", "api/remotecontrol", "api/action
s", "api/properties", "./time", "./actions", "./viewoptions", "./scripts", s",
"./viewcontrol", "./location", "./search", "jquery-ui"], function($, settin "api/properties", "./time", "./joystickqueue", "./actions", "./viewo
gs, globalize, rc, actionApi, propApi, timeui) { ptions",
"./scripts",
"./viewcontrol", "./location", "./search", "jquery-ui"
], function($, settings, globalize, rc, actionApi, propApi, timeui,
JoystickQueue) {
"use strict"; "use strict";
var animationSupported = (window.requestAnimationFrame !== undefined ); var animationSupported = (window.requestAnimationFrame !== undefined );
//controls //controls
var $noresponse; var $noresponse;
var $noresponsetime; var $noresponsetime;
var sel_infostring;
var activeTab = 0; var activeTab = 0;
//keep preloaded images to prevent browser from releasing them //keep preloaded images to prevent browser from releasing them
var preloadedImgs = []; var preloadedImgs = [];
if (!animationSupported) { if (!animationSupported) {
console.log("animation frame not supported"); console.log("animation frame not supported");
} else { } else {
console.log("animation frame supported"); console.log("animation frame supported");
} }
skipping to change at line 43 skipping to change at line 46
if (settings.useAnimationFrame && animationSupported) { if (settings.useAnimationFrame && animationSupported) {
window.requestAnimationFrame(animate); window.requestAnimationFrame(animate);
} else { } else {
setTimeout(animate, settings.animationDelay); setTimeout(animate, settings.animationDelay);
} }
} }
// create // create
function createAutomaticGUIElements() { function createAutomaticGUIElements() {
console.log("setting up GUI elements");
//automatically setup spinners //automatically setup spinners
$("input.spinner").each(function() { $("input.spinner").each(function() {
var self = $(this), var self = $(this),
min = self.data("min"), min = self.data("min"),
max = self.data("max"), max = self.data("max"),
step = self.data("step"), step = self.data("step"),
format = self.data("numberformat"); format = self.data("numberformat");
self.spinner({ self.spinner({
min: min, min: min,
max: max, max: max,
skipping to change at line 76 skipping to change at line 81
max: max, max: max,
step: step step: step
}); });
}); });
//create jquery ui buttons + selectmenu //create jquery ui buttons + selectmenu
$("button.jquerybutton").button(); $("button.jquerybutton").button();
$("select.selectmenu").selectmenu({ $("select.selectmenu").selectmenu({
width: 'auto' width: 'auto'
}); });
//setup joysticks
$(".joystickcontainer > .joystick").each(function() {
var joy = $(this);
new JoystickQueue(joy, joy.data("joyurl"), joy.data(
"joymax"));
});
} }
function connectStelProperties() { function connectStelProperties() {
//hook up automatic stelproperty spinners //hook up automatic stelproperty spinners
$("input.spinner.stelproperty").each(function() { $("input.spinner.stelproperty").each(function() {
var self = $(this); var self = $(this);
var prop = self.attr("name"); var prop = self.attr("name");
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
} }
$(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) { $(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) {
if (!self.data("updatePaused")) if (!self.data("updatePaused"))
self.spinner("value", prop.value); self.spinner("value", prop.value);
}); });
self.spinner("value", propApi.getStelProp(prop)); self.spinner("value", propApi.getStelProp(prop));
self.on("focus", function(evt) { self.on("focus", function(evt) {
self.data("updatePaused", true); self.data("updatePaused", true);
skipping to change at line 113 skipping to change at line 128
self.on("spinuserinput", function(evt, ui) { self.on("spinuserinput", function(evt, ui) {
propApi.setStelPropQueued(prop, ui.value); propApi.setStelPropQueued(prop, ui.value);
}); });
}); });
//hook up stelproperty checkboxes //hook up stelproperty checkboxes
$("input[type='checkbox'].stelproperty").each(function() { $("input[type='checkbox'].stelproperty").each(function() {
var self = $(this); var self = $(this);
var prop = self.attr("name"); var prop = self.attr("name");
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
} }
$(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) { $(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) {
self[0].checked = prop.value; self[0].checked = prop.value;
}); });
self[0].checked = propApi.getStelProp(prop); self[0].checked = propApi.getStelProp(prop);
self.click(function() { self.click(function() {
propApi.setStelProp(prop, this.checked); propApi.setStelProp(prop, this.checked);
}); });
}); });
$("div.slider.stelproperty").each(function() { $("div.slider.stelproperty").each(function() {
var self = $(this); var self = $(this);
var prop = self.data("prop"); var prop = self.data("prop");
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
} }
$(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) { $(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) {
self.slider("value", prop.value); self.slider("value", prop.value);
}); });
self.slider("value", propApi.getStelProp(prop)); self.slider("value", propApi.getStelProp(prop));
self.on("slide", function(evt, ui) { self.on("slide", function(evt, ui) {
propApi.setStelPropQueued(prop, ui.value); propApi.setStelPropQueued(prop, ui.value);
}); });
}); });
//hook up span stelproperty display //hook up span stelproperty display
$("span.stelproperty").each(function() { $("span.stelproperty").each(function() {
var elem = this; var elem = this;
var self = $(this); var self = $(this);
var prop = self.data("prop"); var prop = self.data("prop");
var numberformat = self.data("numberformat"); var numberformat = self.data("numberformat");
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
} }
$(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) { $(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) {
var val = prop.value; var val = prop.value;
if(numberformat) if (numberformat)
val = globalize.format(val,numberfor val = globalize.format(val, numberfo
mat); rmat);
elem.textContent = val; elem.textContent = val;
}); });
var val = propApi.getStelProp(prop); var val = propApi.getStelProp(prop);
if(numberformat) if (numberformat)
val = globalize.format(val,numberfor val = globalize.format(val, numberformat);
mat);
elem.textContent = val; elem.textContent = val;
}); });
$("select.stelproperty").each(function() { $("select.stelproperty").each(function() {
var self = $(this); var self = $(this);
var prop = self.attr("name"); var prop = self.attr("name");
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
} }
$(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) { $(propApi).on("stelPropertyChanged:" + prop, functio n(evt, prop) {
self.val(prop.value); self.val(prop.value);
self.data("currentSelection", prop.value); self.data("currentSelection", prop.value);
//if this is a jquery UI selectmenu, we have to refresh //if this is a jquery UI selectmenu, we have to refresh
if (self.hasClass('selectmenu')) { if (self.hasClass('selectmenu')) {
self.selectmenu("refresh"); self.selectmenu("refresh");
} }
}); });
var curVal = propApi.getStelProp(prop); var curVal = propApi.getStelProp(prop);
skipping to change at line 203 skipping to change at line 234
}); });
}); });
//stelproperty direct value change //stelproperty direct value change
$("button.stelproperty, input[type='button'].stelproperty"). click(function() { $("button.stelproperty, input[type='button'].stelproperty"). click(function() {
var self = $(this); var self = $(this);
var prop = this.name; var prop = this.name;
var val = this.value; var val = this.value;
if (!prop) { if (!prop) {
console.error('Error: no StelProperty name d console.error(
efined on an "stelproperty" element, element follows...'); 'Error: no StelProperty name defined
on an "stelproperty" element, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no StelProperty name defined o alert(
n an "stelproperty" element, see log for details'); 'Error: no StelProperty name defined
on an "stelproperty" element, see log for details'
);
return; return;
} }
if (!val) { if (!val) {
console.error('Error: no value defined for a console.error(
n "stelproperty" button, element follows...'); 'Error: no value defined for an "ste
lproperty" button, element follows...'
);
console.dir(this); console.dir(this);
alert('Error: no value defined for an "stelp alert(
roperty" button,, see log for details'); 'Error: no value defined for an "ste
lproperty" button,, see log for details'
);
return; return;
} }
propApi.setStelProp(prop, val); propApi.setStelProp(prop, val);
}); });
} }
//DOM-ready //DOM-ready
$(function() { $(function() {
//preload the error images, otherwise they may be loaded whe n the connection is lost, which of course wont work //preload the error images, otherwise they may be loaded whe n the connection is lost, which of course wont work
skipping to change at line 288 skipping to change at line 327
active: oldTabId, active: oldTabId,
activate: function(evt, ui) { activate: function(evt, ui) {
var idx = ui.newTab.index(); var idx = ui.newTab.index();
activeTab = idx; activeTab = idx;
if (webStorageSupported) { if (webStorageSupported) {
sessionStorage.setItem(tabDataKey, i dx); sessionStorage.setItem(tabDataKey, i dx);
} }
} }
}); });
sel_infostring = document.getElementById("sel_infostring");
var $loading = $("#loadindicator").hide(), var $loading = $("#loadindicator").hide(),
timer; timer;
$(document).ajaxStart(function() { $(document).ajaxStart(function() {
timer && clearTimeout(timer); timer && clearTimeout(timer);
timer = setTimeout(function() { timer = setTimeout(function() {
$loading.show(); $loading.show();
}, settings.spinnerDelay); }, settings.spinnerDelay);
}); });
$(document).ajaxStop(function() { $(document).ajaxStop(function() {
clearTimeout(timer); clearTimeout(timer);
$loading.hide(); $loading.hide();
}); });
//start animation & update loop //start animation & update loop
animate(); animate();
rc.startUpdateLoop(); rc.startUpdateLoop();
$("#loadoverlay").fadeOut(); $("#loadoverlay").fadeOut();
$(rc).trigger("uiReady"); //signal other components that the main UI init is done (some may need the jQueryUI stuff set up)
}); });
//new server data //new server data
$(rc).on('serverDataReceived', function(event, data) { $(rc).on('serverDataReceived', function(event, data) {
if (data.selectioninfo) {
sel_infostring.innerHTML = data.selectioninfo;
sel_infostring.className = "";
} else {
sel_infostring.innerHTML = rc.tr("No current selecti
on");
sel_infostring.className = "bold";
}
//this will get reset after the event is processed //this will get reset after the event is processed
//this means the connection WAS lost before, but now is not anymore //this means the connection WAS lost before, but now is not anymore
if (rc.isConnectionLost()) { if (rc.isConnectionLost()) {
$noresponse.dialog("close"); $noresponse.dialog("close");
} }
}); });
$(rc).on("serverDataError", function(evt) { $(rc).on("serverDataError", function(evt) {
if (!rc.isConnectionLost()) { if (!rc.isConnectionLost()) {
$noresponse.dialog("open"); $noresponse.dialog("open");
 End of changes. 23 change blocks. 
51 lines changed or deleted 79 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/