language
stringclasses 6
values | original_string
stringlengths 25
887k
| text
stringlengths 25
887k
|
---|---|---|
JavaScript | function LASGetGridResponse_getLo(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
value = this.getAxis(axis_lc).v[0];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
if(step<0)
value = start + (size-1) * step;
else
value = start;
}
}
return value;
} | function LASGetGridResponse_getLo(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
value = this.getAxis(axis_lc).v[0];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
if(step<0)
value = start + (size-1) * step;
else
value = start;
}
}
return value;
} |
JavaScript | function LASGetGridResponse_getHi(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
if(this.getAxis(axis_lc).hi)
value = this.getAxis(axis_lc).hi;
else
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
var index = this.getAxis(axis_lc).v.length - 1;
value = this.getAxis(axis_lc).v[index];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
if(step<0)
value=start;
else
value = start + (size-1) * step;
}
}
return value;
} | function LASGetGridResponse_getHi(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
if(this.getAxis(axis_lc).hi)
value = this.getAxis(axis_lc).hi;
else
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
var index = this.getAxis(axis_lc).v.length - 1;
value = this.getAxis(axis_lc).v[index];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
if(step<0)
value=start;
else
value = start + (size-1) * step;
}
}
return value;
} |
JavaScript | function LASGetGridResponse_getDelta(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.step;
}
return Number(value);
} | function LASGetGridResponse_getDelta(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.step;
}
return Number(value);
} |
JavaScript | function LASGetGridResponse_getMinuteInterval(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = Number(this.getAxis(axis_lc).minuteInterval);
}
return value;
} | function LASGetGridResponse_getMinuteInterval(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = Number(this.getAxis(axis_lc).minuteInterval);
}
return value;
} |
JavaScript | function LASGetGridResponse_getSize(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.size;
} else {
if (this.hasMenu(axis)) {
value = this.getAxis(axis_lc).v.length;
}
}
return Number(value);
} | function LASGetGridResponse_getSize(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.size;
} else {
if (this.hasMenu(axis)) {
value = this.getAxis(axis_lc).v.length;
}
}
return Number(value);
} |
JavaScript | function LASGetGridResponse_getUnits(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).units;
}
return value;
} | function LASGetGridResponse_getUnits(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).units;
}
return value;
} |
JavaScript | function LASGetGridResponse_getID(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).display_type;
}
return value;
} | function LASGetGridResponse_getID(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).display_type;
}
return value;
} |
JavaScript | function LASGetGridResponse_getDisplayType(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasAxis(axis)) {
if (this.getAxis(axis_lc).display_type) {
value = this.getAxis(axis_lc).display_type;
}
}
return value;
} | function LASGetGridResponse_getDisplayType(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasAxis(axis)) {
if (this.getAxis(axis_lc).display_type) {
value = this.getAxis(axis_lc).display_type;
}
}
return value;
} |
JavaScript | function LASGetGridResponse_getRenderFormat(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
switch (axis_lc) {
case 't':
value = "";
if (this.getAxis('t').yearNeeded == 'true') { value += "Y"; }
if (this.getAxis('t').monthNeeded == 'true') { value += "M"; }
if (this.getAxis('t').dayNeeded == 'true') { value += "D"; }
if (this.getAxis('t').hourNeeded == 'true') { value += "T"; }
break;
}
return value;
} | function LASGetGridResponse_getRenderFormat(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
switch (axis_lc) {
case 't':
value = "";
if (this.getAxis('t').yearNeeded == 'true') { value += "Y"; }
if (this.getAxis('t').monthNeeded == 'true') { value += "M"; }
if (this.getAxis('t').dayNeeded == 'true') { value += "D"; }
if (this.getAxis('t').hourNeeded == 'true') { value += "T"; }
break;
}
return value;
} |
JavaScript | function LASGetGridResponse_getMenu(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
var menu = null;
value = new Array;
if (this.getAxis(axis_lc).v && typeof this.getAxis(axis_lc).v == 'object' && !this.getAxis(axis_lc).v.label) {
menu = this.getAxis(axis_lc).v;
for (var i=0; i<menu.length; i++) {
if (axis_lc == 't') {
//TODO: Remove this hack after resolution of trac ticket #147.
var month_name = String(menu[i].content).toLowerCase();
if (month_name == 'jan') { menu[i].content = '15-Jan'; }
if (month_name == 'feb') { menu[i].content = '15-Feb'; }
if (month_name == 'mar') { menu[i].content = '15-Mar'; }
if (month_name == 'apr') { menu[i].content = '15-Apr'; }
if (month_name == 'may') { menu[i].content = '15-May'; }
if (month_name == 'jun') { menu[i].content = '15-Jun'; }
if (month_name == 'jul') { menu[i].content = '15-Jul'; }
if (month_name == 'aug') { menu[i].content = '15-Aug'; }
if (month_name == 'sep') { menu[i].content = '15-Sep'; }
if (month_name == 'oct') { menu[i].content = '15-Oct'; }
if (month_name == 'nov') { menu[i].content = '15-Nov'; }
if (month_name == 'dec') { menu[i].content = '15-Dec'; }
value[i] = new Array(menu[i].label,menu[i].content);
} else {
value[i] = new Array(menu[i],menu[i]);
}
}
} else if (this.getAxis(axis_lc).v)
if(this.getAxis(axis_lc).v.label)
value[0] = new Array(this.getAxis(axis_lc).v.label,this.getAxis(axis_lc).v.content);
else
value[0] = new Array(this.getAxis(axis_lc).v, this.getAxis(axis_lc).v);
return value;
} | function LASGetGridResponse_getMenu(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
var menu = null;
value = new Array;
if (this.getAxis(axis_lc).v && typeof this.getAxis(axis_lc).v == 'object' && !this.getAxis(axis_lc).v.label) {
menu = this.getAxis(axis_lc).v;
for (var i=0; i<menu.length; i++) {
if (axis_lc == 't') {
//TODO: Remove this hack after resolution of trac ticket #147.
var month_name = String(menu[i].content).toLowerCase();
if (month_name == 'jan') { menu[i].content = '15-Jan'; }
if (month_name == 'feb') { menu[i].content = '15-Feb'; }
if (month_name == 'mar') { menu[i].content = '15-Mar'; }
if (month_name == 'apr') { menu[i].content = '15-Apr'; }
if (month_name == 'may') { menu[i].content = '15-May'; }
if (month_name == 'jun') { menu[i].content = '15-Jun'; }
if (month_name == 'jul') { menu[i].content = '15-Jul'; }
if (month_name == 'aug') { menu[i].content = '15-Aug'; }
if (month_name == 'sep') { menu[i].content = '15-Sep'; }
if (month_name == 'oct') { menu[i].content = '15-Oct'; }
if (month_name == 'nov') { menu[i].content = '15-Nov'; }
if (month_name == 'dec') { menu[i].content = '15-Dec'; }
value[i] = new Array(menu[i].label,menu[i].content);
} else {
value[i] = new Array(menu[i],menu[i]);
}
}
} else if (this.getAxis(axis_lc).v)
if(this.getAxis(axis_lc).v.label)
value[0] = new Array(this.getAxis(axis_lc).v.label,this.getAxis(axis_lc).v.content);
else
value[0] = new Array(this.getAxis(axis_lc).v, this.getAxis(axis_lc).v);
return value;
} |
JavaScript | function LatitudeWidget(lo, hi, delta) {
// Public methods
this.render = LatitudeWidget_render;
this.disable = LatitudeWidget_disable;
this.enable = LatitudeWidget_enable;
this.show = LatitudeWidget_show;
this.hide = LatitudeWidget_hide;
this.getSelectedIndex = LatitudeWidget_getSelectedIndex;
this.getValue = LatitudeWidget_getValue;
this.getValues = LatitudeWidget_getValues;
this.setCallback = LatitudeWidget_setCallback;
this.setValue = LatitudeWidget_setValue;
this.setValueByIndex = LatitudeWidget_setValueByIndex;
// Event handlers
this.selectChange = LatitudeWidget_selectChange;
// Initialization
/**
* Lowest value displayed in the Select menu.
*/
this.lo = Number(lo);
/**
* Highest value displayed in the Select menu.
*/
this.hi = Number(hi);
/**
* Spacing beteen Select options (decimal degrees)
*/
this.delta = Number(delta);
/**
* Number of Options in the Select menu.
*/
this.length = 0;
/**
* Select object type ['select-one' | 'select-multiple'] (currently only 'select-one' is supported)
*/
this.type = 'select-one';
/**
* ID string identifying this widget.
*/
this.widgetType = 'LatitudeWidget';
/**
* Specifies whether this widget is currently disabled.
*/
this.disabled = 0;
/**
* Specifies whether this widget is currently visible.
*/
this.visible = 0;
/**
* Callback function attached to the onChange event.
*/
this.callback = null;
} | function LatitudeWidget(lo, hi, delta) {
// Public methods
this.render = LatitudeWidget_render;
this.disable = LatitudeWidget_disable;
this.enable = LatitudeWidget_enable;
this.show = LatitudeWidget_show;
this.hide = LatitudeWidget_hide;
this.getSelectedIndex = LatitudeWidget_getSelectedIndex;
this.getValue = LatitudeWidget_getValue;
this.getValues = LatitudeWidget_getValues;
this.setCallback = LatitudeWidget_setCallback;
this.setValue = LatitudeWidget_setValue;
this.setValueByIndex = LatitudeWidget_setValueByIndex;
// Event handlers
this.selectChange = LatitudeWidget_selectChange;
// Initialization
/**
* Lowest value displayed in the Select menu.
*/
this.lo = Number(lo);
/**
* Highest value displayed in the Select menu.
*/
this.hi = Number(hi);
/**
* Spacing beteen Select options (decimal degrees)
*/
this.delta = Number(delta);
/**
* Number of Options in the Select menu.
*/
this.length = 0;
/**
* Select object type ['select-one' | 'select-multiple'] (currently only 'select-one' is supported)
*/
this.type = 'select-one';
/**
* ID string identifying this widget.
*/
this.widgetType = 'LatitudeWidget';
/**
* Specifies whether this widget is currently disabled.
*/
this.disabled = 0;
/**
* Specifies whether this widget is currently visible.
*/
this.visible = 0;
/**
* Callback function attached to the onChange event.
*/
this.callback = null;
} |
JavaScript | function LatitudeWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
//TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
var length = (this.hi - this.lo) / this.delta;
var value = this.lo - this.delta;
var text = "";
// NOTE: By default the appearance of options in a menu is from
// NOTE: top (first) to bottom (last). For the LatitudeWidget
// NOTE: we add options in reverse order so that low values will
// NOTE: appear at the bottom (South).
for (var i=length-1; i>=0; i--) {
value += this.delta;
if (value < 0) {
text = Math.abs(value).toString() + ' S';
} else {
text = Math.abs(value).toString() + ' N';
}
Select.options[i]=new Option(text, value);
}
Select.selectedIndex = 0;
Select.options[0].selected = true;
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
// Store the pointer to the Select object inside the LatitudeWidget object
this.Select = Select;
this.length = this.Select.length;
} | function LatitudeWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
//TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
var length = (this.hi - this.lo) / this.delta;
var value = this.lo - this.delta;
var text = "";
// NOTE: By default the appearance of options in a menu is from
// NOTE: top (first) to bottom (last). For the LatitudeWidget
// NOTE: we add options in reverse order so that low values will
// NOTE: appear at the bottom (South).
for (var i=length-1; i>=0; i--) {
value += this.delta;
if (value < 0) {
text = Math.abs(value).toString() + ' S';
} else {
text = Math.abs(value).toString() + ' N';
}
Select.options[i]=new Option(text, value);
}
Select.selectedIndex = 0;
Select.options[0].selected = true;
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
// Store the pointer to the Select object inside the LatitudeWidget object
this.Select = Select;
this.length = this.Select.length;
} |
JavaScript | function LatitudeWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} | function LatitudeWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} |
JavaScript | function LatitudeWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} | function LatitudeWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} |
JavaScript | function LatitudeWidget_setValue(lat) {
//TODO: Throw error if lat < -90 || lat > 90
var internal_lat = Number(lat);
var i = 0;
// NOTE: Latitude widget values are ordered from high -> low
while (i <= this.Select.length) {
var option_val = Number(this.Select.options[i].value);
if (internal_lat >= option_val) {
this.Select.selectedIndex = i;
this.Select.options[i].selected = true;
return;
// TODO: include logic to find closest match if lat is in between option_vals
}
i++;
}
} | function LatitudeWidget_setValue(lat) {
//TODO: Throw error if lat < -90 || lat > 90
var internal_lat = Number(lat);
var i = 0;
// NOTE: Latitude widget values are ordered from high -> low
while (i <= this.Select.length) {
var option_val = Number(this.Select.options[i].value);
if (internal_lat >= option_val) {
this.Select.selectedIndex = i;
this.Select.options[i].selected = true;
return;
// TODO: include logic to find closest match if lat is in between option_vals
}
i++;
}
} |
JavaScript | function LatitudeWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('LatitudeWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('LatitudeWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the LatitudeWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} | function LatitudeWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('LatitudeWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('LatitudeWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the LatitudeWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} |
JavaScript | function LASResponse(JSONObject) {
this.response = JSONObject.backend_response.response;
// Add methods to this object
this.getDate = LASResponse_getDate;
this.getID = LASResponse_getID;
this.getImageURL = LASResponse_getImageURL;
this.getDebugURL = LASResponse_getDebugURL;
this.getMapScaleURL = LASResponse_getMapScaleURL;
this.getRSSURL = LASResponse_getRSSURL;
this.isError = LASResponse_isError;
this.getResult = LASResponse_getResult;
// Check for incomplete LASResponse. Sometimes it looks like:
//
// {"backend_response":{}}
if (!this.response) {
throw("LASResponse is empty.");
}
} | function LASResponse(JSONObject) {
this.response = JSONObject.backend_response.response;
// Add methods to this object
this.getDate = LASResponse_getDate;
this.getID = LASResponse_getID;
this.getImageURL = LASResponse_getImageURL;
this.getDebugURL = LASResponse_getDebugURL;
this.getMapScaleURL = LASResponse_getMapScaleURL;
this.getRSSURL = LASResponse_getRSSURL;
this.isError = LASResponse_isError;
this.getResult = LASResponse_getResult;
// Check for incomplete LASResponse. Sometimes it looks like:
//
// {"backend_response":{}}
if (!this.response) {
throw("LASResponse is empty.");
}
} |
JavaScript | function LASResponse_getImageURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('plot_image');
return (Result.url);
} | function LASResponse_getImageURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('plot_image');
return (Result.url);
} |
JavaScript | function LASResponse_getDebugURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('debug');
return (Result.url);
} | function LASResponse_getDebugURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('debug');
return (Result.url);
} |
JavaScript | function LASResponse_getMapScaleURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('map_scale');
return (Result.url);
} | function LASResponse_getMapScaleURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('map_scale');
return (Result.url);
} |
JavaScript | function LASResponse_getRSSURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('rss');
return (Result.url);
} | function LASResponse_getRSSURL() {
// TODO: Throw exception when Result is not found.
var Result = this.getResult('rss');
return (Result.url);
} |
JavaScript | function LASResponse_getResult(ID) {
// TODO: Throw exception when Result is not found?
var length = this.response.result.length;
if (length) {
for (i=0; i<length; i++) {
if (this.response.result[i].ID == ID) {
return this.response.result[i];
}
}
} else {
if (this.response.result.ID == ID) {
return this.response.result;
}
}
return null;
} | function LASResponse_getResult(ID) {
// TODO: Throw exception when Result is not found?
var length = this.response.result.length;
if (length) {
for (i=0; i<length; i++) {
if (this.response.result[i].ID == ID) {
return this.response.result[i];
}
}
} else {
if (this.response.result.ID == ID) {
return this.response.result;
}
}
return null;
} |
JavaScript | function LASGetDataConstraintsResponse_getConstraintType() {
if(this.response.DataConstraints.Constraint)
if(this.response.DataConstraints.Constraint[0])
if(this.response.DataConstraints.Constraint[0].dataset)
return "dataset";
else
return "Constraint";
else
return null;
else
return null;
} | function LASGetDataConstraintsResponse_getConstraintType() {
if(this.response.DataConstraints.Constraint)
if(this.response.DataConstraints.Constraint[0])
if(this.response.DataConstraints.Constraint[0].dataset)
return "dataset";
else
return "Constraint";
else
return null;
else
return null;
} |
JavaScript | function LASGetDataConstraintsResponse_getConstraintID() {
if(this.getConstraintType() == "dataset")
return this.response.DataConstraints.Constraint[0].constraint.ID;
else
return "Constraint";
} | function LASGetDataConstraintsResponse_getConstraintID() {
if(this.getConstraintType() == "dataset")
return this.response.DataConstraints.Constraint[0].constraint.ID;
else
return "Constraint";
} |
JavaScript | function LASGetDataConstraintsResponse_getConstraintSize() {
if(this.getConstraintType() == "dataset") {
if(this.response.DataConstraints.Constraint[0].dataset.variables.variable)
return this.response.DataConstraints.Constraint[0].dataset.variables.variable.length;
} else
if(this.response.DataConstraints[this.getConstraintType()])
return this.response.DataConstraints[this.getConstraintType()].length;
else
return false;
} | function LASGetDataConstraintsResponse_getConstraintSize() {
if(this.getConstraintType() == "dataset") {
if(this.response.DataConstraints.Constraint[0].dataset.variables.variable)
return this.response.DataConstraints.Constraint[0].dataset.variables.variable.length;
} else
if(this.response.DataConstraints[this.getConstraintType()])
return this.response.DataConstraints[this.getConstraintType()].length;
else
return false;
} |
JavaScript | function LASGetDataConstraintsResponse_getChild(i) {
if(this.getConstraintType()=="dataset")
return this.response.DataConstraints.Constraint[0].dataset.variables.variable[i];
else
if(this.response.DataConstraints[this.getConstraintType()]);
return this.response.DataConstraints[this.getConstraintType()][i];
return false;
} | function LASGetDataConstraintsResponse_getChild(i) {
if(this.getConstraintType()=="dataset")
return this.response.DataConstraints.Constraint[0].dataset.variables.variable[i];
else
if(this.response.DataConstraints[this.getConstraintType()]);
return this.response.DataConstraints[this.getConstraintType()][i];
return false;
} |
JavaScript | function MenuWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
with (Select) {
// TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
for (var i=0; i<this.Menu.length; i++) {
options[i]=new Option(this.Menu[i][0], this.Menu[i][1]);
if (i == this.selectedIndex) {
options[i].selected = true;
}
}
}
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
this.visible = 1;
// Store the pointer to the Select object inside the MenuWidget object
this.Select = Select;
this.length = this.Select.length;
} | function MenuWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
with (Select) {
// TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
for (var i=0; i<this.Menu.length; i++) {
options[i]=new Option(this.Menu[i][0], this.Menu[i][1]);
if (i == this.selectedIndex) {
options[i].selected = true;
}
}
}
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
this.visible = 1;
// Store the pointer to the Select object inside the MenuWidget object
this.Select = Select;
this.length = this.Select.length;
} |
JavaScript | function MenuWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} | function MenuWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} |
JavaScript | function MenuWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} | function MenuWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} |
JavaScript | function MenuWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('MenuWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('MenuWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the MenuWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} | function MenuWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('MenuWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('MenuWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the MenuWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} |
JavaScript | function findPosX(obj) {
var curLeft = 0;
if (obj.offsetParent) {
do {
curLeft += obj.offsetLeft;
} while (obj = obj.offsetParent);
}
else if (obj.x) {
curLeft += obj.x;
}
return curLeft;
} | function findPosX(obj) {
var curLeft = 0;
if (obj.offsetParent) {
do {
curLeft += obj.offsetLeft;
} while (obj = obj.offsetParent);
}
else if (obj.x) {
curLeft += obj.x;
}
return curLeft;
} |
JavaScript | function scrollInit() {
if (!document.getElementsByTagName)
return;
var allLinks = document.getElementsByTagName('img');
for (var i = 0; i < allLinks.length; i++) {
var link = allLinks[i];
if ((' ' + link.className + ' ').indexOf(' clickableimage ') != -1) {
addEvent(link, 'click', clickListener, false);
}
}
} | function scrollInit() {
if (!document.getElementsByTagName)
return;
var allLinks = document.getElementsByTagName('img');
for (var i = 0; i < allLinks.length; i++) {
var link = allLinks[i];
if ((' ' + link.className + ' ').indexOf(' clickableimage ') != -1) {
addEvent(link, 'click', clickListener, false);
}
}
} |
JavaScript | function DateWidget(lo,hi,deltaMinutes,offsetMinutes,add_sub_1,add_sub_2) {
// Public methods that make up the the ImageSlideSorter Widget API
this.setCallback = DateWidget_setCallback;
this.render = DateWidget_render;
this.renderToNode = DateWidget_renderToNode;
this.disable = DateWidget_disable;
this.enable = DateWidget_enable;
this.show = DateWidget_show;
this.hide = DateWidget_hide;
this.getValue = DateWidget_getValue;
this.setValue = DateWidget_setValue;
/*
* TODO: Implelement this one as part of the LAS 'Widget Interface'
this.setValueByIndex = DateWidget_setValueByIndex;
*/
// Public methods
this.initializeYearMenu = DateWidget_initializeYearMenu;
this.setDateRange = DateWidget_setDateRange;
this.setDate1 = DateWidget_setDate1;
this.setDate2 = DateWidget_setDate2;
/*
this.nextDate1 = DateWidget_nextDate1;
this.nextDate2 = DateWidget_nextDate2;
*/
this.resetDateRange = DateWidget_resetDateRange;
this.resetDate1 = DateWidget_resetDate1;
this.resetDate2 = DateWidget_resetDate2;
this.toString = DateWidget_toString;
this.getDateLo = DateWidget_getDateLo;
this.getDateHi = DateWidget_getDateHi;
this.getDate1 = DateWidget_getDate1;
this.getDate2 = DateWidget_getDate2;
this.alert = DateWidget_alert;
this.setDeltaMinutes = DateWidget_setDeltaMinutes;
this.setOffsetMinutes = DateWidget_setOffsetMinutes;
// LAS/Ferret specific methods
this.getDate1_Ferret = DateWidget_getDate1_Ferret;
this.getDate2_Ferret = DateWidget_getDate2_Ferret;
// Private methods
this.parseDate = DateWidget_parseDate;
this.febDays = DateWidget_febDays;
this.twoDigit = DateWidget_twoDigit;
this.fourDigit = DateWidget_fourDigit;
this.correctOrder = DateWidget_correctOrder;
this.addEvent = DateWidget_addEvent;
this.flash = DateWidget_flash;
// Private methods that are called by the event handlers
this.selectYear = DateWidget_selectYear;
this.selectMonth = DateWidget_selectMonth;
this.selectDay = DateWidget_selectDay;
this.selectTime = DateWidget_selectTime;
// Event handlers
/*
* See optoinClick method below
this.optionClick = DateWidget_optionClick;
*/
this.selectChange = DateWidget_selectChange;
// Initialization
/**
* The SlideSorter requires that each widget must have a type attribute identifying it.
*/
this.widgetType = 'DateWidget';
/**
* @ignore
*/
this.climatology = 0;
/**
* @ignore
*/
this.disabled = 0;
/**
* @ignore
*/
this.visible = 0;
/**
* The number of minutes between options in the Time selector.
* <p>
* For example, setting deltaMinutes to 60 will result in the
* Time selector presenting an option for every hour, on the hour.
* <p>
* The default setting of 1440 (= 24 hours) shows only a single value of
* "00:00:00".
*/
this.deltaMinutes = (deltaMinutes) ? deltaMinutes : 1440;
/**
* The number of minutes by which to offset the Time selector from "00:00:00".
* <p>
* For example, setting deltaMinutes to 360 and offsetMinutes to 30
* will cause the Time selector to show the following values:
* <ul>
* <li>"00:30:00"</li>
* <li>"06:30:00"</li>
* <li>"12:30:00"</li>
* <li>"18:30:00"</li>
* </ul>
* <p>
* This may be useful for forecast data that is available at offsetMinutes
* after some regular interval.
*/
this.offsetMinutes = (offsetMinutes) ? offsetMinutes : 0;
// Attempt to parse the incoming date strings
var date1, date2, error_msg;
try {
date1 = this.parseDate(lo,add_sub_1);
} catch(error) {
error_msg = "DateWidget ERROR: new: error parsing \"" + lo + "\"\n" + error;
alert(error_msg);
}
try {
date2 = this.parseDate(hi,add_sub_2);
} catch(error) {
error_msg = "DateWidget ERROR: new: error parsing \"" + hi + "\"\n" + error;
alert(error_msg);
}
// Set the time domain
/**
* The Year associated with the earliest valid date.
*/
this.yearLo = date1[0];
/**
* The Month associated with the earliest valid date.
*/
this.monthLo = date1[1];
/**
* The Day associated with the earliest valid date.
*/
this.dayLo = date1[2];
/**
* The Hour associated with the earliest valid date.
*/
this.hourLo = date1[3];
/**
* The Minute associated with the earliest valid date.
*/
this.minuteLo = date1[4];
/**
* The Second associated with the earliest valid date.
*/
this.secondLo = date1[5];
/**
* The Year associated with the latest valid date.
*/
this.yearHi = date2[0];
/**
* The Month associated with the latest valid date.
*/
this.monthHi = date2[1];
/**
* The Day associated with the latest valid date.
*/
this.dayHi = date2[2];
/**
* The Hour associated with the latest valid date.
*/
this.hourHi = date2[3];
/**
* The Minute associated with the latest valid date.
*/
this.minuteHi = date2[4];
/**
* The Second associated with the latest valid date.
*/
this.secondHi = date2[5];
// On initialization, set the time range to the full domain
/**
* The currently selected low Year
*/
this.year1 = this.yearLo;
/**
* The currently selected low Month
*/
this.month1 = this.monthLo;
/**
* The currently selected low Day
*/
this.day1 = this.dayLo;
/**
* The currently selected low Hour
*/
this.hour1 = this.hourLo;
/**
* The currently selected low Minute
*/
this.minute1 = this.minuteLo;
/**
* The currently selected low Second
*/
this.second1 = this.secondLo;
/**
* The currently selected high Year
*/
this.year2 = this.yearHi;
/**
* The currently selected high Month
*/
this.month2 = this.monthHi;
/**
* The currently selected high Day
*/
this.day2 = this.dayHi;
/**
* The currently selected high Hour
*/
this.hour2 = this.hourHi;
/**
* The currently selected high Minute
*/
this.minute2 = this.minuteHi;
/**
* The currently selected high Second
*/
this.second2 = this.secondHi;
} | function DateWidget(lo,hi,deltaMinutes,offsetMinutes,add_sub_1,add_sub_2) {
// Public methods that make up the the ImageSlideSorter Widget API
this.setCallback = DateWidget_setCallback;
this.render = DateWidget_render;
this.renderToNode = DateWidget_renderToNode;
this.disable = DateWidget_disable;
this.enable = DateWidget_enable;
this.show = DateWidget_show;
this.hide = DateWidget_hide;
this.getValue = DateWidget_getValue;
this.setValue = DateWidget_setValue;
/*
* TODO: Implelement this one as part of the LAS 'Widget Interface'
this.setValueByIndex = DateWidget_setValueByIndex;
*/
// Public methods
this.initializeYearMenu = DateWidget_initializeYearMenu;
this.setDateRange = DateWidget_setDateRange;
this.setDate1 = DateWidget_setDate1;
this.setDate2 = DateWidget_setDate2;
/*
this.nextDate1 = DateWidget_nextDate1;
this.nextDate2 = DateWidget_nextDate2;
*/
this.resetDateRange = DateWidget_resetDateRange;
this.resetDate1 = DateWidget_resetDate1;
this.resetDate2 = DateWidget_resetDate2;
this.toString = DateWidget_toString;
this.getDateLo = DateWidget_getDateLo;
this.getDateHi = DateWidget_getDateHi;
this.getDate1 = DateWidget_getDate1;
this.getDate2 = DateWidget_getDate2;
this.alert = DateWidget_alert;
this.setDeltaMinutes = DateWidget_setDeltaMinutes;
this.setOffsetMinutes = DateWidget_setOffsetMinutes;
// LAS/Ferret specific methods
this.getDate1_Ferret = DateWidget_getDate1_Ferret;
this.getDate2_Ferret = DateWidget_getDate2_Ferret;
// Private methods
this.parseDate = DateWidget_parseDate;
this.febDays = DateWidget_febDays;
this.twoDigit = DateWidget_twoDigit;
this.fourDigit = DateWidget_fourDigit;
this.correctOrder = DateWidget_correctOrder;
this.addEvent = DateWidget_addEvent;
this.flash = DateWidget_flash;
// Private methods that are called by the event handlers
this.selectYear = DateWidget_selectYear;
this.selectMonth = DateWidget_selectMonth;
this.selectDay = DateWidget_selectDay;
this.selectTime = DateWidget_selectTime;
// Event handlers
/*
* See optoinClick method below
this.optionClick = DateWidget_optionClick;
*/
this.selectChange = DateWidget_selectChange;
// Initialization
/**
* The SlideSorter requires that each widget must have a type attribute identifying it.
*/
this.widgetType = 'DateWidget';
/**
* @ignore
*/
this.climatology = 0;
/**
* @ignore
*/
this.disabled = 0;
/**
* @ignore
*/
this.visible = 0;
/**
* The number of minutes between options in the Time selector.
* <p>
* For example, setting deltaMinutes to 60 will result in the
* Time selector presenting an option for every hour, on the hour.
* <p>
* The default setting of 1440 (= 24 hours) shows only a single value of
* "00:00:00".
*/
this.deltaMinutes = (deltaMinutes) ? deltaMinutes : 1440;
/**
* The number of minutes by which to offset the Time selector from "00:00:00".
* <p>
* For example, setting deltaMinutes to 360 and offsetMinutes to 30
* will cause the Time selector to show the following values:
* <ul>
* <li>"00:30:00"</li>
* <li>"06:30:00"</li>
* <li>"12:30:00"</li>
* <li>"18:30:00"</li>
* </ul>
* <p>
* This may be useful for forecast data that is available at offsetMinutes
* after some regular interval.
*/
this.offsetMinutes = (offsetMinutes) ? offsetMinutes : 0;
// Attempt to parse the incoming date strings
var date1, date2, error_msg;
try {
date1 = this.parseDate(lo,add_sub_1);
} catch(error) {
error_msg = "DateWidget ERROR: new: error parsing \"" + lo + "\"\n" + error;
alert(error_msg);
}
try {
date2 = this.parseDate(hi,add_sub_2);
} catch(error) {
error_msg = "DateWidget ERROR: new: error parsing \"" + hi + "\"\n" + error;
alert(error_msg);
}
// Set the time domain
/**
* The Year associated with the earliest valid date.
*/
this.yearLo = date1[0];
/**
* The Month associated with the earliest valid date.
*/
this.monthLo = date1[1];
/**
* The Day associated with the earliest valid date.
*/
this.dayLo = date1[2];
/**
* The Hour associated with the earliest valid date.
*/
this.hourLo = date1[3];
/**
* The Minute associated with the earliest valid date.
*/
this.minuteLo = date1[4];
/**
* The Second associated with the earliest valid date.
*/
this.secondLo = date1[5];
/**
* The Year associated with the latest valid date.
*/
this.yearHi = date2[0];
/**
* The Month associated with the latest valid date.
*/
this.monthHi = date2[1];
/**
* The Day associated with the latest valid date.
*/
this.dayHi = date2[2];
/**
* The Hour associated with the latest valid date.
*/
this.hourHi = date2[3];
/**
* The Minute associated with the latest valid date.
*/
this.minuteHi = date2[4];
/**
* The Second associated with the latest valid date.
*/
this.secondHi = date2[5];
// On initialization, set the time range to the full domain
/**
* The currently selected low Year
*/
this.year1 = this.yearLo;
/**
* The currently selected low Month
*/
this.month1 = this.monthLo;
/**
* The currently selected low Day
*/
this.day1 = this.dayLo;
/**
* The currently selected low Hour
*/
this.hour1 = this.hourLo;
/**
* The currently selected low Minute
*/
this.minute1 = this.minuteLo;
/**
* The currently selected low Second
*/
this.second1 = this.secondLo;
/**
* The currently selected high Year
*/
this.year2 = this.yearHi;
/**
* The currently selected high Month
*/
this.month2 = this.monthHi;
/**
* The currently selected high Day
*/
this.day2 = this.dayHi;
/**
* The currently selected high Hour
*/
this.hour2 = this.hourHi;
/**
* The currently selected high Minute
*/
this.minute2 = this.minuteHi;
/**
* The currently selected high Second
*/
this.second2 = this.secondHi;
} |
JavaScript | function DateWidget_initializeYearMenu(YearMenu) {
// Recreate the Year menu
// If widget #1, range = yearLo:yearHi
// If widget #2, range = yearLo:yearHi
var loYear;
var hiYear;
var currentYear;
// Get the appropriate loYear, hiYear and currentYear
// TODO: Use matching instead of '==' when 'DW_Year1' is replaced by
// TODO: this.entry_id + "_Year1"
if (YearMenu.getAttribute('id') == 'DW_Year1') {
loYear = this.yearLo;
hiYear = this.yearHi;
if (this.year1 > this.year2) {
currentYear = this.year2;
this.flash(YearMenu);
} else {
currentYear = this.year1;
}
} else {
loYear = this.yearLo;
hiYear = this.yearHi;
if (this.year1 > this.year2) {
currentYear = this.year1;
this.flash(YearMenu);
} else {
currentYear = this.year2;
}
}
// Create a new set of options and then select
// a year: current selection or nearest available unless initializing.
// NOTE: See Quirksmode for many hints on cross-browser scripting (http://www.quirksmode.org/)
// NOTE:
// NOTE: 1) Qurksmode recommends usig the traditional model for event registering
// NOTE:
// NOTE: 2) Safari 1.3 doesn't support events on Options
// NOTE: Instead, attach an onchange event to the Select object
var n = hiYear - loYear + 1
var y = loYear;
with (YearMenu) {
options.length=0;
for (i=0; i<n; i++) {
options[i]=new Option(y,y);
//this.addEvent(options[i], 'click', this.optionClick, false);
y++;
}
if (this.initializing) {
// Initialize Year1 to the first year
// Initialize Year2 to the last year
this.internallyForced = 1;
if (name == 'Year1') {
options[0].selected=true;
} else {
options[length-1].selected=true;
}
this.initializing = 0;
} else {
y = loYear;
for (i=0; i<n; i++) {
if (y == currentYear) {
options[i].selected=true;
}
y++;
}
}
}
YearMenu.onchange = this.selectChange;
this.selectYear(YearMenu);
} | function DateWidget_initializeYearMenu(YearMenu) {
// Recreate the Year menu
// If widget #1, range = yearLo:yearHi
// If widget #2, range = yearLo:yearHi
var loYear;
var hiYear;
var currentYear;
// Get the appropriate loYear, hiYear and currentYear
// TODO: Use matching instead of '==' when 'DW_Year1' is replaced by
// TODO: this.entry_id + "_Year1"
if (YearMenu.getAttribute('id') == 'DW_Year1') {
loYear = this.yearLo;
hiYear = this.yearHi;
if (this.year1 > this.year2) {
currentYear = this.year2;
this.flash(YearMenu);
} else {
currentYear = this.year1;
}
} else {
loYear = this.yearLo;
hiYear = this.yearHi;
if (this.year1 > this.year2) {
currentYear = this.year1;
this.flash(YearMenu);
} else {
currentYear = this.year2;
}
}
// Create a new set of options and then select
// a year: current selection or nearest available unless initializing.
// NOTE: See Quirksmode for many hints on cross-browser scripting (http://www.quirksmode.org/)
// NOTE:
// NOTE: 1) Qurksmode recommends usig the traditional model for event registering
// NOTE:
// NOTE: 2) Safari 1.3 doesn't support events on Options
// NOTE: Instead, attach an onchange event to the Select object
var n = hiYear - loYear + 1
var y = loYear;
with (YearMenu) {
options.length=0;
for (i=0; i<n; i++) {
options[i]=new Option(y,y);
//this.addEvent(options[i], 'click', this.optionClick, false);
y++;
}
if (this.initializing) {
// Initialize Year1 to the first year
// Initialize Year2 to the last year
this.internallyForced = 1;
if (name == 'Year1') {
options[0].selected=true;
} else {
options[length-1].selected=true;
}
this.initializing = 0;
} else {
y = loYear;
for (i=0; i<n; i++) {
if (y == currentYear) {
options[i].selected=true;
}
y++;
}
}
}
YearMenu.onchange = this.selectChange;
this.selectYear(YearMenu);
} |
JavaScript | function DateWidget_setDateRange(String1,String2,add_sub_1,add_sub_2) {
this.resetDateRange();
this.setDate1(String1,add_sub_1);
this.setDate2(String2,add_sub_2);
} | function DateWidget_setDateRange(String1,String2,add_sub_1,add_sub_2) {
this.resetDateRange();
this.setDate1(String1,add_sub_1);
this.setDate2(String2,add_sub_2);
} |
JavaScript | function DateWidget_setDate1(String1,add_sub_1) {
// TODO: setDate1() needs to throw exceptions
var date1 = this.parseDate(String1,add_sub_1);
this.year1 = date1[0];
this.month1 = date1[1];
this.day1 = date1[2];
this.hour1 = date1[3];
this.minute1 = date1[4];
this.second1 = date1[5];
if (!this.climatology) {
this.initializeYearMenu(this.Year1);
} else {
if (this.Month1) {
this.selectMonth(this.Month1);
}
}
} | function DateWidget_setDate1(String1,add_sub_1) {
// TODO: setDate1() needs to throw exceptions
var date1 = this.parseDate(String1,add_sub_1);
this.year1 = date1[0];
this.month1 = date1[1];
this.day1 = date1[2];
this.hour1 = date1[3];
this.minute1 = date1[4];
this.second1 = date1[5];
if (!this.climatology) {
this.initializeYearMenu(this.Year1);
} else {
if (this.Month1) {
this.selectMonth(this.Month1);
}
}
} |
JavaScript | function DateWidget_setDate2(String2,add_sub_2) {
// TODO: setDate2() needs to throw exceptions
var date2 = this.parseDate(String2,add_sub_2);
this.year2 = date2[0];
this.month2 = date2[1];
this.day2 = date2[2];
this.hour2 = date2[3];
this.minute2 = date2[4];
this.second2 = date2[5];
if (this.Year2) {
this.initializeYearMenu(this.Year2);
} else {
if (this.Month2) {
this.selectMonth(this.Month2);
}
}
} | function DateWidget_setDate2(String2,add_sub_2) {
// TODO: setDate2() needs to throw exceptions
var date2 = this.parseDate(String2,add_sub_2);
this.year2 = date2[0];
this.month2 = date2[1];
this.day2 = date2[2];
this.hour2 = date2[3];
this.minute2 = date2[4];
this.second2 = date2[5];
if (this.Year2) {
this.initializeYearMenu(this.Year2);
} else {
if (this.Month2) {
this.selectMonth(this.Month2);
}
}
} |
JavaScript | function DateWidget_getDate1_Ferret() {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var month1 = (this.month1 == '00') ? '' : '-' + monthNames[Number(this.month1)-1];
var day1 = (this.day1 == '00') ? '' : this.day1;
if( this.menu_set_1.indexOf('T')!=-1)
var time1 = (this.Time1) ? ' ' + this.twoDigit(this.hour1) + ':' + this.twoDigit(this.minute1) + ':' + this.twoDigit(this.second1) : '';
else
var time1 = "";
var message = day1 + month1 + '-' + this.fourDigit(this.year1) + time1;
return message;
} | function DateWidget_getDate1_Ferret() {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var month1 = (this.month1 == '00') ? '' : '-' + monthNames[Number(this.month1)-1];
var day1 = (this.day1 == '00') ? '' : this.day1;
if( this.menu_set_1.indexOf('T')!=-1)
var time1 = (this.Time1) ? ' ' + this.twoDigit(this.hour1) + ':' + this.twoDigit(this.minute1) + ':' + this.twoDigit(this.second1) : '';
else
var time1 = "";
var message = day1 + month1 + '-' + this.fourDigit(this.year1) + time1;
return message;
} |
JavaScript | function DateWidget_getDate2_Ferret() {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var month2 = (this.month2 == '00') ? '' : '-' + monthNames[Number(this.month2)-1];
var day2 = (this.day2 == '00') ? '' : this.day2;
if(this.menu_set_2.indexOf('T')!=-1)
var time2 = (this.Time2) ? ' ' + this.twoDigit(this.hour2) + ':' + this.twoDigit(this.minute2) + ':' + this.twoDigit(this.second2) : '';
else
var time2 = "";
//var message = (this.Year2) ? day2 + month2 + '-' + this.fourDigit(this.year2) + time2 : '';
var message = day2 + month2 + '-' + this.fourDigit(this.year2) + time2;
return message;
} | function DateWidget_getDate2_Ferret() {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var month2 = (this.month2 == '00') ? '' : '-' + monthNames[Number(this.month2)-1];
var day2 = (this.day2 == '00') ? '' : this.day2;
if(this.menu_set_2.indexOf('T')!=-1)
var time2 = (this.Time2) ? ' ' + this.twoDigit(this.hour2) + ':' + this.twoDigit(this.minute2) + ':' + this.twoDigit(this.second2) : '';
else
var time2 = "";
//var message = (this.Year2) ? day2 + month2 + '-' + this.fourDigit(this.year2) + time2 : '';
var message = day2 + month2 + '-' + this.fourDigit(this.year2) + time2;
return message;
} |
JavaScript | function DateWidget_getValue() {
var result = this.getDate1_Ferret();
if (this.menu_set_2) {
result = result + "," + this.getDate2_Ferret();
}
return result;
} | function DateWidget_getValue() {
var result = this.getDate1_Ferret();
if (this.menu_set_2) {
result = result + "," + this.getDate2_Ferret();
}
return result;
} |
JavaScript | function DateWidget_disable(hilo) {
var node = document.getElementById(this.element_id);
var select_nodes = node.getElementsByTagName('select');
for (var i=0; i<select_nodes.length; i++)
switch(hilo) {
case 'hi' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='2')
select_nodes[i].disabled= 1;
else
break;
case 'lo' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='1')
select_nodes[i].disabled= 1;
break;
default :
select_nodes[i].disabled = 1;
}
this.disabled = 1;
} | function DateWidget_disable(hilo) {
var node = document.getElementById(this.element_id);
var select_nodes = node.getElementsByTagName('select');
for (var i=0; i<select_nodes.length; i++)
switch(hilo) {
case 'hi' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='2')
select_nodes[i].disabled= 1;
else
break;
case 'lo' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='1')
select_nodes[i].disabled= 1;
break;
default :
select_nodes[i].disabled = 1;
}
this.disabled = 1;
} |
JavaScript | function DateWidget_enable(hilo) {
var node = document.getElementById(this.element_id);
var select_nodes = node.getElementsByTagName('select');
for (var i=0; i<select_nodes.length; i++)
switch(hilo) {
case 'hi' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='2')
select_nodes[i].disabled= 0;
else
break;
case 'lo' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='1')
select_nodes[i].disabled= 0;
break;
default :
select_nodes[i].disabled = 0;
}
this.disabled = 0;
} | function DateWidget_enable(hilo) {
var node = document.getElementById(this.element_id);
var select_nodes = node.getElementsByTagName('select');
for (var i=0; i<select_nodes.length; i++)
switch(hilo) {
case 'hi' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='2')
select_nodes[i].disabled= 0;
else
break;
case 'lo' :
if(select_nodes[i].id[select_nodes[i].id.length-1]=='1')
select_nodes[i].disabled= 0;
break;
default :
select_nodes[i].disabled = 0;
}
this.disabled = 0;
} |
JavaScript | function DateWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} | function DateWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} |
JavaScript | function DateWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} | function DateWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} |
JavaScript | function DateWidget_parseDate(dateString,add_sub) {
var YMDHMS;
var milli;
var date = new Date();
var newDate = new Date();
switch (dateString) {
case 'NOW':
break;
case 'TODAY':
var dummy = new Date();
date = new Date(dummy.getFullYear(),dummy.getMonth(),dummy.getDate(),0,0,0);
newDate = new Date(dummy.getFullYear(),dummy.getMonth(),dummy.getDate(),0,0,0);
break;
default:
var dateTime = String(dateString).split(' ');
var YMD = String(dateTime[0]).split('-');
var YMDHMS = String(dateTime[0]).split('-');
// Ferret format: 'D?-Mon[-YYYY]'
if (String(YMD[1]).length == 3) {
var months = {jan:'01',feb:'02',mar:'03',apr:'04',may:'05',jun:'06',jul:'07',aug:'08',sep:'09',oct:'10',nov:'11',dec:'12'};
var mon = String(YMD[1].toLowerCase());
var MM = months[mon];
if (YMD[2]) {
YMDHMS[0] = YMD[2];
} else {
YMDHMS[0] = '0001';
}
YMDHMS[1] = MM;
YMDHMS[2] = YMD[0];
}
if (YMDHMS[0]) {
// NOTE: The javascript Date object in most browsers treats all 0000 < years < 0100 as if they were two-digit
// NOTE: representations of '19YY'. To account for this we will add 8000 to all
// NOTE: years < 0100 for internal Date object calculations and then subtract 8000
// NOTE: at the end.
if (Number(YMDHMS[0]).valueOf() >= 8000) {
error_msg = 'The DateWidget cannot handle years >= 8000. Incoming date is "' + dateString + '"';
throw(error_msg);
}
var year = Number(YMDHMS[0]).valueOf();
if (year < 100) {
year += 8000;
YMDHMS[0] = String(year);
}
// NOTE: Test for restricted Safari range as described here:
// NOTE: http://www.merlyn.demon.co.uk/js-datex.htm
var in_year = Number(YMDHMS[0]);
var Safari_date = new Date(in_year,1,1);
var Safari_year = Safari_date.getFullYear();
if (Safari_year != in_year) {
if (in_year > 8000) { in_year -= 8000 } // convert back to original for error message
error_msg = 'Browser Issue! Some browsers, eg Safari, only support years within the restricted range of "1902" to "2037". Incoming year is "' + in_year + '".';
//throw(error_msg);
}
} else {
error_msg = 'DateWidget ERROR: parseDate: bad date "' + dateString + '"';
//throw(error_msg);
}
if (dateTime[1]) {
var HMS = String(dateTime[1]).split(':');
YMDHMS[3] = HMS[0];
YMDHMS[4] = HMS[1];
if ( HMS[2] ) {
YMDHMS[5] = HMS[2];
} else {
YMDHMS[5] = '00';
}
} else {
YMDHMS[3] = '00';
YMDHMS[4] = '00';
YMDHMS[5] = '00';
}
// Throw exceptions if appropriate
var error_msg;
if (Number(YMDHMS[1]).valueOf() < 1 || Number(YMDHMS[1]).valueOf() > 12) {
error_msg = "DateWidget ERROR: parseDate: month \"" + YMDHMS[1] + "\" must be in the range 1:12";
throw(error_msg);
}
if (Number(YMDHMS[2]).valueOf() < 1 || Number(YMDHMS[2]).valueOf() > 31) {
error_msg = "DateWidget ERROR: parseDate: day \"" + YMDHMS[2] + "\" must be in the range 1:31";
throw(error_msg);
}
if (Number(YMDHMS[3]).valueOf() < 0 || Number(YMDHMS[3]).valueOf() > 23) {
error_msg = "DateWidget ERROR: parseDate: hour \"" + YMDHMS[3] + "\" must be in the range 0:23";
throw(error_msg);
}
if (Number(YMDHMS[4]).valueOf() < 0 || Number(YMDHMS[4]).valueOf() > 59) {
error_msg = "DateWidget ERROR: parseDate: minute \"" + YMDHMS[4] + "\" must be in the range 0:59";
throw(error_msg);
}
if (Number(YMDHMS[5]).valueOf() < 0 || Number(YMDHMS[5]).valueOf() > 59) {
error_msg = "DateWidget ERROR: parseDate: second \"" + YMDHMS[5] + "\" must be in the range 0:59";
throw(error_msg);
}
date = new Date(YMDHMS[0],YMDHMS[1]-1,YMDHMS[2],YMDHMS[3],YMDHMS[4],YMDHMS[5]);
newDate = new Date(YMDHMS[0],YMDHMS[1]-1,YMDHMS[2],YMDHMS[3],YMDHMS[4],YMDHMS[5]);
break;
}
if (add_sub) {
milli = date.valueOf() + 60 * 1000 * add_sub;
newDate = new Date(milli);
}
// NOTE: Store integer values (not Strings) in YMDHMS.
with (newDate) {
YMDHMS = new Array(getFullYear(),getMonth()+1,getDate(),getHours(),getMinutes(),getSeconds());
}
// NOTE: No support for seconds at this time
YMDHMS[5] = 0;
// NOTE: Return years > 8000 to their original
if (YMDHMS[0] >= 8000) {
YMDHMS[0] -= 8000;
}
return YMDHMS;
} | function DateWidget_parseDate(dateString,add_sub) {
var YMDHMS;
var milli;
var date = new Date();
var newDate = new Date();
switch (dateString) {
case 'NOW':
break;
case 'TODAY':
var dummy = new Date();
date = new Date(dummy.getFullYear(),dummy.getMonth(),dummy.getDate(),0,0,0);
newDate = new Date(dummy.getFullYear(),dummy.getMonth(),dummy.getDate(),0,0,0);
break;
default:
var dateTime = String(dateString).split(' ');
var YMD = String(dateTime[0]).split('-');
var YMDHMS = String(dateTime[0]).split('-');
// Ferret format: 'D?-Mon[-YYYY]'
if (String(YMD[1]).length == 3) {
var months = {jan:'01',feb:'02',mar:'03',apr:'04',may:'05',jun:'06',jul:'07',aug:'08',sep:'09',oct:'10',nov:'11',dec:'12'};
var mon = String(YMD[1].toLowerCase());
var MM = months[mon];
if (YMD[2]) {
YMDHMS[0] = YMD[2];
} else {
YMDHMS[0] = '0001';
}
YMDHMS[1] = MM;
YMDHMS[2] = YMD[0];
}
if (YMDHMS[0]) {
// NOTE: The javascript Date object in most browsers treats all 0000 < years < 0100 as if they were two-digit
// NOTE: representations of '19YY'. To account for this we will add 8000 to all
// NOTE: years < 0100 for internal Date object calculations and then subtract 8000
// NOTE: at the end.
if (Number(YMDHMS[0]).valueOf() >= 8000) {
error_msg = 'The DateWidget cannot handle years >= 8000. Incoming date is "' + dateString + '"';
throw(error_msg);
}
var year = Number(YMDHMS[0]).valueOf();
if (year < 100) {
year += 8000;
YMDHMS[0] = String(year);
}
// NOTE: Test for restricted Safari range as described here:
// NOTE: http://www.merlyn.demon.co.uk/js-datex.htm
var in_year = Number(YMDHMS[0]);
var Safari_date = new Date(in_year,1,1);
var Safari_year = Safari_date.getFullYear();
if (Safari_year != in_year) {
if (in_year > 8000) { in_year -= 8000 } // convert back to original for error message
error_msg = 'Browser Issue! Some browsers, eg Safari, only support years within the restricted range of "1902" to "2037". Incoming year is "' + in_year + '".';
//throw(error_msg);
}
} else {
error_msg = 'DateWidget ERROR: parseDate: bad date "' + dateString + '"';
//throw(error_msg);
}
if (dateTime[1]) {
var HMS = String(dateTime[1]).split(':');
YMDHMS[3] = HMS[0];
YMDHMS[4] = HMS[1];
if ( HMS[2] ) {
YMDHMS[5] = HMS[2];
} else {
YMDHMS[5] = '00';
}
} else {
YMDHMS[3] = '00';
YMDHMS[4] = '00';
YMDHMS[5] = '00';
}
// Throw exceptions if appropriate
var error_msg;
if (Number(YMDHMS[1]).valueOf() < 1 || Number(YMDHMS[1]).valueOf() > 12) {
error_msg = "DateWidget ERROR: parseDate: month \"" + YMDHMS[1] + "\" must be in the range 1:12";
throw(error_msg);
}
if (Number(YMDHMS[2]).valueOf() < 1 || Number(YMDHMS[2]).valueOf() > 31) {
error_msg = "DateWidget ERROR: parseDate: day \"" + YMDHMS[2] + "\" must be in the range 1:31";
throw(error_msg);
}
if (Number(YMDHMS[3]).valueOf() < 0 || Number(YMDHMS[3]).valueOf() > 23) {
error_msg = "DateWidget ERROR: parseDate: hour \"" + YMDHMS[3] + "\" must be in the range 0:23";
throw(error_msg);
}
if (Number(YMDHMS[4]).valueOf() < 0 || Number(YMDHMS[4]).valueOf() > 59) {
error_msg = "DateWidget ERROR: parseDate: minute \"" + YMDHMS[4] + "\" must be in the range 0:59";
throw(error_msg);
}
if (Number(YMDHMS[5]).valueOf() < 0 || Number(YMDHMS[5]).valueOf() > 59) {
error_msg = "DateWidget ERROR: parseDate: second \"" + YMDHMS[5] + "\" must be in the range 0:59";
throw(error_msg);
}
date = new Date(YMDHMS[0],YMDHMS[1]-1,YMDHMS[2],YMDHMS[3],YMDHMS[4],YMDHMS[5]);
newDate = new Date(YMDHMS[0],YMDHMS[1]-1,YMDHMS[2],YMDHMS[3],YMDHMS[4],YMDHMS[5]);
break;
}
if (add_sub) {
milli = date.valueOf() + 60 * 1000 * add_sub;
newDate = new Date(milli);
}
// NOTE: Store integer values (not Strings) in YMDHMS.
with (newDate) {
YMDHMS = new Array(getFullYear(),getMonth()+1,getDate(),getHours(),getMinutes(),getSeconds());
}
// NOTE: No support for seconds at this time
YMDHMS[5] = 0;
// NOTE: Return years > 8000 to their original
if (YMDHMS[0] >= 8000) {
YMDHMS[0] -= 8000;
}
return YMDHMS;
} |
JavaScript | function DateWidget_febDays(year) {
var febDays = 28
if ( (year%4) == 0 ) {
febDays = 29;
if ( (year%100) == 0 ) {
febDays = 28;
if ( (year%400) == 0 ) {
febDays = 29;
}
}
}
return febDays;
} | function DateWidget_febDays(year) {
var febDays = 28
if ( (year%4) == 0 ) {
febDays = 29;
if ( (year%100) == 0 ) {
febDays = 28;
if ( (year%400) == 0 ) {
febDays = 29;
}
}
}
return febDays;
} |
JavaScript | function DateWidget_fourDigit(num) {
while (String(num).length < 4) {
num = '0' + String(num);
}
return num;
} | function DateWidget_fourDigit(num) {
while (String(num).length < 4) {
num = '0' + String(num);
}
return num;
} |
JavaScript | function DateWidget_flash(Menu) {
var name = Menu.id;
var command = "document.getElementById(\'" + name + "\').style.backgroundColor = '#fff'";
Menu.style.backgroundColor = '#fcc';
window.setTimeout(command,750);
} | function DateWidget_flash(Menu) {
var name = Menu.id;
var command = "document.getElementById(\'" + name + "\').style.backgroundColor = '#fff'";
Menu.style.backgroundColor = '#fcc';
window.setTimeout(command,750);
} |
JavaScript | function DateWidget_selectYear(YearMenu) {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var monthVals = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
currentYear = YearMenu.options[YearMenu.selectedIndex].value;
var currentMonth;
var MonthMenu;
if (YearMenu.getAttribute('id') == 'DW_Year1') {
MonthMenu = this.Month1;
this.year1 = currentYear;
if (this.year1 == this.year2 && this.month1 > this.month2) {
currentMonth = this.month2 - 1;
this.flash(MonthMenu);
} else {
currentMonth = this.month1 - 1;
}
} else {
MonthMenu = this.Month2;
this.year2 = currentYear;
if (this.year1 == this.year2 && this.month1 > this.month2) {
currentMonth = this.month1 - 1;
this.flash(MonthMenu);
} else {
currentMonth = this.month2 - 1;
}
}
// Recreate the Month menu
// If widget #1, range = yearLo-monthLo:yearHi-monthHi
// If widget #2, range = yearLo-monthLo:yearHi-monthHi
var loMonth = 0;
var hiMonth = 11;
var OtherYearMenu;
if (YearMenu.getAttribute('id') == 'DW_Year1') {
OtherYearMenu = this.Year2;
if (currentYear == this.yearLo) {
loMonth = this.monthLo - 1;
}
if (currentYear == this.yearHi) {
hiMonth = this.monthHi - 1;
}
} else {
OtherYearMenu = this.Year1;
if (currentYear == this.yearLo) {
loMonth = this.monthLo - 1;
}
if (currentYear == this.yearHi) {
hiMonth = this.monthHi - 1;
}
}
// Create a new set of options and then select
// a month: current selection or nearest available unless initializing.
if (MonthMenu) {
with (MonthMenu) {
var n = hiMonth - loMonth;
var m = loMonth;
options.length=0;
if (this.monthLo != '00') {
for (i=0; i<=n; i++) {
options[i]=new Option(monthNames[m],monthVals[m]);
//this.addEvent(options[i], 'click', this.optionClick, false);
m++;
}
if (currentMonth < loMonth || currentMonth > hiMonth) {
if (currentMonth < loMonth) {
options[0].selected = true;
} else {
var i = hiMonth - loMonth;
if(options[i]) {
options[i].selected = true; }
}
} else {
var i = currentMonth - loMonth;
if(options[i]) {
options[i].selected = true;
}
}
}
}
MonthMenu.onchange = this.selectChange;
this.selectMonth(MonthMenu);
} else {
//No Month-Day-Time Menus
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
}
} | function DateWidget_selectYear(YearMenu) {
var monthNames = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var monthVals = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
currentYear = YearMenu.options[YearMenu.selectedIndex].value;
var currentMonth;
var MonthMenu;
if (YearMenu.getAttribute('id') == 'DW_Year1') {
MonthMenu = this.Month1;
this.year1 = currentYear;
if (this.year1 == this.year2 && this.month1 > this.month2) {
currentMonth = this.month2 - 1;
this.flash(MonthMenu);
} else {
currentMonth = this.month1 - 1;
}
} else {
MonthMenu = this.Month2;
this.year2 = currentYear;
if (this.year1 == this.year2 && this.month1 > this.month2) {
currentMonth = this.month1 - 1;
this.flash(MonthMenu);
} else {
currentMonth = this.month2 - 1;
}
}
// Recreate the Month menu
// If widget #1, range = yearLo-monthLo:yearHi-monthHi
// If widget #2, range = yearLo-monthLo:yearHi-monthHi
var loMonth = 0;
var hiMonth = 11;
var OtherYearMenu;
if (YearMenu.getAttribute('id') == 'DW_Year1') {
OtherYearMenu = this.Year2;
if (currentYear == this.yearLo) {
loMonth = this.monthLo - 1;
}
if (currentYear == this.yearHi) {
hiMonth = this.monthHi - 1;
}
} else {
OtherYearMenu = this.Year1;
if (currentYear == this.yearLo) {
loMonth = this.monthLo - 1;
}
if (currentYear == this.yearHi) {
hiMonth = this.monthHi - 1;
}
}
// Create a new set of options and then select
// a month: current selection or nearest available unless initializing.
if (MonthMenu) {
with (MonthMenu) {
var n = hiMonth - loMonth;
var m = loMonth;
options.length=0;
if (this.monthLo != '00') {
for (i=0; i<=n; i++) {
options[i]=new Option(monthNames[m],monthVals[m]);
//this.addEvent(options[i], 'click', this.optionClick, false);
m++;
}
if (currentMonth < loMonth || currentMonth > hiMonth) {
if (currentMonth < loMonth) {
options[0].selected = true;
} else {
var i = hiMonth - loMonth;
if(options[i]) {
options[i].selected = true; }
}
} else {
var i = currentMonth - loMonth;
if(options[i]) {
options[i].selected = true;
}
}
}
}
MonthMenu.onchange = this.selectChange;
this.selectMonth(MonthMenu);
} else {
//No Month-Day-Time Menus
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
}
} |
JavaScript | function DateWidget_selectMonth(MonthMenu) {
var currentYear;
var currentMonth;
var currentDay;
var DayMenu;
var OtherYearMenu;
var dayVals = new Array('01','02','03','04','05','06','07','08','09','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30','31');
if (this.monthLo == '00') {
currentMonth = '00';
} else {
currentMonth = MonthMenu.options[MonthMenu.selectedIndex].value;
}
// TODO: Use matching instead of '==' when 'DW_Month1' is replaced by
// TODO: this.entry_id + "_Month1"
if (MonthMenu.getAttribute('id') == 'DW_Month1') {
OtherYearMenu = this.Year2;
DayMenu = this.Day1;
currentYear = this.year1;
this.month1 = currentMonth;
if (this.year1 == this.year2 && this.month1 == this.month2 && this.day1 > this.day2) {
currentDay = this.day2;
this.flash(DayMenu);
} else {
currentDay = this.day1;
}
} else {
OtherYearMenu = this.Year1;
DayMenu = this.Day2;
currentYear = this.year2;
this.month2 = currentMonth;
if (this.year1 == this.year2 && this.month1 == this.month2 && this.day1 > this.day2) {
currentDay = this.day1;
this.flash(DayMenu);
} else {
currentDay = this.day2;
}
}
// Recreate the Day menu
var loDay = 1;
var hiDay = 31;
// Modify hiDay based on month
switch (currentMonth) {
case "02":
hiDay = this.febDays(currentYear); break;
case "04":
hiDay = 30; break;
case "06":
hiDay = 30; break;
case "09":
hiDay = 30; break;
case "11":
hiDay = 30; break;
default:
hiDay = 31; break;
}
// Recreate the Day menu
// If widget #1, range = yearLo-monthLo-dayLo:yearHi-monthHi-dayHi
// If widget #2, range = yearLo-monthLo-dayLo:yearHi-monthHi-dayHi
if (MonthMenu.getAttribute('id') == 'DW_Month1') {
if (currentYear == this.yearLo && currentMonth == this.monthLo) {
loDay = this.dayLo;
}
if (currentYear == this.yearHi && currentMonth == this.monthHi) {
hiDay = this.dayHi;
}
} else {
if (currentYear == this.yearLo && currentMonth == this.monthLo) {
loDay = this.dayLo;
}
if (currentYear == this.yearHi && currentMonth == this.monthHi) {
hiDay = this.dayHi;
}
}
// Create a new set of options and then select
// a day: current selection or nearest available
if (DayMenu) {
with (DayMenu) {
var n = hiDay - loDay + 1;
var d = loDay - 1;
options.length=0;
if (this.dayLo != '00') { // No days widget
for (i=0; i<n; i++) {
options[i]=new Option(dayVals[d],dayVals[d]);
//this.addEvent(options[i], 'click', this.optionClick, false);
d++;
}
if (currentDay < loDay || currentDay > hiDay) {
if (currentDay < loDay) {
options[0].selected = true;
} else {
var i = hiDay - loDay;
options[i].selected = true;
}
this.flash(DayMenu);
} else {
var i = currentDay - loDay;
options[i].selected = true;
}
}
}
DayMenu.onchange = this.selectChange;
this.selectDay(DayMenu);
} else {
//No Day-Time Menus
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
}
} | function DateWidget_selectMonth(MonthMenu) {
var currentYear;
var currentMonth;
var currentDay;
var DayMenu;
var OtherYearMenu;
var dayVals = new Array('01','02','03','04','05','06','07','08','09','10',
'11','12','13','14','15','16','17','18','19','20',
'21','22','23','24','25','26','27','28','29','30','31');
if (this.monthLo == '00') {
currentMonth = '00';
} else {
currentMonth = MonthMenu.options[MonthMenu.selectedIndex].value;
}
// TODO: Use matching instead of '==' when 'DW_Month1' is replaced by
// TODO: this.entry_id + "_Month1"
if (MonthMenu.getAttribute('id') == 'DW_Month1') {
OtherYearMenu = this.Year2;
DayMenu = this.Day1;
currentYear = this.year1;
this.month1 = currentMonth;
if (this.year1 == this.year2 && this.month1 == this.month2 && this.day1 > this.day2) {
currentDay = this.day2;
this.flash(DayMenu);
} else {
currentDay = this.day1;
}
} else {
OtherYearMenu = this.Year1;
DayMenu = this.Day2;
currentYear = this.year2;
this.month2 = currentMonth;
if (this.year1 == this.year2 && this.month1 == this.month2 && this.day1 > this.day2) {
currentDay = this.day1;
this.flash(DayMenu);
} else {
currentDay = this.day2;
}
}
// Recreate the Day menu
var loDay = 1;
var hiDay = 31;
// Modify hiDay based on month
switch (currentMonth) {
case "02":
hiDay = this.febDays(currentYear); break;
case "04":
hiDay = 30; break;
case "06":
hiDay = 30; break;
case "09":
hiDay = 30; break;
case "11":
hiDay = 30; break;
default:
hiDay = 31; break;
}
// Recreate the Day menu
// If widget #1, range = yearLo-monthLo-dayLo:yearHi-monthHi-dayHi
// If widget #2, range = yearLo-monthLo-dayLo:yearHi-monthHi-dayHi
if (MonthMenu.getAttribute('id') == 'DW_Month1') {
if (currentYear == this.yearLo && currentMonth == this.monthLo) {
loDay = this.dayLo;
}
if (currentYear == this.yearHi && currentMonth == this.monthHi) {
hiDay = this.dayHi;
}
} else {
if (currentYear == this.yearLo && currentMonth == this.monthLo) {
loDay = this.dayLo;
}
if (currentYear == this.yearHi && currentMonth == this.monthHi) {
hiDay = this.dayHi;
}
}
// Create a new set of options and then select
// a day: current selection or nearest available
if (DayMenu) {
with (DayMenu) {
var n = hiDay - loDay + 1;
var d = loDay - 1;
options.length=0;
if (this.dayLo != '00') { // No days widget
for (i=0; i<n; i++) {
options[i]=new Option(dayVals[d],dayVals[d]);
//this.addEvent(options[i], 'click', this.optionClick, false);
d++;
}
if (currentDay < loDay || currentDay > hiDay) {
if (currentDay < loDay) {
options[0].selected = true;
} else {
var i = hiDay - loDay;
options[i].selected = true;
}
this.flash(DayMenu);
} else {
var i = currentDay - loDay;
options[i].selected = true;
}
}
}
DayMenu.onchange = this.selectChange;
this.selectDay(DayMenu);
} else {
//No Day-Time Menus
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
}
} |
JavaScript | function DateWidget_selectDay(DayMenu) {
var currentYear;
var currentMonth;
var currentDay;
var currentHour;
var TimeMenu;
var OtherYearMenu;
if (this.dayLo == '00') { // No days
currentDay = '00';
} else {
currentDay = DayMenu.options[DayMenu.selectedIndex].value;
}
// TODO: Use matching instead of '==' when 'DW_Day1' is replaced by
// TODO: this.entry_id + "_Month1"
if (DayMenu.getAttribute('id') == 'DW_Day1') {
this.day1 = currentDay;
TimeMenu = this.Time1;
OtherYearMenu = this.Year2;
currentYear = this.year1;
currentMonth = this.month1;
currentDay = this.day1;
/*
currentTime = (currentYear == this.year2 &&
currentMonth == this.month2 &&
currentDay == this.day2 &&
this.hour1 > this.hour2) ?
this.hour2 + ':' + this.minute2 :
this.hour1 + ':' + this.minute1;
*/
currentTime = this.hour1 + ':' + this.minute1;
} else {
this.day2 = currentDay;
TimeMenu = this.Time2;
OtherYearMenu = this.Year1;
currentYear = this.year2;
currentMonth = this.month2;
currentDay = this.day2;
/*
currentTime = (currentYear == this.year1 &&
currentMonth == this.month1 &&
currentDay == this.day1 &&
this.hour1 > this.hour2) ?
this.hour1 + ':' + this.minute1 :
this.hour2 + ':' + this.minute2;
*/
currentTime = this.hour2 + ':' + this.minute2;
}
var loMinute = this.offsetMinutes;
var hiMinute = 1440;
// NOTE: use Number() to prevent '60' + '60' = '6060'
if (currentYear == this.yearLo &&
currentMonth == this.monthLo &&
currentDay == this.dayLo) {
loMinute = Number(this.minuteLo) + Number(this.hourLo) * 60;
}
if (currentYear == this.yearHi &&
currentMonth == this.monthHi &&
currentDay == this.dayHi) {
hiMinute = Number(this.minuteHi) + Number(this.hourHi) * 60;
}
// Create hours menu
// TODO: Figure out why TimeMenu isn't working with nextDate()
if (TimeMenu) {
with (TimeMenu) {
var time='00:00';
var hr = Math.floor(loMinute/60);
var min = loMinute - hr * 60;
var minutes = loMinute;
var n = Math.floor((hiMinute-loMinute)/this.deltaMinutes) + 1;
for (i=0; i<n; i++) {
time = this.twoDigit(hr) + ":" + this.twoDigit(min);
options[i]=new Option(time,time);
//this.addEvent(options[i], 'click', this.optionClick, false);
// if (time == currentTime) { this line fails
var tmp = String(currentTime).split(":");
if(tmp[0]==hr && tmp[1]==min){
options[i].selected = true;
}
minutes = Number(minutes) + Number(this.deltaMinutes);
hr = Math.floor(minutes/60);
min = minutes - hr * 60;
if (hr >= 24) { break; }
}
}
TimeMenu.onchange = this.selectChange;
}
// Force update of other Years, Months & Days while avoiding an infinite loop
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
} | function DateWidget_selectDay(DayMenu) {
var currentYear;
var currentMonth;
var currentDay;
var currentHour;
var TimeMenu;
var OtherYearMenu;
if (this.dayLo == '00') { // No days
currentDay = '00';
} else {
currentDay = DayMenu.options[DayMenu.selectedIndex].value;
}
// TODO: Use matching instead of '==' when 'DW_Day1' is replaced by
// TODO: this.entry_id + "_Month1"
if (DayMenu.getAttribute('id') == 'DW_Day1') {
this.day1 = currentDay;
TimeMenu = this.Time1;
OtherYearMenu = this.Year2;
currentYear = this.year1;
currentMonth = this.month1;
currentDay = this.day1;
/*
currentTime = (currentYear == this.year2 &&
currentMonth == this.month2 &&
currentDay == this.day2 &&
this.hour1 > this.hour2) ?
this.hour2 + ':' + this.minute2 :
this.hour1 + ':' + this.minute1;
*/
currentTime = this.hour1 + ':' + this.minute1;
} else {
this.day2 = currentDay;
TimeMenu = this.Time2;
OtherYearMenu = this.Year1;
currentYear = this.year2;
currentMonth = this.month2;
currentDay = this.day2;
/*
currentTime = (currentYear == this.year1 &&
currentMonth == this.month1 &&
currentDay == this.day1 &&
this.hour1 > this.hour2) ?
this.hour1 + ':' + this.minute1 :
this.hour2 + ':' + this.minute2;
*/
currentTime = this.hour2 + ':' + this.minute2;
}
var loMinute = this.offsetMinutes;
var hiMinute = 1440;
// NOTE: use Number() to prevent '60' + '60' = '6060'
if (currentYear == this.yearLo &&
currentMonth == this.monthLo &&
currentDay == this.dayLo) {
loMinute = Number(this.minuteLo) + Number(this.hourLo) * 60;
}
if (currentYear == this.yearHi &&
currentMonth == this.monthHi &&
currentDay == this.dayHi) {
hiMinute = Number(this.minuteHi) + Number(this.hourHi) * 60;
}
// Create hours menu
// TODO: Figure out why TimeMenu isn't working with nextDate()
if (TimeMenu) {
with (TimeMenu) {
var time='00:00';
var hr = Math.floor(loMinute/60);
var min = loMinute - hr * 60;
var minutes = loMinute;
var n = Math.floor((hiMinute-loMinute)/this.deltaMinutes) + 1;
for (i=0; i<n; i++) {
time = this.twoDigit(hr) + ":" + this.twoDigit(min);
options[i]=new Option(time,time);
//this.addEvent(options[i], 'click', this.optionClick, false);
// if (time == currentTime) { this line fails
var tmp = String(currentTime).split(":");
if(tmp[0]==hr && tmp[1]==min){
options[i].selected = true;
}
minutes = Number(minutes) + Number(this.deltaMinutes);
hr = Math.floor(minutes/60);
min = minutes - hr * 60;
if (hr >= 24) { break; }
}
}
TimeMenu.onchange = this.selectChange;
}
// Force update of other Years, Months & Days while avoiding an infinite loop
if (this.internallyForced) {
this.internallyForced = 0;
} else {
if (OtherYearMenu) {
if (!this.correctOrder()) {
this.internallyForced = 1;
this.initializeYearMenu(OtherYearMenu);
}
}
}
} |
JavaScript | function DateWidget_selectTime(TimeMenu) {
var time = TimeMenu.options[TimeMenu.selectedIndex].value;
var Time = String(time).split(':');
// TODO: Use matching instead of '==' when 'DW_Time1' is replaced by
// TODO: this.entry_id + "_Time1"
if (TimeMenu.getAttribute('id') == 'DW_Time1') {
this.hour1 = Time[0];
this.minute1 = Time[1];
} else {
this.hour2 = Time[0];
this.minute2 = Time[1];
}
} | function DateWidget_selectTime(TimeMenu) {
var time = TimeMenu.options[TimeMenu.selectedIndex].value;
var Time = String(time).split(':');
// TODO: Use matching instead of '==' when 'DW_Time1' is replaced by
// TODO: this.entry_id + "_Time1"
if (TimeMenu.getAttribute('id') == 'DW_Time1') {
this.hour1 = Time[0];
this.minute1 = Time[1];
} else {
this.hour2 = Time[0];
this.minute2 = Time[1];
}
} |
JavaScript | function LASGrid(response) {
/**
* LAS Grid object obtained from the Velocity template.
*/
this.response = response;
// Add methods to this object
this.hasAxis = LASGrid_hasAxis;
this.hasArange = LASGrid_hasArange;
this.hasMenu = LASGrid_hasMenu;
this.getAxis = LASGrid_getAxis;
this.getLo = LASGrid_getLo;
this.getHi = LASGrid_getHi;
this.getDelta = LASGrid_getDelta;
this.getSize = LASGrid_getSize;
this.getUnits = LASGrid_getUnits;
this.getID = LASGrid_getID;
this.getDisplayType = LASGrid_getDisplayType;
this.getRenderFormat = LASGrid_getRenderFormat;
this.getMenu = LASGrid_getMenu;
// Check for incomplete LASGrid.
if (response == null) {
var error_string = 'The LASGrid is empty';
throw(error_string);
}
} | function LASGrid(response) {
/**
* LAS Grid object obtained from the Velocity template.
*/
this.response = response;
// Add methods to this object
this.hasAxis = LASGrid_hasAxis;
this.hasArange = LASGrid_hasArange;
this.hasMenu = LASGrid_hasMenu;
this.getAxis = LASGrid_getAxis;
this.getLo = LASGrid_getLo;
this.getHi = LASGrid_getHi;
this.getDelta = LASGrid_getDelta;
this.getSize = LASGrid_getSize;
this.getUnits = LASGrid_getUnits;
this.getID = LASGrid_getID;
this.getDisplayType = LASGrid_getDisplayType;
this.getRenderFormat = LASGrid_getRenderFormat;
this.getMenu = LASGrid_getMenu;
// Check for incomplete LASGrid.
if (response == null) {
var error_string = 'The LASGrid is empty';
throw(error_string);
}
} |
JavaScript | function LASGrid_getAxis(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
for (var i=0;i<this.response.grid.axis.length; i++) {
if(this.response.grid.axis[i].type==axis_lc)
value = this.response.grid.axis[i];
}
return value;
} | function LASGrid_getAxis(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
for (var i=0;i<this.response.grid.axis.length; i++) {
if(this.response.grid.axis[i].type==axis_lc)
value = this.response.grid.axis[i];
}
return value;
} |
JavaScript | function LASGrid_hasAxis(axis) {
var axis_lc = String(axis).toLowerCase();
var value = false;
if (this.getAxis(axis_lc)) {
value = true;
}
return value;
} | function LASGrid_hasAxis(axis) {
var axis_lc = String(axis).toLowerCase();
var value = false;
if (this.getAxis(axis_lc)) {
value = true;
}
return value;
} |
JavaScript | function LASGrid_hasArange(axis) {
var axis_lc = String(axis).toLowerCase();
var value = false;
if(this.hasAxis(axis_lc)) {
if (this.getAxis(axis_lc).arange) {
value = true;
}
}
return value;
} | function LASGrid_hasArange(axis) {
var axis_lc = String(axis).toLowerCase();
var value = false;
if(this.hasAxis(axis_lc)) {
if (this.getAxis(axis_lc).arange) {
value = true;
}
}
return value;
} |
JavaScript | function LASGrid_getLo(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
value = this.getAxis(axis_lc).v[0];
} else { // <arange ...>
value = this.getAxis(axis_lc).arange.start;
}
}
return value;
} | function LASGrid_getLo(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).lo;
} else {
if (this.hasMenu(axis)) { // <v> array
value = this.getAxis(axis_lc).v[0];
} else { // <arange ...>
value = this.getAxis(axis_lc).arange.start;
}
}
return value;
} |
JavaScript | function LASGrid_getHi(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).hi;
} else {
if (this.hasMenu(axis)) { // <v> array
var index = this.getAxis(axis_lc).v.length - 1;
value = this.getAxis(axis_lc).v[index];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
value = start + (size-1) * step;
}
}
return value;
} | function LASGrid_getHi(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (axis_lc == 't') {
value = this.getAxis(axis_lc).hi;
} else {
if (this.hasMenu(axis)) { // <v> array
var index = this.getAxis(axis_lc).v.length - 1;
value = this.getAxis(axis_lc).v[index];
} else { // <arange ...>
var start = Number(this.getAxis(axis_lc).arange.start);
var size = Number(this.getAxis(axis_lc).arange.size);
var step = Number(this.getAxis(axis_lc).arange.step);
value = start + (size-1) * step;
}
}
return value;
} |
JavaScript | function LASGrid_getDelta(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.step;
}
return Number(value);
} | function LASGrid_getDelta(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.step;
}
return Number(value);
} |
JavaScript | function LASGrid_getSize(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.size;
} else {
if (this.hasMenu(axis)) {
value = this.getAxis(axis_lc).v.length;
}
}
return Number(value);
} | function LASGrid_getSize(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasArange(axis_lc)) {
value = this.getAxis(axis_lc).arange.size;
} else {
if (this.hasMenu(axis)) {
value = this.getAxis(axis_lc).v.length;
}
}
return Number(value);
} |
JavaScript | function LASGrid_getUnits(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).units;
}
return value;
} | function LASGrid_getUnits(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).units;
}
return value;
} |
JavaScript | function LASGrid_getID(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).display_type;
}
return value;
} | function LASGrid_getID(axis) {
var value = null;
var axis_lc = String(axis).toLowerCase();
if (this.hasAxis(axis_lc)) {
value = this.getAxis(axis_lc).display_type;
}
return value;
} |
JavaScript | function LASGrid_getDisplayType(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasAxis(axis)) {
if (this.getAxis(axis_lc).display_type) {
value = this.getAxis(axis_lc).display_type;
}
}
return value;
} | function LASGrid_getDisplayType(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
if (this.hasAxis(axis)) {
if (this.getAxis(axis_lc).display_type) {
value = this.getAxis(axis_lc).display_type;
}
}
return value;
} |
JavaScript | function LASGrid_getRenderFormat(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
switch (axis_lc) {
case 't':
value = "";
if (this.getAxis('t').yearNeeded == 'true') { value += "Y"; }
if (this.getAxis('t').monthNeeded == 'true') { value += "M"; }
if (this.getAxis('t').dayNeeded == 'true') { value += "D"; }
if (this.getAxis('t').hourNeeded == 'true') { value += "T"; }
break;
}
return value;
} | function LASGrid_getRenderFormat(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
switch (axis_lc) {
case 't':
value = "";
if (this.getAxis('t').yearNeeded == 'true') { value += "Y"; }
if (this.getAxis('t').monthNeeded == 'true') { value += "M"; }
if (this.getAxis('t').dayNeeded == 'true') { value += "D"; }
if (this.getAxis('t').hourNeeded == 'true') { value += "T"; }
break;
}
return value;
} |
JavaScript | function LASGrid_getMenu(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
var menu = null;
if (this.getAxis(axis_lc).v) {
value = new Array;
menu = this.getAxis(axis_lc).v;
// NOTE: The <v> object of the response looks like this:
// NOTE: "v":[
// NOTE: {"label1":"content1"},
// NOTE: {"label2":"content2"},
// NOTE: ...
// NOTE: {"labelN":"contentN"}],
for (var i=0; i<menu.length; i++) {
if (axis_lc == 't') {
//TODO: Remove this hack after resolution of trac ticket #147.
var month_name = String(menu[i].content).toLowerCase();
if (month_name == 'jan') { menu[i].content = '15-Jan'; }
if (month_name == 'feb') { menu[i].content = '15-Feb'; }
if (month_name == 'mar') { menu[i].content = '15-Mar'; }
if (month_name == 'apr') { menu[i].content = '15-Apr'; }
if (month_name == 'may') { menu[i].content = '15-May'; }
if (month_name == 'jun') { menu[i].content = '15-Jun'; }
if (month_name == 'jul') { menu[i].content = '15-Jul'; }
if (month_name == 'aug') { menu[i].content = '15-Aug'; }
if (month_name == 'sep') { menu[i].content = '15-Sep'; }
if (month_name == 'oct') { menu[i].content = '15-Oct'; }
if (month_name == 'nov') { menu[i].content = '15-Nov'; }
if (month_name == 'dec') { menu[i].content = '15-Dec'; }
value[i] = new Array(menu[i].label,menu[i].content);
} else {
value[i] = new Array(menu[i],menu[i]);
}
}
}
return value;
} | function LASGrid_getMenu(axis) {
var axis_lc = String(axis).toLowerCase();
var value = null;
var menu = null;
if (this.getAxis(axis_lc).v) {
value = new Array;
menu = this.getAxis(axis_lc).v;
// NOTE: The <v> object of the response looks like this:
// NOTE: "v":[
// NOTE: {"label1":"content1"},
// NOTE: {"label2":"content2"},
// NOTE: ...
// NOTE: {"labelN":"contentN"}],
for (var i=0; i<menu.length; i++) {
if (axis_lc == 't') {
//TODO: Remove this hack after resolution of trac ticket #147.
var month_name = String(menu[i].content).toLowerCase();
if (month_name == 'jan') { menu[i].content = '15-Jan'; }
if (month_name == 'feb') { menu[i].content = '15-Feb'; }
if (month_name == 'mar') { menu[i].content = '15-Mar'; }
if (month_name == 'apr') { menu[i].content = '15-Apr'; }
if (month_name == 'may') { menu[i].content = '15-May'; }
if (month_name == 'jun') { menu[i].content = '15-Jun'; }
if (month_name == 'jul') { menu[i].content = '15-Jul'; }
if (month_name == 'aug') { menu[i].content = '15-Aug'; }
if (month_name == 'sep') { menu[i].content = '15-Sep'; }
if (month_name == 'oct') { menu[i].content = '15-Oct'; }
if (month_name == 'nov') { menu[i].content = '15-Nov'; }
if (month_name == 'dec') { menu[i].content = '15-Dec'; }
value[i] = new Array(menu[i].label,menu[i].content);
} else {
value[i] = new Array(menu[i],menu[i]);
}
}
}
return value;
} |
JavaScript | function LongitudeWidget(lo, hi, delta) {
// Public methods
this.render = LongitudeWidget_render;
this.disable = LongitudeWidget_disable;
this.enable = LongitudeWidget_enable;
this.show = LongitudeWidget_show;
this.hide = LongitudeWidget_hide;
this.getSelectedIndex = LongitudeWidget_getSelectedIndex;
this.getValue = LongitudeWidget_getValue;
this.getValues = LongitudeWidget_getValues;
this.setCallback = LongitudeWidget_setCallback;
this.setValue = LongitudeWidget_setValue;
this.setValueByIndex = LongitudeWidget_setValueByIndex;
// Event handlers
this.selectChange = LongitudeWidget_selectChange;
// Initialization
/**
* Lowest value displayed in the Select menu.
*/
this.lo = Number(lo);
/**
* Highest value displayed in the Select menu.
*/
this.hi = Number(hi);
/**
* Spacing beteen Select options (decimal degrees)
*/
this.delta = Number(delta);
/**
* Number of Options in the Select menu.
*/
this.length = 0;
/**
* Select object type ['select-one' | 'select-multiple'] (currently only 'select-one' is supported)
*/
this.type = 'select-one';
/**
* ID string identifying this widget.
*/
this.widgetType = 'LongitudeWidget';
/**
* Specifies whether this widget is currently disabled.
*/
this.disabled = 0;
/**
* Specifies whether this widget is currently visible.
*/
this.visible = 0;
/**
* Callback function attached to the onChange event.
*/
this.callback = null;
} | function LongitudeWidget(lo, hi, delta) {
// Public methods
this.render = LongitudeWidget_render;
this.disable = LongitudeWidget_disable;
this.enable = LongitudeWidget_enable;
this.show = LongitudeWidget_show;
this.hide = LongitudeWidget_hide;
this.getSelectedIndex = LongitudeWidget_getSelectedIndex;
this.getValue = LongitudeWidget_getValue;
this.getValues = LongitudeWidget_getValues;
this.setCallback = LongitudeWidget_setCallback;
this.setValue = LongitudeWidget_setValue;
this.setValueByIndex = LongitudeWidget_setValueByIndex;
// Event handlers
this.selectChange = LongitudeWidget_selectChange;
// Initialization
/**
* Lowest value displayed in the Select menu.
*/
this.lo = Number(lo);
/**
* Highest value displayed in the Select menu.
*/
this.hi = Number(hi);
/**
* Spacing beteen Select options (decimal degrees)
*/
this.delta = Number(delta);
/**
* Number of Options in the Select menu.
*/
this.length = 0;
/**
* Select object type ['select-one' | 'select-multiple'] (currently only 'select-one' is supported)
*/
this.type = 'select-one';
/**
* ID string identifying this widget.
*/
this.widgetType = 'LongitudeWidget';
/**
* Specifies whether this widget is currently disabled.
*/
this.disabled = 0;
/**
* Specifies whether this widget is currently visible.
*/
this.visible = 0;
/**
* Callback function attached to the onChange event.
*/
this.callback = null;
} |
JavaScript | function LongitudeWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
//TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
// NOTE: Deal with dateline crossing
var lo = this.lo;
var hi = this.hi;
var delta = this.delta;
if (hi < lo) {
hi += 360;
}
var length = (hi - lo) / delta + 1;
var value = lo - delta;
var text = "";
for (var i=0; i<length; i++) {
value += delta;
// NOTE: Deal with dateline crossing
if (value > 180) {
value -= 360;
}
if (value < 0) {
text = Math.abs(value).toString() + ' W';
} else {
text = Math.abs(value).toString() + ' E';
}
Select.options[i]=new Option(text, value);
}
Select.selectedIndex = 0;
Select.options[0].selected = true;
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
// Store the pointer to the Select object inside the LongitudeWidget object
this.Select = Select;
this.length = this.Select.length;
} | function LongitudeWidget_render(element_id,type) {
this.element_id = element_id;
if (type) { this.type = type; }
var node = document.getElementById(this.element_id);
var children = node.childNodes;
var num_children = children.length;
// Remove any children of this widget
// NOTE: Start removing children from the end. Otherwise, what was
// NOTE: children[1] becomes children[0] when children[0] is removed.
for (var i=num_children-1; i>=0; i--) {
var child = children[i];
if (child) {
node.removeChild(child);
}
}
// Create and populate the Select object
var id_text = this.element_id + '_Select';
var Select = document.createElement('select');
Select.setAttribute('id',id_text);
//TODO: deal with setting the 'type'
// NOTE: IE doesn't support the setAttribute() method for the 'type' attribute
// NOTE: We just remove this capability for now (defaults to 'select-one'
//Select.setAttribute('type', this.type);
Select.setAttribute('name', id_text);
// NOTE: Deal with dateline crossing
var lo = this.lo;
var hi = this.hi;
var delta = this.delta;
if (hi < lo) {
hi += 360;
}
var length = (hi - lo) / delta + 1;
var value = lo - delta;
var text = "";
for (var i=0; i<length; i++) {
value += delta;
// NOTE: Deal with dateline crossing
if (value > 180) {
value -= 360;
}
if (value < 0) {
text = Math.abs(value).toString() + ' W';
} else {
text = Math.abs(value).toString() + ' E';
}
Select.options[i]=new Option(text, value);
}
Select.selectedIndex = 0;
Select.options[0].selected = true;
Select.widget = this;
Select.onchange = this.selectChange;
node.appendChild(Select);
// Store the pointer to the Select object inside the LongitudeWidget object
this.Select = Select;
this.length = this.Select.length;
} |
JavaScript | function LongitudeWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} | function LongitudeWidget_show() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'visible';
this.visible = 1;
} |
JavaScript | function LongitudeWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} | function LongitudeWidget_hide() {
var node = document.getElementById(this.element_id);
node.style.visibility = 'hidden';
this.visible = 0;
} |
JavaScript | function LongitudeWidget_setValue(lon) {
var internal_lon = Number(lon)%360;
internal_lon = (internal_lon >= 0) ? internal_lon : internal_lon+360;
var i = 0;
while (i <= this.Select.length) {
var option_val = Number(this.Select.options[i].value);
option_val = (option_val >= 0) ? option_val : option_val+360;
if (internal_lon <= option_val) {
this.Select.selectedIndex = i;
this.Select.options[i].selected = true;
return;
// TODO: include logic to find closest match if lon is in between option_vals
}
i++;
}
} | function LongitudeWidget_setValue(lon) {
var internal_lon = Number(lon)%360;
internal_lon = (internal_lon >= 0) ? internal_lon : internal_lon+360;
var i = 0;
while (i <= this.Select.length) {
var option_val = Number(this.Select.options[i].value);
option_val = (option_val >= 0) ? option_val : option_val+360;
if (internal_lon <= option_val) {
this.Select.selectedIndex = i;
this.Select.options[i].selected = true;
return;
// TODO: include logic to find closest match if lon is in between option_vals
}
i++;
}
} |
JavaScript | function LongitudeWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('LongitudeWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('LongitudeWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the LongitudeWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} | function LongitudeWidget_selectChange(e) {
// Cross-browser discovery of the event target
// By Stuart Landridge in "DHTML Utopia ..."
var target;
if (window.event && window.event.srcElement) {
target = window.event.srcElement;
} else if (e && e.target) {
target = e.target;
} else {
alert('LongitudeWidget ERROR:\n> selectChange: This browser does not support standard javascript events.');
return;
}
if (target.nodeName.toLowerCase() != 'select') {
alert('LongitudeWidget ERROR:\n> selectChange: event target [' + target.nodeName.toLowerCase() + '] should instead be [select]');
return;
}
// NOTE: I believe that this function is evaluated outside the context of the LongitudeWidget.
// NOTE: Hence the need to extract the Widget from the Select object.
var MW = target.widget;
if (MW.callback) {
MW.callback(MW);
}
} |
JavaScript | function SearchController($scope) {
// initially the search params consist of an empty array
$scope.searchParams = [];
// if the search result object is already defined by a parent scope
// (e.g. ModuleController) we share it, else we create a new one
$scope.searchResult = $scope.searchResult || new SearchResult();
// handle a click on the '+' button to add filter
$scope.addSearchParam = function() {
var newFilter = { filter: $scope.searchFilters[0].value };
$scope.searchParams.push(newFilter);
}
// handle a click on the '-' button to remove a filter
$scope.removeSearchParam = function(index) {
$scope.searchParams.splice(index, 1);
}
// handle a click on the 'search' button
$scope.search = function() {
civilian.request($scope, $scope.module.searchPath).
data($scope.searchParams).
post().
then(function(result) {
$scope.searchResult.init(result.data);
});
}
// handle a click on the 'reset' button
$scope.reset = function() {
$scope.searchResult.clear();
$scope.searchParams = [];
$scope.addSearchParam();
}
// load search filters: add extension 'filter' to invoke the correct server-side method
// we also cache the response since the filter definition will not change
var filterPath = $scope.module.searchPath.append('filter');
civilian.request($scope, $scope.module.searchFilterPath).
cache(true).
get().
then(function() {
// the response has initialized the searchFilter variable
// now that we have the filter definitions, add a first parameter
if ($scope.searchFilters)
$scope.addSearchParam();
});
} | function SearchController($scope) {
// initially the search params consist of an empty array
$scope.searchParams = [];
// if the search result object is already defined by a parent scope
// (e.g. ModuleController) we share it, else we create a new one
$scope.searchResult = $scope.searchResult || new SearchResult();
// handle a click on the '+' button to add filter
$scope.addSearchParam = function() {
var newFilter = { filter: $scope.searchFilters[0].value };
$scope.searchParams.push(newFilter);
}
// handle a click on the '-' button to remove a filter
$scope.removeSearchParam = function(index) {
$scope.searchParams.splice(index, 1);
}
// handle a click on the 'search' button
$scope.search = function() {
civilian.request($scope, $scope.module.searchPath).
data($scope.searchParams).
post().
then(function(result) {
$scope.searchResult.init(result.data);
});
}
// handle a click on the 'reset' button
$scope.reset = function() {
$scope.searchResult.clear();
$scope.searchParams = [];
$scope.addSearchParam();
}
// load search filters: add extension 'filter' to invoke the correct server-side method
// we also cache the response since the filter definition will not change
var filterPath = $scope.module.searchPath.append('filter');
civilian.request($scope, $scope.module.searchFilterPath).
cache(true).
get().
then(function() {
// the response has initialized the searchFilter variable
// now that we have the filter definitions, add a first parameter
if ($scope.searchFilters)
$scope.addSearchParam();
});
} |
JavaScript | function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return 'in ' + (minutes == 0 ? '' : (minutes + ' min ')) + seconds + ' sec';
} | function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return 'in ' + (minutes == 0 ? '' : (minutes + ' min ')) + seconds + ' sec';
} |
JavaScript | function execShellCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
let errorMsg = 'TIME: ' + (new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000))).toISOString() + '\n';
errorMsg += 'ERROR: ' + error;
errorMsg += 'STDOUT: ' + stdout + (stdout? '' : '\n');
errorMsg += 'STDERR: ' + stderr + (stderr? '' : '\n');
errorMsg += '----------------------------------------------------------------------------------------------------\n';
if(!(cmd.includes('az functionapp deployment source config-zip') && error.toString().includes("Operation failed with status: 'Bad Request'."))) {
console.error(errorMsg);
fs.appendFileSync('./error.log', errorMsg);
}
reject();
}
resolve(stdout? stdout : stderr);
});
});
} | function execShellCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
let errorMsg = 'TIME: ' + (new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000))).toISOString() + '\n';
errorMsg += 'ERROR: ' + error;
errorMsg += 'STDOUT: ' + stdout + (stdout? '' : '\n');
errorMsg += 'STDERR: ' + stderr + (stderr? '' : '\n');
errorMsg += '----------------------------------------------------------------------------------------------------\n';
if(!(cmd.includes('az functionapp deployment source config-zip') && error.toString().includes("Operation failed with status: 'Bad Request'."))) {
console.error(errorMsg);
fs.appendFileSync('./error.log', errorMsg);
}
reject();
}
resolve(stdout? stdout : stderr);
});
});
} |
JavaScript | async function deployAzure(params, func, funcFirstUpperCase, testName) {
return new Promise(async (resolve, reject) => {
let start = now();
currentLogStatusAzure += '<h5>Microsoft Azure (Linux, parallel deployment)</h5>';
currentLogStatusAzure += '<ul stlye="list-style-position: outside">';
currentLogStatusAzureEnd += '</ul>';
runningStatusAzure = true;
var promises = [];
if(params.node == 'true') {
let p = deployFunction(constants.AZURE, constants.NODE, func, 'node-' + func, '', '', 'node', '10', '', '/azure/src/node/node_' + func, 'Node.js', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.python == 'true') {
let p = deployFunction(constants.AZURE, constants.PYTHON, func, 'python-' + func, '', '', 'python', '3.7', '', '/azure/src/python/python_' + func, 'Python', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.go == 'true') {
currentLogStatusAzure += '<li><span style="color:orange">SKIP:</span> No Go runtime</li>';
}
if(params.dotnet == 'true') {
let p = deployFunction(constants.AZURE, constants.DOTNET, func, 'dotnet-' + func, '', '', 'dotnet', '2', '', '/azure/src/dotnet/dotnet_' + func, '.NET', '', '', params.ram, params.timeout);
promises.push(p);
}
await Promise.all(promises);
let end = now();
currentLogStatusAzure += 'Completed ' + millisToMinutesAndSeconds((end-start).toFixed(3));
runningStatusAzure = false;
resolve();
});
} | async function deployAzure(params, func, funcFirstUpperCase, testName) {
return new Promise(async (resolve, reject) => {
let start = now();
currentLogStatusAzure += '<h5>Microsoft Azure (Linux, parallel deployment)</h5>';
currentLogStatusAzure += '<ul stlye="list-style-position: outside">';
currentLogStatusAzureEnd += '</ul>';
runningStatusAzure = true;
var promises = [];
if(params.node == 'true') {
let p = deployFunction(constants.AZURE, constants.NODE, func, 'node-' + func, '', '', 'node', '10', '', '/azure/src/node/node_' + func, 'Node.js', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.python == 'true') {
let p = deployFunction(constants.AZURE, constants.PYTHON, func, 'python-' + func, '', '', 'python', '3.7', '', '/azure/src/python/python_' + func, 'Python', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.go == 'true') {
currentLogStatusAzure += '<li><span style="color:orange">SKIP:</span> No Go runtime</li>';
}
if(params.dotnet == 'true') {
let p = deployFunction(constants.AZURE, constants.DOTNET, func, 'dotnet-' + func, '', '', 'dotnet', '2', '', '/azure/src/dotnet/dotnet_' + func, '.NET', '', '', params.ram, params.timeout);
promises.push(p);
}
await Promise.all(promises);
let end = now();
currentLogStatusAzure += 'Completed ' + millisToMinutesAndSeconds((end-start).toFixed(3));
runningStatusAzure = false;
resolve();
});
} |
JavaScript | async function deployAzureWindows(params, func, funcFirstUpperCase, testName) {
return new Promise(async (resolve, reject) => {
let start = now();
currentLogStatusAzureWindows += '<h5>Microsoft Azure (Windows, parallel deployment)</h5>';
currentLogStatusAzureWindows += '<ul stlye="list-style-position: outside">';
currentLogStatusAzureWindowsEnd += '</ul>';
runningStatusAzureWindows = true;
var promises = [];
if(params.node == 'true') {
let p = deployFunction(constants.AZUREWINDOWS, constants.NODE, func, 'node-' + func, '', '', 'node', '10', '', '/azure/src/node/node_' + func, 'Node.js', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.python == 'true') {
currentLogStatusAzureWindows += '<li><span style="color:orange">SKIP:</span> No Python runtime</li>';
}
if(params.go == 'true') {
currentLogStatusAzureWindows += '<li><span style="color:orange">SKIP:</span> No Go runtime</li>';
}
if(params.dotnet == 'true') {
let p = deployFunction(constants.AZUREWINDOWS, constants.DOTNET, func, 'dotnet-' + func, '', '', 'dotnet', '2', '', '/azure/src/dotnet/dotnet_' + func, '.NET', '', '', params.ram, params.timeout);
promises.push(p);
}
await Promise.all(promises);
let end = now();
currentLogStatusAzureWindows += 'Completed ' + millisToMinutesAndSeconds((end-start).toFixed(3));
runningStatusAzureWindows = false;
resolve();
});
} | async function deployAzureWindows(params, func, funcFirstUpperCase, testName) {
return new Promise(async (resolve, reject) => {
let start = now();
currentLogStatusAzureWindows += '<h5>Microsoft Azure (Windows, parallel deployment)</h5>';
currentLogStatusAzureWindows += '<ul stlye="list-style-position: outside">';
currentLogStatusAzureWindowsEnd += '</ul>';
runningStatusAzureWindows = true;
var promises = [];
if(params.node == 'true') {
let p = deployFunction(constants.AZUREWINDOWS, constants.NODE, func, 'node-' + func, '', '', 'node', '10', '', '/azure/src/node/node_' + func, 'Node.js', '', '', params.ram, params.timeout);
promises.push(p);
}
if(params.python == 'true') {
currentLogStatusAzureWindows += '<li><span style="color:orange">SKIP:</span> No Python runtime</li>';
}
if(params.go == 'true') {
currentLogStatusAzureWindows += '<li><span style="color:orange">SKIP:</span> No Go runtime</li>';
}
if(params.dotnet == 'true') {
let p = deployFunction(constants.AZUREWINDOWS, constants.DOTNET, func, 'dotnet-' + func, '', '', 'dotnet', '2', '', '/azure/src/dotnet/dotnet_' + func, '.NET', '', '', params.ram, params.timeout);
promises.push(p);
}
await Promise.all(promises);
let end = now();
currentLogStatusAzureWindows += 'Completed ' + millisToMinutesAndSeconds((end-start).toFixed(3));
runningStatusAzureWindows = false;
resolve();
});
} |
JavaScript | async function cleanup() {
testingModule.resetURLs();
currentLogStatus += '<h4>Cleaning Up...</h4>';
var promises = [];
let p1 = cleanupAWS();
promises.push(p1);
let p2 = cleanupAzure();
promises.push(p2);
let p3 = cleanupGoogle();
promises.push(p3);
let p4 = cleanupIBM();
promises.push(p4);
await Promise.all(promises);
currentLogStatusEnd += '<h4>Cleanup finished</h4>';
runningStatus = false;
} | async function cleanup() {
testingModule.resetURLs();
currentLogStatus += '<h4>Cleaning Up...</h4>';
var promises = [];
let p1 = cleanupAWS();
promises.push(p1);
let p2 = cleanupAzure();
promises.push(p2);
let p3 = cleanupGoogle();
promises.push(p3);
let p4 = cleanupIBM();
promises.push(p4);
await Promise.all(promises);
currentLogStatusEnd += '<h4>Cleanup finished</h4>';
runningStatus = false;
} |
JavaScript | function execShellCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
let errorMsg = 'TIME: ' + (new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000))).toISOString() + '\n';
errorMsg += 'ERROR: ' + error;
errorMsg += 'STDOUT: ' + stdout + (stdout? '' : '\n');
errorMsg += 'STDERR: ' + stderr + (stderr? '' : '\n');
errorMsg += '----------------------------------------------------------------------------------------------------\n';
reject(errorMsg);
}
resolve(stdout? stdout : stderr);
});
});
} | function execShellCommand(cmd) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
if (error) {
let errorMsg = 'TIME: ' + (new Date(Date.now() - ((new Date()).getTimezoneOffset() * 60000))).toISOString() + '\n';
errorMsg += 'ERROR: ' + error;
errorMsg += 'STDOUT: ' + stdout + (stdout? '' : '\n');
errorMsg += 'STDERR: ' + stderr + (stderr? '' : '\n');
errorMsg += '----------------------------------------------------------------------------------------------------\n';
reject(errorMsg);
}
resolve(stdout? stdout : stderr);
});
});
} |
JavaScript | update() {
let sortedItems = this.get('sortedItems');
// Position of the first element
let position = this._itemPosition;
// Just in case we haven’t called prepare first.
if (position === undefined) {
position = this.get('itemPosition');
}
sortedItems.forEach(item => {
let dimension;
let direction = this.get('direction');
if (!get(item, 'isDragging')) {
set(item, direction, position);
}
// add additional spacing around active element
if (get(item, 'isBusy')) {
position += get(item, 'spacing') * 2;
}
if (direction === 'x') {
dimension = 'width';
}
if (direction === 'y') {
dimension = 'height';
}
position += get(item, dimension);
});
} | update() {
let sortedItems = this.get('sortedItems');
// Position of the first element
let position = this._itemPosition;
// Just in case we haven’t called prepare first.
if (position === undefined) {
position = this.get('itemPosition');
}
sortedItems.forEach(item => {
let dimension;
let direction = this.get('direction');
if (!get(item, 'isDragging')) {
set(item, direction, position);
}
// add additional spacing around active element
if (get(item, 'isBusy')) {
position += get(item, 'spacing') * 2;
}
if (direction === 'x') {
dimension = 'width';
}
if (direction === 'y') {
dimension = 'height';
}
position += get(item, dimension);
});
} |
JavaScript | commit() {
let items = this.get('sortedItems');
let groupModel = this.get('model');
let itemModels = items.mapBy('model');
let draggedItem = items.findBy('wasDropped', true);
let draggedModel;
if (draggedItem) {
set(draggedItem, 'wasDropped', false); // Reset
draggedModel = get(draggedItem, 'model');
}
delete this._itemPosition;
run.schedule('render', () => {
items.invoke('freeze');
});
run.schedule('afterRender', () => {
items.invoke('reset');
});
run.next(() => {
run.schedule('render', () => {
items.invoke('thaw');
});
});
if (groupModel !== NO_MODEL) {
invokeAction(this, 'onChange', groupModel, itemModels, draggedModel);
} else {
invokeAction(this, 'onChange', itemModels, draggedModel);
}
} | commit() {
let items = this.get('sortedItems');
let groupModel = this.get('model');
let itemModels = items.mapBy('model');
let draggedItem = items.findBy('wasDropped', true);
let draggedModel;
if (draggedItem) {
set(draggedItem, 'wasDropped', false); // Reset
draggedModel = get(draggedItem, 'model');
}
delete this._itemPosition;
run.schedule('render', () => {
items.invoke('freeze');
});
run.schedule('afterRender', () => {
items.invoke('reset');
});
run.next(() => {
run.schedule('render', () => {
items.invoke('thaw');
});
});
if (groupModel !== NO_MODEL) {
invokeAction(this, 'onChange', groupModel, itemModels, draggedModel);
} else {
invokeAction(this, 'onChange', itemModels, draggedModel);
}
} |
JavaScript | freeze() {
let el = this.$();
if (!el) { return; }
el.css({ transition: 'none' });
el.height(); // Force-apply styles
} | freeze() {
let el = this.$();
if (!el) { return; }
el.css({ transition: 'none' });
el.height(); // Force-apply styles
} |
JavaScript | reset() {
let el = this.$();
if (!el) { return; }
delete this._y;
delete this._x;
el.css({ transform: '' });
el.height(); // Force-apply styles
} | reset() {
let el = this.$();
if (!el) { return; }
delete this._y;
delete this._x;
el.css({ transform: '' });
el.height(); // Force-apply styles
} |
JavaScript | _primeDrag(startEvent) {
let handle = this.get('handle');
if (handle && !$(startEvent.target).closest(handle).length) {
return;
}
this._prepareDragListener = bind(this, this._prepareDrag, startEvent);
this._cancelStartDragListener = () => {
$(window).off('mousemove touchmove', this._prepareDragListener);
};
$(window).on('mousemove touchmove', this._prepareDragListener);
$(window).one('click mouseup touchend', this._cancelStartDragListener);
} | _primeDrag(startEvent) {
let handle = this.get('handle');
if (handle && !$(startEvent.target).closest(handle).length) {
return;
}
this._prepareDragListener = bind(this, this._prepareDrag, startEvent);
this._cancelStartDragListener = () => {
$(window).off('mousemove touchmove', this._prepareDragListener);
};
$(window).on('mousemove touchmove', this._prepareDragListener);
$(window).one('click mouseup touchend', this._cancelStartDragListener);
} |
JavaScript | _scrollOnEdges(drag) {
let groupDirection = this.get('group.direction');
let $element = this.$();
let scrollContainer = new ScrollContainer(scrollParent($element)[0]);
let itemContainer = {
width: $element.width(),
height: $element.height(),
get left() {
return $element.offset().left;
},
get right() {
return this.left + this.width;
},
get top() {
return $element.offset().top;
},
get bottom() {
return this.top + this.height;
}
};
let leadingEdgeKey, trailingEdgeKey, scrollKey, pageKey;
if (groupDirection === 'x') {
leadingEdgeKey = 'left';
trailingEdgeKey = 'right';
scrollKey = 'scrollLeft';
pageKey = 'pageX';
} else {
leadingEdgeKey = 'top';
trailingEdgeKey = 'bottom';
scrollKey = 'scrollTop';
pageKey = 'pageY';
}
let createFakeEvent = () => {
if (this._pageX == null && this._pageY == null) { return; }
return {
pageX: this._pageX,
pageY: this._pageY
};
};
// Set a trigger padding that will start scrolling
// the box when the item reaches within padding pixels
// of the edge of the scroll container.
let checkScrollBounds = () => {
let leadingEdge = itemContainer[leadingEdgeKey];
let trailingEdge = itemContainer[trailingEdgeKey];
let scroll = scrollContainer[scrollKey]();
let delta = 0;
if (trailingEdge >= scrollContainer[trailingEdgeKey]) {
delta = trailingEdge - scrollContainer[trailingEdgeKey];
} else if (leadingEdge <= scrollContainer[leadingEdgeKey]) {
delta = leadingEdge - scrollContainer[leadingEdgeKey];
}
if (delta !== 0) {
let speed = this.get('maxScrollSpeed');
delta = Math.min(Math.max(delta, -1 * speed), speed);
delta = scrollContainer[scrollKey](scroll + delta) - scroll;
let event = createFakeEvent();
if (event) {
if (scrollContainer.isWindow) {
event[pageKey] += delta;
}
run(() => drag(event));
}
}
if (this.get('isDragging')) {
requestAnimationFrame(checkScrollBounds);
}
};
if (!Ember.testing) {
requestAnimationFrame(checkScrollBounds);
}
} | _scrollOnEdges(drag) {
let groupDirection = this.get('group.direction');
let $element = this.$();
let scrollContainer = new ScrollContainer(scrollParent($element)[0]);
let itemContainer = {
width: $element.width(),
height: $element.height(),
get left() {
return $element.offset().left;
},
get right() {
return this.left + this.width;
},
get top() {
return $element.offset().top;
},
get bottom() {
return this.top + this.height;
}
};
let leadingEdgeKey, trailingEdgeKey, scrollKey, pageKey;
if (groupDirection === 'x') {
leadingEdgeKey = 'left';
trailingEdgeKey = 'right';
scrollKey = 'scrollLeft';
pageKey = 'pageX';
} else {
leadingEdgeKey = 'top';
trailingEdgeKey = 'bottom';
scrollKey = 'scrollTop';
pageKey = 'pageY';
}
let createFakeEvent = () => {
if (this._pageX == null && this._pageY == null) { return; }
return {
pageX: this._pageX,
pageY: this._pageY
};
};
// Set a trigger padding that will start scrolling
// the box when the item reaches within padding pixels
// of the edge of the scroll container.
let checkScrollBounds = () => {
let leadingEdge = itemContainer[leadingEdgeKey];
let trailingEdge = itemContainer[trailingEdgeKey];
let scroll = scrollContainer[scrollKey]();
let delta = 0;
if (trailingEdge >= scrollContainer[trailingEdgeKey]) {
delta = trailingEdge - scrollContainer[trailingEdgeKey];
} else if (leadingEdge <= scrollContainer[leadingEdgeKey]) {
delta = leadingEdge - scrollContainer[leadingEdgeKey];
}
if (delta !== 0) {
let speed = this.get('maxScrollSpeed');
delta = Math.min(Math.max(delta, -1 * speed), speed);
delta = scrollContainer[scrollKey](scroll + delta) - scroll;
let event = createFakeEvent();
if (event) {
if (scrollContainer.isWindow) {
event[pageKey] += delta;
}
run(() => drag(event));
}
}
if (this.get('isDragging')) {
requestAnimationFrame(checkScrollBounds);
}
};
if (!Ember.testing) {
requestAnimationFrame(checkScrollBounds);
}
} |
JavaScript | _applyPosition() {
if (!this.element || !this.$()) { return; }
const groupDirection = this.get('group.direction');
if (groupDirection === 'x') {
let x = this.get('x');
let dx = x - this.element.offsetLeft + parseFloat(this.$().css('margin-left'));
this.$().css({
transform: `translateX(${dx}px)`
});
}
if (groupDirection === 'y') {
let y = this.get('y');
let dy = y - this.element.offsetTop;
this.$().css({
transform: `translateY(${dy}px)`
});
}
} | _applyPosition() {
if (!this.element || !this.$()) { return; }
const groupDirection = this.get('group.direction');
if (groupDirection === 'x') {
let x = this.get('x');
let dx = x - this.element.offsetLeft + parseFloat(this.$().css('margin-left'));
this.$().css({
transform: `translateX(${dx}px)`
});
}
if (groupDirection === 'y') {
let y = this.get('y');
let dy = y - this.element.offsetTop;
this.$().css({
transform: `translateY(${dy}px)`
});
}
} |
JavaScript | _drag(dimension) {
if(this.get('isDestroyed') || this.get('isDestroying')){
return;
}
let updateInterval = this.get('updateInterval');
const groupDirection = this.get('group.direction');
if (groupDirection === 'x') {
this.set('x', dimension);
}
if (groupDirection === 'y') {
this.set('y', dimension);
}
run.throttle(this, '_tellGroup', 'update', updateInterval);
} | _drag(dimension) {
if(this.get('isDestroyed') || this.get('isDestroying')){
return;
}
let updateInterval = this.get('updateInterval');
const groupDirection = this.get('group.direction');
if (groupDirection === 'x') {
this.set('x', dimension);
}
if (groupDirection === 'y') {
this.set('y', dimension);
}
run.throttle(this, '_tellGroup', 'update', updateInterval);
} |
JavaScript | _waitForTransition() {
return new Promise(resolve => {
run.next(() => {
let duration = 0;
if (this.get('isAnimated')) {
duration = this.get('transitionDuration');
}
run.later(this, resolve, duration);
});
});
} | _waitForTransition() {
return new Promise(resolve => {
run.next(() => {
let duration = 0;
if (this.get('isAnimated')) {
duration = this.get('transitionDuration');
}
run.later(this, resolve, duration);
});
});
} |
JavaScript | _complete() {
if(this.get('isDestroyed') || this.get('isDestroying')){
return;
}
invokeAction(this, 'onDragStop', this.get('model'));
this.set('isDropping', false);
this.set('wasDropped', true);
this._tellGroup('commit');
} | _complete() {
if(this.get('isDestroyed') || this.get('isDestroying')){
return;
}
invokeAction(this, 'onDragStop', this.get('model'));
this.set('isDropping', false);
this.set('wasDropped', true);
this._tellGroup('commit');
} |
JavaScript | function printDeparture(row) {
let delayMinutes = Math.floor((((row.delay % 31536000) % 86400) % 3600) / 60);
let time = row.when.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"});
console.log(time + " " + delayMinutes + " " + row.line.product + " " + row.direction + " | stationId: " + row.station.id);
} | function printDeparture(row) {
let delayMinutes = Math.floor((((row.delay % 31536000) % 86400) % 3600) / 60);
let time = row.when.toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"});
console.log(time + " " + delayMinutes + " " + row.line.product + " " + row.direction + " | stationId: " + row.station.id);
} |
JavaScript | function CPChaincode(chain, chaincodeID) {
if(!(chain && chaincodeID))
throw new Error('Cannot create chaincode helper without both a chain object and the chaincode ID!');
this.chain = chain;
this.chaincodeID = chaincodeID;
// Add an optional queue for processing chaincode related tasks. Prevents "timer start called twice" errors from
// the SDK by only processing one request at a time.
this.queue = async.queue(function(task, callback) {
task(callback);
}, 1);
} | function CPChaincode(chain, chaincodeID) {
if(!(chain && chaincodeID))
throw new Error('Cannot create chaincode helper without both a chain object and the chaincode ID!');
this.chain = chain;
this.chaincodeID = chaincodeID;
// Add an optional queue for processing chaincode related tasks. Prevents "timer start called twice" errors from
// the SDK by only processing one request at a time.
this.queue = async.queue(function(task, callback) {
task(callback);
}, 1);
} |
JavaScript | function invoke(chain, enrollID, requestBody, cb) {
// Submit the invoke transaction as the given user
console.log(TAG, 'Invoke transaction as:', enrollID);
chain.getMember(enrollID, function (getMemberError, usr) {
if (getMemberError) {
console.error(TAG, 'failed to get ' + enrollID + ' member:', getMemberError.message);
if (cb) cb(getMemberError);
} else {
console.log(TAG, 'successfully got member:', enrollID);
console.log(TAG, 'invoke body:', JSON.stringify(requestBody));
var invokeTx = usr.invoke(requestBody);
// Print the invoke results
invokeTx.on('completed', function (results) {
// Invoke transaction submitted successfully
console.log(TAG, 'Successfully completed invoke. Results:', results);
cb(null, results);
});
invokeTx.on('submitted', function (results) {
// Invoke transaction submitted successfully
console.log(TAG, 'invoke submitted');
cb(null, results);
});
invokeTx.on('error', function (err) {
// Invoke transaction submission failed
console.log(TAG, 'invoke failed. Error:', err);
cb(err);
});
}
});
} | function invoke(chain, enrollID, requestBody, cb) {
// Submit the invoke transaction as the given user
console.log(TAG, 'Invoke transaction as:', enrollID);
chain.getMember(enrollID, function (getMemberError, usr) {
if (getMemberError) {
console.error(TAG, 'failed to get ' + enrollID + ' member:', getMemberError.message);
if (cb) cb(getMemberError);
} else {
console.log(TAG, 'successfully got member:', enrollID);
console.log(TAG, 'invoke body:', JSON.stringify(requestBody));
var invokeTx = usr.invoke(requestBody);
// Print the invoke results
invokeTx.on('completed', function (results) {
// Invoke transaction submitted successfully
console.log(TAG, 'Successfully completed invoke. Results:', results);
cb(null, results);
});
invokeTx.on('submitted', function (results) {
// Invoke transaction submitted successfully
console.log(TAG, 'invoke submitted');
cb(null, results);
});
invokeTx.on('error', function (err) {
// Invoke transaction submission failed
console.log(TAG, 'invoke failed. Error:', err);
cb(err);
});
}
});
} |
JavaScript | function query(chain, enrollID, requestBody, cb) {
// Submit the invoke transaction as the given user
console.log(TAG, 'querying chaincode as:', enrollID);
chain.getMember(enrollID, function (getMemberError, usr) {
if (getMemberError) {
console.error(TAG, 'failed to get ' + enrollID + ' member:', getMemberError.message);
if (cb) cb(getMemberError);
} else {
console.log(TAG, 'successfully got member:', enrollID);
console.log(TAG, 'query body:', JSON.stringify(requestBody));
var queryTx = usr.query(requestBody);
queryTx.on('complete', function (results) {
console.log(TAG, 'Successfully completed query. Results:', results);
cb(null, results.result);
});
queryTx.on('error', function (err) {
console.log(TAG, 'query failed. Error:', err);
cb(err);
});
}
});
} | function query(chain, enrollID, requestBody, cb) {
// Submit the invoke transaction as the given user
console.log(TAG, 'querying chaincode as:', enrollID);
chain.getMember(enrollID, function (getMemberError, usr) {
if (getMemberError) {
console.error(TAG, 'failed to get ' + enrollID + ' member:', getMemberError.message);
if (cb) cb(getMemberError);
} else {
console.log(TAG, 'successfully got member:', enrollID);
console.log(TAG, 'query body:', JSON.stringify(requestBody));
var queryTx = usr.query(requestBody);
queryTx.on('complete', function (results) {
console.log(TAG, 'Successfully completed query. Results:', results);
cb(null, results.result);
});
queryTx.on('error', function (err) {
console.log(TAG, 'query failed. Error:', err);
cb(err);
});
}
});
} |
JavaScript | function updateSelectedMunicipality(){
var selectedMunicipality = municipalitySelect.find('option:selected').text();
if (selectedMunicipality !== "") {
selectedMunicipalityElem.text(selectedMunicipality);
}
} | function updateSelectedMunicipality(){
var selectedMunicipality = municipalitySelect.find('option:selected').text();
if (selectedMunicipality !== "") {
selectedMunicipalityElem.text(selectedMunicipality);
}
} |
JavaScript | function toggleMembershipRadios(){
var municipalMembership = $('#municipalMembership');
if( equalMunicipalitys() || ((typeof userMunicipalityMatchesInitiativeMunicipality !== 'undefined') && userMunicipalityMatchesInitiativeMunicipality)){
municipalityNotEqual.stop(false,true).slideUp(slideOptions);
disableSubmit(false);
showMembership(false);
} else {
municipalityNotEqual.stop(false,true).slideDown(slideOptions);
if (!validationErrors){
preventContinuing(true, 'mask', $('.toggle-disable'));
}
if (Init.isVerifiedInitiative()) {
disableSubmit(true);
}
if(otherMunicipalitySelect.prop('checked')) {
showMembership(true);
}
}
} | function toggleMembershipRadios(){
var municipalMembership = $('#municipalMembership');
if( equalMunicipalitys() || ((typeof userMunicipalityMatchesInitiativeMunicipality !== 'undefined') && userMunicipalityMatchesInitiativeMunicipality)){
municipalityNotEqual.stop(false,true).slideUp(slideOptions);
disableSubmit(false);
showMembership(false);
} else {
municipalityNotEqual.stop(false,true).slideDown(slideOptions);
if (!validationErrors){
preventContinuing(true, 'mask', $('.toggle-disable'));
}
if (Init.isVerifiedInitiative()) {
disableSubmit(true);
}
if(otherMunicipalitySelect.prop('checked')) {
showMembership(true);
}
}
} |
JavaScript | function warningNotMember(show){
var warning = $('.is-not-member');
if (show){
warning.fadeIn(speedFast);
} else {
warning.hide();
}
} | function warningNotMember(show){
var warning = $('.is-not-member');
if (show){
warning.fadeIn(speedFast);
} else {
warning.hide();
}
} |
JavaScript | function groupByDevice(roomDeviceTypes) {
return Promise.reduce(roomDeviceTypes, (result, room) => result.concat(room.deviceTypes), [])
.then(deviceTypesWithoutRoom => Promise.reduce(deviceTypesWithoutRoom, (deviceTypeByDevice, deviceType) => {
const val = roomDeviceTypes.device;
deviceTypeByDevice[val] = deviceTypeByDevice[val] || [];
deviceTypeByDevice[val].push(deviceType);
return deviceTypeByDevice;
}, {}));
} | function groupByDevice(roomDeviceTypes) {
return Promise.reduce(roomDeviceTypes, (result, room) => result.concat(room.deviceTypes), [])
.then(deviceTypesWithoutRoom => Promise.reduce(deviceTypesWithoutRoom, (deviceTypeByDevice, deviceType) => {
const val = roomDeviceTypes.device;
deviceTypeByDevice[val] = deviceTypeByDevice[val] || [];
deviceTypeByDevice[val].push(deviceType);
return deviceTypeByDevice;
}, {}));
} |
JavaScript | function LoginStack() {
return (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name='Login' component={LoginScreen} />
<Stack.Screen name='Sign Up' component={SignUpScreen} />
<Stack.Screen name='Home Screen' component={Tabs} />
</Stack.Navigator>
);
} | function LoginStack() {
return (
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
>
<Stack.Screen name='Login' component={LoginScreen} />
<Stack.Screen name='Sign Up' component={SignUpScreen} />
<Stack.Screen name='Home Screen' component={Tabs} />
</Stack.Navigator>
);
} |
JavaScript | function check_display_canvas () {
if (window.innerWidth < MINIMUM_CANVAS_WIDTH) {
document.getElementById("canvas").style.display = "none";
document.getElementById("canvas").height = 0;
document.getElementById("canvas").width = 0;
document.getElementById("canvas-message").style.display = "block";
} else {
document.getElementById("canvas").style.display = "block";
document.getElementById("canvas").height = MINIMUM_CANVAS_HEIGHT;
document.getElementById("canvas").width = MINIMUM_CANVAS_WIDTH;
document.getElementById("canvas-message").style.display = "none";
}
} | function check_display_canvas () {
if (window.innerWidth < MINIMUM_CANVAS_WIDTH) {
document.getElementById("canvas").style.display = "none";
document.getElementById("canvas").height = 0;
document.getElementById("canvas").width = 0;
document.getElementById("canvas-message").style.display = "block";
} else {
document.getElementById("canvas").style.display = "block";
document.getElementById("canvas").height = MINIMUM_CANVAS_HEIGHT;
document.getElementById("canvas").width = MINIMUM_CANVAS_WIDTH;
document.getElementById("canvas-message").style.display = "none";
}
} |
JavaScript | function GameLevel (gameCanvas, levelJSON) {
var self = this;
this.gameCanvas = gameCanvas;
this.levelJSON = levelJSON;
this.intervals = [];
this.objects = [];
/** Clear all intervals associated with objects in this level. */
this.clear_intervals = function(){
this.intervals.forEach(function (interval) {
clearInterval(interval);
});
}
/** Add two walls and two platforms to the canvas
to form boundaries at the edges. */
this.load_borders = function(width, height){
var background = '#F9F9F9';
var border = '#000';
this.add_box(0, 0, width, height, background, border, true);
}
/** Load current level settings to the canvas. */
this.load_JSON = function(){
this.add_boxes(this.levelJSON["boxes"]);
this.add_lines(this.levelJSON["lines"]);
this.add_walls(this.levelJSON["walls"]);
this.add_npcs(this.levelJSON["NPCs"]);
}
/** Add a box object to the gameCanvas. */
this.add_box = function (xMin, yMin, xMax, yMax, fill, stroke, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var box = new CanvasShape(this.gameCanvas, fill, stroke);
this.objects.push(box);
box.steps.push([xMin, yMin], [xMax, yMin], [xMax, yMax], [xMin, yMax]);
box.add_line(xMin, yMin, xMax, yMin, isFatal, isEndpoint);
box.add_line(xMin, yMax, xMax, yMax, isFatal, isEndpoint);
box.add_line(xMin, yMin, xMin, yMax, false, false);
box.add_line(xMax, yMin, xMax, yMax, false, false);
this.gameCanvas.wallAreas.push([xMin, yMin, yMax]);
this.gameCanvas.wallAreas.push([xMax, yMin, yMax]);
this.gameCanvas.platformAreas.push([xMin, xMax, yMin]);
this.gameCanvas.platformAreas.push([xMin, xMax, yMax]);
}
/** Add a list of box objects from JSON to this level. */
this.add_boxes = function (boxArgs) {
var boxArgs = boxArgs || [];
boxArgs.forEach(function (box) {
self.add_box(box.xMin, box.yMin, box.xMax, box.yMax,
box.fill, box.stroke, box.isFatal, box.isEndpoint);
});
}
/** Add a line to this shape. */
this.add_line = function (xMin, yMin, xMax, yMax, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var line = new CanvasLine(this.gameCanvas, xMin, yMin,
xMax, yMax, isFatal, isEndpoint);
this.objects.push(line);
this.gameCanvas.platformAreas.push([xMin, xMax, yMin]);
}
/** Add a list of line objects from JSON to this level. */
this.add_lines = function (lineArgs) {
var lineArgs = lineArgs || [];
lineArgs.forEach(function (line) {
self.add_line(line.xMin, line.yMin, line.xMax, line.yMax,
line.isFatal, line.isEndpoint);
});
}
/** Add a wall object to the gameCanvas. */
this.add_wall = function (xPosition, yBottom, yHeight) {
var newWall = new CanvasLine(this.gameCanvas, xPosition, yBottom,
xPosition, yBottom+yHeight);
this.objects.push(newWall);
this.gameCanvas.wallAreas.push([xPosition, yBottom, yHeight]);
}
/** Add a list of wall objects from JSON to this level. */
this.add_walls = function (wallArgs) {
var wallArgs = wallArgs || [];
wallArgs.forEach(function (wall) {
self.add_wall(wall.xPosition, wall.yBottom, wall.yHeight);
});
}
/** Add a new character to this gameCanvas. */
this.add_npc = function (xPosition, yPosition) {
var newNPC = new GameCharacter(this.gameCanvas, xPosition, yPosition);
this.gameCanvas.characters.push(newNPC);
return newNPC;
}
/** Add a list of npc objects from JSON to this level. */
this.add_npcs = function (npcArgs) {
var npcArgs = npcArgs || [];
npcArgs.forEach(function (npc) {
self.add_npc(npc.xPosition, npc.yPosition);
});
}
} | function GameLevel (gameCanvas, levelJSON) {
var self = this;
this.gameCanvas = gameCanvas;
this.levelJSON = levelJSON;
this.intervals = [];
this.objects = [];
/** Clear all intervals associated with objects in this level. */
this.clear_intervals = function(){
this.intervals.forEach(function (interval) {
clearInterval(interval);
});
}
/** Add two walls and two platforms to the canvas
to form boundaries at the edges. */
this.load_borders = function(width, height){
var background = '#F9F9F9';
var border = '#000';
this.add_box(0, 0, width, height, background, border, true);
}
/** Load current level settings to the canvas. */
this.load_JSON = function(){
this.add_boxes(this.levelJSON["boxes"]);
this.add_lines(this.levelJSON["lines"]);
this.add_walls(this.levelJSON["walls"]);
this.add_npcs(this.levelJSON["NPCs"]);
}
/** Add a box object to the gameCanvas. */
this.add_box = function (xMin, yMin, xMax, yMax, fill, stroke, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var box = new CanvasShape(this.gameCanvas, fill, stroke);
this.objects.push(box);
box.steps.push([xMin, yMin], [xMax, yMin], [xMax, yMax], [xMin, yMax]);
box.add_line(xMin, yMin, xMax, yMin, isFatal, isEndpoint);
box.add_line(xMin, yMax, xMax, yMax, isFatal, isEndpoint);
box.add_line(xMin, yMin, xMin, yMax, false, false);
box.add_line(xMax, yMin, xMax, yMax, false, false);
this.gameCanvas.wallAreas.push([xMin, yMin, yMax]);
this.gameCanvas.wallAreas.push([xMax, yMin, yMax]);
this.gameCanvas.platformAreas.push([xMin, xMax, yMin]);
this.gameCanvas.platformAreas.push([xMin, xMax, yMax]);
}
/** Add a list of box objects from JSON to this level. */
this.add_boxes = function (boxArgs) {
var boxArgs = boxArgs || [];
boxArgs.forEach(function (box) {
self.add_box(box.xMin, box.yMin, box.xMax, box.yMax,
box.fill, box.stroke, box.isFatal, box.isEndpoint);
});
}
/** Add a line to this shape. */
this.add_line = function (xMin, yMin, xMax, yMax, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var line = new CanvasLine(this.gameCanvas, xMin, yMin,
xMax, yMax, isFatal, isEndpoint);
this.objects.push(line);
this.gameCanvas.platformAreas.push([xMin, xMax, yMin]);
}
/** Add a list of line objects from JSON to this level. */
this.add_lines = function (lineArgs) {
var lineArgs = lineArgs || [];
lineArgs.forEach(function (line) {
self.add_line(line.xMin, line.yMin, line.xMax, line.yMax,
line.isFatal, line.isEndpoint);
});
}
/** Add a wall object to the gameCanvas. */
this.add_wall = function (xPosition, yBottom, yHeight) {
var newWall = new CanvasLine(this.gameCanvas, xPosition, yBottom,
xPosition, yBottom+yHeight);
this.objects.push(newWall);
this.gameCanvas.wallAreas.push([xPosition, yBottom, yHeight]);
}
/** Add a list of wall objects from JSON to this level. */
this.add_walls = function (wallArgs) {
var wallArgs = wallArgs || [];
wallArgs.forEach(function (wall) {
self.add_wall(wall.xPosition, wall.yBottom, wall.yHeight);
});
}
/** Add a new character to this gameCanvas. */
this.add_npc = function (xPosition, yPosition) {
var newNPC = new GameCharacter(this.gameCanvas, xPosition, yPosition);
this.gameCanvas.characters.push(newNPC);
return newNPC;
}
/** Add a list of npc objects from JSON to this level. */
this.add_npcs = function (npcArgs) {
var npcArgs = npcArgs || [];
npcArgs.forEach(function (npc) {
self.add_npc(npc.xPosition, npc.yPosition);
});
}
} |
JavaScript | function CanvasShape (gameCanvas, fill, stroke) {
var self = this;
this.gameCanvas = gameCanvas;
this.fill = fill || '#555559';
this.stroke = stroke || '#111114';
this.lines = [];
this.steps = [];
/** Add a line to this shape. */
this.add_line = function (xMin, yMin, xMax, yMax, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var line = new CanvasLine(this.gameCanvas, xMin, yMin,
xMax, yMax, isFatal, isEndpoint);
this.lines.push(line);
}
/** Draw this shape on the canvas. */
this.draw = function(){
var context = this.gameCanvas.context;
var yOffset = this.gameCanvas.groundOffset;
context.beginPath();
start = this.steps[this.steps.length - 1];
context.moveTo(start[0], yOffset-start[1]);
this.steps.forEach(function (step) {
context.lineTo(step[0], yOffset-step[1]);
});
context.closePath();
context.fillStyle = this.fill;
context.fill();
context.strokeStyle = this.stroke;
context.stroke();
}
} | function CanvasShape (gameCanvas, fill, stroke) {
var self = this;
this.gameCanvas = gameCanvas;
this.fill = fill || '#555559';
this.stroke = stroke || '#111114';
this.lines = [];
this.steps = [];
/** Add a line to this shape. */
this.add_line = function (xMin, yMin, xMax, yMax, isFatal, isEndpoint) {
var isFatal = isFatal || false;
var isEndpoint = isEndpoint || false;
var line = new CanvasLine(this.gameCanvas, xMin, yMin,
xMax, yMax, isFatal, isEndpoint);
this.lines.push(line);
}
/** Draw this shape on the canvas. */
this.draw = function(){
var context = this.gameCanvas.context;
var yOffset = this.gameCanvas.groundOffset;
context.beginPath();
start = this.steps[this.steps.length - 1];
context.moveTo(start[0], yOffset-start[1]);
this.steps.forEach(function (step) {
context.lineTo(step[0], yOffset-step[1]);
});
context.closePath();
context.fillStyle = this.fill;
context.fill();
context.strokeStyle = this.stroke;
context.stroke();
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.