function GetAJAXInstance() { if (window.XMLHttpRequest) {return new XMLHttpRequest();} else if (window.ActiveXObject) { try {return new ActiveXObject('Msxml2.XMLHTTP');} catch (e) { try {return new ActiveXObject('Microsoft.XMLHTTP');} catch (e) {} } } return false; } function ParseXML(code,onerror) { if (!code) { if (onerror) {onerror(null,'No XML code supplied, probably the web service has not been found');} return; } if (window.ActiveXObject) { var xmldoc = new ActiveXObject('Microsoft.XMLDOM'); xmldoc.async = 'false'; xmldoc.loadXML(code); if (xmldoc.parseError.errorCode != 0) { if (onerror) {onerror(code,xmldoc.parseError.reason);} return null; } return xmldoc; } else { var xmldoc = new DOMParser().parseFromString(code,'text/xml'); if (xmldoc.documentElement.tagName == 'parsererror') { if (onerror) { var xmlerror = new XMLSerializer().serializeToString(xmldoc); var re = />([\s\S]*?)Location:([\s\S]*?)Line Number (\d+), Column (\d+):([\s\S]*?)(?:\-*\^)/; re.test(xmlerror); onerror(code,RegExp.$1); } return null; } return xmldoc; } } function jsAJAXLoader() { if (isNaN(jsAJAXLoader.count)) {jsAJAXLoader.count = 0;} this.index = jsAJAXLoader.count; this.name = "jsAJAXLoader" + (jsAJAXLoader.count++); this.obj = this.name + "Object"; eval(this.obj + " = this") this.Busy = false; this.LoadBuffer = new Array(); this.GetLoader = jsAJAXGetLoader; this.StartLoad = jsAJAXLoaderStartLoad; this.CheckBuffer = jsAJAXLoaderCheckBuffer; this.EndLoad = jsAJAXLoaderEndLoad; } function jsAJAXGetLoader(page,onendload,data) { return new jsAJAXLoaderData(this,page,onendload,data); } function jsAJAXLoaderStartLoad(data) { this.LoadBuffer = this.LoadBuffer.concat(data); this.CheckBuffer(); } function jsAJAXLoaderCheckBuffer() { if (this.LoadBuffer.length > 0) { if (this.Busy) { setTimeout(this.obj + '.CheckBuffer()',100); return; } else { this.Busy = true; var current = this.LoadBuffer[0]; var oname = this.obj; var page = current.Page; this.Loader = GetAJAXInstance(); if (this.Loader) { var varstxt = ''; for (var i=0;i 0)) { var txt = (this.Loader.status == 200) ? this.Loader.responseText : null; var current = this.LoadBuffer[0]; if (current.OnEndLoad) {current.OnEndLoad(txt,current.EndLoadData);} this.LoadBuffer.splice(0,1); this.Loader = null; this.Busy = false; this.CheckBuffer(); } } } function jsAJAXLoaderData(parent,page,onendload,data) { if (isNaN(jsAJAXLoaderData.count)) {jsAJAXLoaderData.count = 0;} this.index = jsAJAXLoaderData.count; this.name = "jsAJAXLoaderData" + (jsAJAXLoaderData.count++); this.obj = this.name + "Object"; eval(this.obj + " = this") this.Parent = parent; this.Page = page; this.OnEndLoad = onendload; this.EndLoadData = data; this.VarNames = new Array(); this.VarValues = new Array(); this.Load = jsAJAXLoaderDataLoad; this.AddVar = jsAJAXLoaderDataAddVar; this.GetValue = jsAJAXLoaderDataGetValue; this.ClearVars = jsAJAXLoaderDataClearVars; } function jsAJAXLoaderDataLoad() {this.Parent.StartLoad(this);} function jsAJAXLoaderDataAddVar(varname,varvalue) { for (var i=0;i' + '
' + '
' + '
' + this.NameExpanded + '
' + ''; return html; } function CollapsableTitleClicked() { if (this.Expanded) {this.Collapse();} else {this.Expand();} } function CollapsableTitleCollapse() { if (this.Expanded) { var div = document.getElementById(this.name + 'Div'); if (div) { div.alt = (this.DescriptionCollapsed) ? this.DescriptionCollapsed : ''; div.title = (this.DescriptionCollapsed) ? this.DescriptionCollapsed : ''; if (this.HideBorderBottom) {div.style.borderBottom = '0px';} } var img = document.getElementById(this.name + 'ExpandIcon'); if (img) {img.src = '../img/tree-plus.gif';} var ndiv = document.getElementById(this.name + 'NameDiv'); if (ndiv) {ndiv.innerHTML = this.NameCollapsed;} var rdiv = document.getElementById(this.RelatedDivId); if (rdiv) {rdiv.style.display = 'none';} this.Expanded = false; if (this.OnCollapse) {this.OnCollapse(this.ReferenceObject);} } } function Floating(header,body,footer) { this.Header = header; this.Body = body; this.Footer = footer; this.GetHTML = FloatingGetHTML; this.BuildDiv = FloatingBuildDiv; this.Destroy = FloatingDestroy; } function FloatingGetHTML() { var html = '
' + '
' + '
'; if (this.Header) {html += this.Header.GetHTML();} if (this.Body) {html += this.Body.GetHTML();} if (this.Footer) {html += this.Footer.GetHTML((this.Body) ? true : false);} html += '
'; return html; } function FloatingBuildDiv(id,cssclass,pdiv) { this.MainDiv = document.createElement('DIV'); if (id) {this.MainDiv.id = id;} this.MainDiv.className = 'floating' + ((cssclass) ? ' ' + cssclass : ''); this.MainDiv.innerHTML = this.GetHTML(); if (pdiv) {pdiv.appendChild(this.MainDiv);} else {document.body.appendChild(this.MainDiv);} return this.MainDiv; } function FloatingDestroy() { if (this.MainDiv) { if (this.MainDiv.parentNode) {this.MainDiv.parentNode.removeChild(this.MainDiv);} this.MainDiv = null; } } function FloatingHeader(idtitle,title,idsubtitle,subtitle) { this.IdTitle = idtitle; this.Title = title; this.IdSubtitle = idsubtitle; this.Subtitle = subtitle; this.GetHTML = FloatingHeaderGetHTML; } function FloatingHeaderGetHTML() { var html = ''; var putsep = false; if ((this.IdTitle)||(this.Title)) { html += '' + ((this.Title) ? this.Title : '') + ''; putsep = true; } if ((this.IdSubtitle)||(this.Subtitle)) { html += '' + ((this.Subtitle) ? this.Subtitle : '') + ''; putsep = true; } if (putsep) {html += '
';} return html; } function FloatingBody(controls,addhtml,twocolumns,fixedheight,addpos) { this.Controls = controls; this.AdditionalHTML = addhtml; this.TwoColumns = twocolumns; this.FixedHeight = fixedheight; this.AdditionalPosition = (addpos) ? addpos : 'BOTTOM'; this.GetHTML = FloatingBodyGetHTML; } function FloatingBodyGetHTML() { var html = '
'; if ((this.AdditionalHTML)&&(this.AdditionalPosition == 'TOP')) {html += this.AdditionalHTML;} if ((this.Controls)&&(this.Controls.length)) { var twoopen = false; for (var i=0;i= this.Controls.length - 2) {html += 'margin-bottom:20px;';} html += '">'; twoopen = true; } html += '
'; } html += this.Controls[i].GetHTML((i == 0),(i == this.Controls.length - 1),this.TwoColumns); if (this.TwoColumns) { html += '
'; if ((twoopen)&&(i % 2 != 0)) {html += '
'; twoopen = false;} } } if (twoopen) {html += '';} } if ((this.AdditionalHTML)&&(this.AdditionalPosition == 'BOTTOM')) {html += this.AdditionalHTML;} html += ''; return html; } function FloatingFooter(leftbuttons,rightbuttons,iderror) { this.LeftButtons = leftbuttons; this.RightButtons = rightbuttons; this.IdError = iderror; this.GetHTML = FloatingFooterGetHTML; } function FloatingFooterGetHTML(showsep) { var html = ''; if (showsep) {html += '
';} html += '
'; if ((this.LeftButtons)&&(this.LeftButtons.length)) { html += '
'; for (var i=0;i
'; } if ((this.RightButtons)&&(this.RightButtons.length)) { html += '
'; for (var i=0;i'; } html += '
' + this.Name + '
' + '' + '
' + ((this.Type == MutableControl) ? ((this.Value) ? this.Value : '') : this.GetControlHTML(readonly)) + '
' + ((this.AdditionalControlHTML) ? '
' + this.AdditionalControlHTML + '
' : '') + '
'; if (!dontputdiv) {html += '
';} return html; } function FormControlGetControlHTML(readonly) { var html = ''; if (readonly) { if (this.Type == BooleanControl) { var text = (this.Value == null) ? '' : ((this.Value == true) ? 'Sí' : 'No'); html += ''; } else if ((this.Type == IntegerControl)||(this.Type == RealControl)) { html += ''; } else if (this.Type == TextControl) { html += ''; } else if (this.Type == DateControl) { html += ''; } else if (this.Type == HourControl) { html += ''; } else if (this.Type == OptionsControl) { var text = ''; if ((this.Value)&&(this.Options)&&(this.Options.length)) { for (var i=0;i'; } else if (this.Type == PasswordControl) { html += ''; } else if (this.Type == LongTextControl) { html += ''; } else if (this.Type == TimeControl) { html += ''; } else if (this.Type == IPControl) { html += ''; } else if (this.Type == ARGBControl) { html += ''; } else if (this.Type == OptionTreeControl) { html += ''; } } else { if (this.Type == BooleanControl) { html += ''; } else if ((this.Type == IntegerControl)||(this.Type == RealControl)) { html += ''; } else if (this.Type == TextControl) { html += ''; } else if (this.Type == DateControl) { var cal = new jsCalendar(this.Id,this.Value,'return CheckControlKeyPressed(event,' + this.Type + ');', ((this.Multiple)&&(this.Value == null)) ? ' propertiesmultiple' : null); html += cal.GetInnerHTML(); } else if (this.Type == HourControl) { var cname = 'calendar text3' + (((this.Multiple)&&(this.Value == null)) ? ' propertiesmultiple' : ''); var tedit = new jsTimeEdit(this.Id,this.Value,cname,'80px','return CheckControlKeyPressed(event,' + this.Type + ');',true,this.OnChange); html += tedit.GetHTML(); } else if (this.Type == FileControl) { // TODO } else if (this.Type == OptionsControl) { html += ''; } else if (this.Type == PasswordControl) { html += ''; } else if (this.Type == LongTextControl) { html += ''; } else if (this.Type == TimeControl) { var cname = 'calendar text3' + (((this.Multiple)&&(this.Value == null)) ? ' propertiesmultiple' : ''); var tedit = new jsTimeEdit(this.Id,this.Value,cname,'90px','return CheckControlKeyPressed(event,' + this.Type + ');',false,this.OnChange); html += tedit.GetHTML(); } else if (this.Type == IPControl) { var cname = 'calendar text3' + (((this.Multiple)&&(this.Value == null)) ? ' propertiesmultiple' : ''); var tedit = new jsIPEdit(this.Id,this.Value,cname,'100px','return CheckControlKeyPressed(event,' + this.Type + ');'); html += tedit.GetHTML(); } else if (this.Type == ARGBControl) { html += ''; } else if (this.Type == OptionTreeControl) { var otree = new OptionTree(this.Id); if (otree.FromXML(this.Options)) {html += otree.GetHTML(this.Must,this.Multiple,this.Value,readonly,this.OnChange)} } } return html; } function GetFormControlValue(id,type) { if ((type == BooleanControl)||(type == OptionsControl)) { var obj = document.getElementById(id); if (obj) {return obj.options[obj.selectedIndex].value;} } else if ((type == IntegerControl)||(type == RealControl)||(type == TextControl)||(type == DateControl)|| (type == HourControl)||(type == PasswordControl)||(type == LongTextControl)||(type == TimeControl)|| (type == IPControl)||(type == ARGBControl)) { var obj = document.getElementById(id); if (obj) {return obj.value;} } else if (type == OptionTreeControl) { var otree = eval(id + 'Object'); if (otree) {return otree.GetValue();} } return null; } function DisableAllControls(div) { if (div) { for (var i=0;i'; return html; } function CheckControlKeyPressed(e,type) { if (type != null) { var keycode = (document.all) ? window.event.keyCode : e.which; if ((keycode > 0)&&(keycode != 8)&&(keycode != 13)&&(keycode != 27)) { var validkey = true; if (type == IntegerControl) { validkey = ((keycode == 45)||((keycode >= 48)&&(keycode <= 57))); } else if (type == RealControl) { validkey = ((keycode == 45)||(keycode == 46)||((keycode >= 48)&&(keycode <= 57))); } else if (type == DateControl) { validkey = ((keycode >= 47)&&(keycode <= 57)); } else if (type == HourControl) { validkey = ((keycode == 58)||((keycode >= 48)&&(keycode <= 57))); } else if ((type == TextControl)||(type == PasswordControl)||(type == LongTextControl)) { validkey = ((keycode != 34)&&(keycode != 39)&&(keycode != 59)&&(keycode != 60)&&(keycode != 62)&&(keycode != 124)); } else if (type == TimeControl) { validkey = ((keycode == 46)||(keycode == 58)||((keycode >= 48)&&(keycode <= 57))); } else if (type == IPControl) { validkey = ((keycode == 46)||((keycode >= 48)&&(keycode <= 57))); } else if (type == ARGBControl) { validkey = (((keycode >= 48)&&(keycode <= 57))||((keycode >= 65)&&(keycode <= 70))||((keycode >= 97)&&(keycode <= 102))); } if (!validkey) { if (document.all) { window.event.returnValue = false; window.event.cancelBubble = true; } else { e.cancelBubble = true; e.preventDefault(); } return false; } } } return true; } function OptionTree(id) { this.obj = id + "Object"; eval(this.obj + " = this") this.Id = id; this.Options = new Array(); this.FromXML = OptionTreeFromXML; this.GetHTML = OptionTreeGetHTML; this.GetLevel = OptionTreeGetLevel; this.GetValue = OptionTreeGetValue; this.FillCombos = OptionTreeFillCombos; this.ComboChanged = OptionTreeComboChanged; } function OptionTreeFromXML(xml) { if (!xml) {return true;} var parser = ParseXML(xml); if (!parser) {return false;} var nodes = parser.getElementsByTagName('options'); if ((!nodes)||(!nodes.length)) {return false;} var root = nodes[0]; this.Options = new Array(); for (var i=0;i'; if ((!must)||(multiple)) {html += '';} var tosel = (i < values.length) ? values[i] : null; for (var j=0;j' + oval + ''; } html += ''; html += ''; } return html; } function OptionTreeGetLevel() { var level = 0; for (var i=0;i level) {level = current;} } return level; } function OptionTreeGetValue() { var level = this.GetLevel(),value = ''; for (var i=0;i limit) {cmb.removeChild(cmb.options[limit]);} if (opobj) { for (var i=0;i max) {max = current;} } level = max; } return level; } function OptionTreeNodeFromNode(tree,parent,node) { if ((node)&&(node.nodeName == 'option')) { var value = null; if (node.attributes.length) {value = node.attributes[0].value;} if (value) { var option = new OptionTreeNode(tree,parent,value); for (var i=0;i= 0) {url = url.substring(0,pos);} document.location.href = url + '?language=' + lang; } function OnLoginLoaded(xmlcode) { var parser = ParseXML(xmlcode,OnLoginError); if (parser) { var nodes = parser.getElementsByTagName('ServiceError'); if ((nodes)&&(nodes.length > 0)) { var text = 'Error desconocido'; for (var i=0;i' + ''; mdiv.appendChild(ldiv); var addhtml = ''; var floating = new Floating( new FloatingHeader(null,'Plataforma de Comunicación Multimedia',null,'Versión 1.0'), new FloatingBody( [ new FormControl('user','Usuario',TextControl,null,'Nombre del usuario',true,50), new FormControl('password','Contraseña',PasswordControl,null,'Contraseña del usuario',true,50) ], addhtml,null,null,'TOP' ), new FloatingFooter( null, [new FormButton('loginok','img/icon-ok.gif','img/icon-ok-dis.gif','Aceptar',true,'OnLoginOkClicked();')], 'loginerror' ) ); floating.BuildDiv(null,'floatinglogin',mdiv); var usrtxt = document.getElementById('user'); if (usrtxt) {usrtxt.onkeyup = OnLoginKeyPress;} var pwdtxt = document.getElementById('password'); if (pwdtxt) {pwdtxt.onkeyup = OnLoginKeyPress;} }