2010-12-02 23:34:41 +00:00
|
|
|
|
/* PACKAGE : COMMON
|
|
|
|
|
|
*/
|
|
|
|
|
|
function get_xmlhttp() {
|
|
|
|
|
|
try {
|
2011-02-05 08:05:49 +00:00
|
|
|
|
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP1");
|
2010-12-02 23:34:41 +00:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
|
|
|
|
|
} catch (E) {
|
|
|
|
|
|
xmlhttp = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
|
|
|
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
|
|
|
}
|
|
|
|
|
|
return xmlhttp;
|
|
|
|
|
|
}
|
|
|
|
|
|
/* ajax_function
|
|
|
|
|
|
* Envia una solicitud GET a ajax_server con la variables "function" y las definidas en parameters.
|
|
|
|
|
|
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com, julces2000@gmail.com>
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
* @package ajax
|
|
|
|
|
|
* @param string ajax_server url de la pagina servidor
|
|
|
|
|
|
* @param string function funci<EFBFBD>n solicitada en el lado del servidor
|
|
|
|
|
|
* @param string parameters variables pasadas por url. Ej. variable=valor&otravariable=suvalor
|
|
|
|
|
|
*/
|
|
|
|
|
|
function ajax_function(ajax_server, funcion, parameters, method)
|
|
|
|
|
|
{
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
var response;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parameters) parameters = '&' + encodeURI(parameters);
|
|
|
|
|
|
if (!method ) method ="POST";
|
|
|
|
|
|
data = "function=" + funcion + parameters;
|
|
|
|
|
|
questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?';
|
|
|
|
|
|
var callServer;
|
|
|
|
|
|
callServer = new leimnud.module.rpc.xmlhttp({
|
|
|
|
|
|
url : ajax_server,
|
|
|
|
|
|
async : false,
|
|
|
|
|
|
method : method,
|
|
|
|
|
|
args : data
|
|
|
|
|
|
});
|
|
|
|
|
|
callServer.make();
|
|
|
|
|
|
response = callServer.xmlhttp.responseText;
|
|
|
|
|
|
var scs = callServer.xmlhttp.responseText.extractScript();
|
|
|
|
|
|
|
|
|
|
|
|
scs.evalScript();
|
|
|
|
|
|
delete callServer;
|
|
|
|
|
|
} catch(ss){
|
|
|
|
|
|
alert("Error: "+ss.message+var_dump(ss));
|
|
|
|
|
|
}
|
|
|
|
|
|
return response;//objetus.responseText;
|
|
|
|
|
|
}
|
|
|
|
|
|
/* ajax_message
|
|
|
|
|
|
* Envia una solicitud GET a ajax_server con la variables "function" y las definidas en parameters.
|
|
|
|
|
|
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com, julces2000@gmail.com>
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
* @package ajax
|
|
|
|
|
|
* @param string ajax_server url de la pagina servidor
|
|
|
|
|
|
* @param string function funci<EFBFBD>n solicitada en el lado del servidor
|
|
|
|
|
|
* @param string parameters variables pasadas por url. Ej. variable=valor&otravariable=suvalor
|
|
|
|
|
|
*/
|
|
|
|
|
|
function ajax_message(ajax_server, funcion, parameters, method, callback)
|
|
|
|
|
|
{
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
var response;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parameters) parameters = '&' + encodeURI(parameters);
|
|
|
|
|
|
if (!method ) method ="POST";
|
|
|
|
|
|
data = "function=" + funcion + parameters;
|
|
|
|
|
|
questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?';
|
|
|
|
|
|
objetus.open( method, ajax_server + ((method==='GET')? questionMark+data : '') , true );
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( callback ) callback(objetus.responseText);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (method==='POST') objetus.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
|
|
objetus.send(((method==='GET')? null : data));
|
|
|
|
|
|
}catch(ss)
|
|
|
|
|
|
{
|
|
|
|
|
|
alert("error"+ss.message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* ajax_post
|
|
|
|
|
|
* Envia una solicitud GET/POST a ajax_server con los parametros definidos
|
|
|
|
|
|
* o los campos de un formulario
|
|
|
|
|
|
* @author Julio Cesar Laura Avendano <juliocesar@colosa.com, julces2000@gmail.com>
|
|
|
|
|
|
* @version 1.0
|
|
|
|
|
|
* @package ajax
|
|
|
|
|
|
* @param string ajax_server url de la pagina servidor
|
|
|
|
|
|
* @param string function funci<EFBFBD>n solicitada en el lado del servidor
|
|
|
|
|
|
* @param string parameters variables pasadas por url o formulario.
|
|
|
|
|
|
* @example: ajax_post('foo.com', document.form[0], "POST", callback )
|
|
|
|
|
|
*/
|
|
|
|
|
|
function ajax_post(ajax_server, parameters, method, callback, asynchronous )
|
|
|
|
|
|
{
|
2014-05-06 10:45:37 -04:00
|
|
|
|
if (ajax_server == '') {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
var response;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (typeof(parameters)==='object') parameters = ajax_getForm(parameters);
|
|
|
|
|
|
if (!method ) method ="POST";
|
|
|
|
|
|
if (typeof(asynchronous)==='undefined') asynchronous = false;
|
|
|
|
|
|
data = parameters;
|
|
|
|
|
|
questionMark = (ajax_server.split('?').length > 1 ) ? '&' : '?';
|
2012-12-06 16:44:10 -04:00
|
|
|
|
if ((method==='POST')||(method==='GET/POST')) {
|
2010-12-02 23:34:41 +00:00
|
|
|
|
objetus.open( 'POST', ajax_server + ((data.length<1024)?(questionMark+data):''), asynchronous );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
objetus.open( method, ajax_server + ((method==='GET')? questionMark+data : '') , asynchronous );
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( callback ) callback(objetus.responseText);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((method==='POST')||(method==='GET/POST')) objetus.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
|
|
|
|
|
|
objetus.send(((method==='GET')? null : data));
|
|
|
|
|
|
if (!asynchronous)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( callback ) callback(objetus.responseText);
|
|
|
|
|
|
return objetus.responseText;
|
|
|
|
|
|
}
|
|
|
|
|
|
}catch(ss)
|
|
|
|
|
|
{
|
|
|
|
|
|
alert("Error: "+ var_dump(ss));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Refactoring.......................
|
|
|
|
|
|
* Fixed by checkboxes binary values
|
|
|
|
|
|
* By Neyek <erik@colosa.com>
|
|
|
|
|
|
* Date March 27th, 2009 12:20:00 GMT-4
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
function ajax_getForm( thisform ) {
|
|
|
|
|
|
var formdata='';
|
|
|
|
|
|
|
|
|
|
|
|
// Loop through form fields
|
|
|
|
|
|
for (var i=0; i < thisform.length; i++) {
|
|
|
|
|
|
if ( formdata!=='' ) formdata += '&';
|
|
|
|
|
|
//Build Send String
|
|
|
|
|
|
if(thisform.elements[i].type == "text") { //Handle Textbox's
|
|
|
|
|
|
formdata += thisform.elements[i].name + "=" + encodeURIComponent(thisform.elements[i].value);
|
|
|
|
|
|
} else if(thisform.elements[i].type == "textarea") { //Handle textareas
|
|
|
|
|
|
formdata += thisform.elements[i].name + "=" + encodeURIComponent(thisform.elements[i].value);
|
|
|
|
|
|
} else if(thisform.elements[i].type == "checkbox") { //Handle checkbox's
|
2012-12-10 14:29:29 -04:00
|
|
|
|
formdata += thisform.elements[i].name + '=' + ((thisform.elements[i].checked)? (typeof(thisform.elements[i].value) != 'undefined' ? thisform.elements[i].value : 'On') : '');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
} else if(thisform.elements[i].type == "radio") { //Handle Radio buttons
|
|
|
|
|
|
if(thisform.elements[i].checked==true){
|
|
|
|
|
|
formdata += thisform.elements[i].name + "=" + thisform.elements[i].value;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if(thisform.elements[i].type == "select-multiple") { //Handle list box
|
|
|
|
|
|
for(var j=0; j<thisform.elements[i].options.length ;j++) {
|
|
|
|
|
|
if ( j!==0 ) formdata += '&';
|
|
|
|
|
|
formdata += ( (thisform.elements[i].options[j].selected)? thisform.elements[i].name.replace('[]', '[' + j + ']') + "=" + encodeURIComponent(thisform.elements[i].options[j].value): '');
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
//finally, this should theoretically this is a select box.
|
|
|
|
|
|
formdata += thisform.elements[i].name + "=" + encodeURIComponent(thisform.elements[i].value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return formdata;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* COMMON FUNCTIONS
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isNumber (sValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
var sValue = new String(sValue);
|
|
|
|
|
|
var bDot = false;
|
|
|
|
|
|
var i, sCharacter;
|
|
|
|
|
|
if ((sValue == null) || (sValue.length == 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isNumber.arguments.length == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return (isNumber.arguments[1] == true);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < sValue.length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
sCharacter = sValue.charAt(i);
|
|
|
|
|
|
if (i != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sCharacter == '.')
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bDot)
|
|
|
|
|
|
{
|
|
|
|
|
|
bDot = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!((sCharacter >= '0') && (sCharacter <= '9')))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (sCharacter == '.')
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bDot)
|
|
|
|
|
|
{
|
|
|
|
|
|
bDot = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!((sCharacter >= '0') && (sCharacter <= '9') && (sCharacter != '-') || (sCharacter == '+')))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function roundNumber(iNumber, iDecimals)
|
2011-12-05 17:18:08 -04:00
|
|
|
|
{
|
|
|
|
|
|
if(typeof(iDecimals) === 'undefined')
|
|
|
|
|
|
iDecimals = 2;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
var iNumber = parseFloat(iNumber || 0);
|
2011-12-05 17:18:08 -04:00
|
|
|
|
var iDecimals = parseFloat(iDecimals || 0);
|
2010-12-02 23:34:41 +00:00
|
|
|
|
return Math.round(iNumber * Math.pow(10, iDecimals)) / Math.pow(10, iDecimals);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toMaskNumber(iNumber,dec)
|
|
|
|
|
|
{
|
|
|
|
|
|
iNumber = fix(iNumber.toString(),dec || 2);
|
|
|
|
|
|
var t=iNumber.split(".");
|
|
|
|
|
|
var arrayResult=iNumber.replace(/\D/g,'').replace(/^0*/,'').split("").reverse();
|
2012-11-09 09:15:56 -04:00
|
|
|
|
var result="";
|
2010-12-02 23:34:41 +00:00
|
|
|
|
var aux=0;
|
|
|
|
|
|
var sep=0;
|
|
|
|
|
|
for(var i=0;i<arrayResult.length;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(i==1)
|
|
|
|
|
|
{
|
2012-11-09 09:15:56 -04:00
|
|
|
|
result="."+arrayResult[i]+result;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(i>1 && aux>=3 && ((aux%3)==0))
|
|
|
|
|
|
{
|
2012-11-09 09:15:56 -04:00
|
|
|
|
result=arrayResult[i]+","+result;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
aux+=1;
|
|
|
|
|
|
sep+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2012-11-09 09:15:56 -04:00
|
|
|
|
result=arrayResult[i]+result;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
if(i>1)
|
|
|
|
|
|
{
|
|
|
|
|
|
aux+=1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2012-11-09 09:15:56 -04:00
|
|
|
|
return result;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fix(val, dec)
|
|
|
|
|
|
{
|
|
|
|
|
|
var a = val.split(".");
|
|
|
|
|
|
var r="";
|
|
|
|
|
|
if(a.length==1)
|
|
|
|
|
|
{
|
|
|
|
|
|
r=a[0]+"."+creaZero(dec);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if(a[1].length<=dec)
|
|
|
|
|
|
{
|
|
|
|
|
|
r=a[0]+"."+a[1]+creaZero(dec-a[1].length);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
r=a[0]+"."+a[1].substr(0,dec);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return r;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function creaZero(cant)
|
|
|
|
|
|
{
|
|
|
|
|
|
var a="";
|
|
|
|
|
|
for(var i=0;i<cant;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
a+="0";
|
|
|
|
|
|
}
|
|
|
|
|
|
return a;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toUnmaskNumber(iNumber)
|
|
|
|
|
|
{
|
|
|
|
|
|
var aux = "";
|
|
|
|
|
|
var num = new String (iNumber);
|
|
|
|
|
|
var len = num.length;
|
|
|
|
|
|
var i = 0;
|
|
|
|
|
|
for (i = 0; i < len; i++ ) {
|
|
|
|
|
|
if (num.charAt ( i) != ',' && num.charAt (i) != '$' && num.charAt (i) != ' ' && num.charAt (i) != '%' ) aux = aux + num.charAt ( i);
|
|
|
|
|
|
}
|
|
|
|
|
|
return parseFloat(aux,2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function compareDates(datea, dateB,porDias)
|
|
|
|
|
|
{
|
|
|
|
|
|
var a = datea.split('/');
|
|
|
|
|
|
|
|
|
|
|
|
var b = dateB.split('/');
|
|
|
|
|
|
x = new Date(a[2], a[1], (porDias)?1:a[0]);
|
|
|
|
|
|
y = new Date(b[2], b[1], (porDias)?1:b[0]);
|
|
|
|
|
|
return ((x - y) <= 0) ? false : true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****THE ANSWER*****/
|
|
|
|
|
|
/*diferencia entre 2 fechas*/
|
|
|
|
|
|
function diff_date(fecha1, fecha2)
|
|
|
|
|
|
{ var f1 = fecha1.split('-');
|
|
|
|
|
|
fecha1 = new Date();
|
|
|
|
|
|
fecha1.setDate(f1[2]);
|
|
|
|
|
|
fecha1.setMonth(f1[1]);
|
|
|
|
|
|
fecha1.setYear(f1[0]);
|
|
|
|
|
|
|
|
|
|
|
|
var f2 = fecha2.split('-');
|
|
|
|
|
|
fecha2 = new Date();
|
|
|
|
|
|
fecha2.setDate(f2[2]);
|
|
|
|
|
|
fecha2.setMonth(f2[1]);
|
|
|
|
|
|
fecha2.setYear(f2[0]);
|
|
|
|
|
|
|
|
|
|
|
|
var dias = Math.floor((fecha1.getTime()-fecha2.getTime())/(3600000*24));
|
|
|
|
|
|
return dias;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* author <julces2000@gmail.com>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getField( fieldName , formId )
|
|
|
|
|
|
{
|
|
|
|
|
|
if (formId)
|
|
|
|
|
|
{
|
|
|
|
|
|
var form = document.getElementById(formId);
|
|
|
|
|
|
if (!form) {form=document.getElementsByName(formId);
|
|
|
|
|
|
if (form) {
|
|
|
|
|
|
if (form.length > 0) {
|
|
|
|
|
|
form = form[0];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (form.length > 0) {
|
|
|
|
|
|
return form.elements[ 'form[' + fieldName + ']' ];
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
//return null;
|
|
|
|
|
|
return document.getElementById( 'form[' + fieldName + ']' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
return document.getElementById( 'form[' + fieldName + ']' );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* author <julces2000@gmail.com>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getElementByName( fieldName )
|
|
|
|
|
|
{
|
|
|
|
|
|
var elements = document.getElementsByName( fieldName );
|
|
|
|
|
|
try{
|
|
|
|
|
|
var x=0;
|
|
|
|
|
|
if (elements.length === 1)
|
|
|
|
|
|
return elements[0];
|
|
|
|
|
|
else if (elements.length === 0)
|
|
|
|
|
|
return elements[0];
|
|
|
|
|
|
else
|
|
|
|
|
|
return elements;
|
|
|
|
|
|
} catch (E)
|
|
|
|
|
|
{}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var myDialog;
|
|
|
|
|
|
function commonDialog ( type, title , text, buttons, values, callbackFn ) {
|
|
|
|
|
|
myDialog = new leimnud.module.panel();
|
|
|
|
|
|
myDialog.options = {
|
|
|
|
|
|
size:{w:400,h:200},
|
|
|
|
|
|
position:{center:true},
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
control: { close :false, roll :false, drag :true, resize :false },
|
|
|
|
|
|
fx: {
|
|
|
|
|
|
//shadow :true,
|
|
|
|
|
|
blinkToFront:false,
|
|
|
|
|
|
opacity :true,
|
|
|
|
|
|
drag:false,
|
|
|
|
|
|
modal: true
|
|
|
|
|
|
},
|
|
|
|
|
|
theme:"processmaker"
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
myDialog.make();
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 'question':
|
|
|
|
|
|
icon = 'question.gif';
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'warning':
|
|
|
|
|
|
icon = 'warning.gif';
|
|
|
|
|
|
break
|
|
|
|
|
|
case 'error':
|
|
|
|
|
|
icon = 'error.gif';
|
|
|
|
|
|
break
|
|
|
|
|
|
default:
|
|
|
|
|
|
icon = 'information.gif';
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var contentStr = '';
|
|
|
|
|
|
contentStr += "<div><table border='0' width='100%' > <tr height='70'><td width='60' align='center' >";
|
|
|
|
|
|
contentStr += "<img src='/js/maborak/core/images/" + icon + "'></td><td >" + text + "</td></tr>";
|
|
|
|
|
|
contentStr += "<tr height='35' valign='bottom'><td colspan='2' align='center'> ";
|
|
|
|
|
|
if ( buttons.custom && buttons.customText )
|
|
|
|
|
|
contentStr += "<input type='button' value='" + buttons.customText + "' onclick='myDialog.dialogCallback(4); ';> ";
|
|
|
|
|
|
if ( buttons.cancel )
|
|
|
|
|
|
contentStr += "<input type='button' value='Cancel' onclick='myDialog.dialogCallback(0);'> ";
|
|
|
|
|
|
if ( buttons.yes )
|
|
|
|
|
|
contentStr += "<input type='button' value=' Yes ' onclick='myDialog.dialogCallback(1);'> ";
|
|
|
|
|
|
if ( buttons.no )
|
|
|
|
|
|
contentStr += "<input type='button' value=' No ' onclick='myDialog.dialogCallback(2);'> ";
|
|
|
|
|
|
contentStr += "</td></tr>";
|
|
|
|
|
|
contentStr += "</table>";
|
|
|
|
|
|
|
|
|
|
|
|
myDialog.addContent( contentStr );
|
|
|
|
|
|
myDialog.values = values;
|
|
|
|
|
|
myDialog.dialogCallback = function ( dialogResult ) {
|
|
|
|
|
|
myDialog.remove( );
|
|
|
|
|
|
if ( callbackFn )
|
|
|
|
|
|
callbackFn ( dialogResult );
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
function var_dump(obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
var o,dump;
|
|
|
|
|
|
dump='';
|
|
|
|
|
|
if (typeof(obj)=='object') {
|
|
|
|
|
|
for(o in obj) if (typeof(obj[o])!=='function')
|
|
|
|
|
|
{
|
|
|
|
|
|
dump+=o+'('+typeof(obj[o])+'):'+obj[o]+"\n";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
dump=obj;
|
|
|
|
|
|
return dump;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* @author David Callizaya
|
|
|
|
|
|
*/
|
|
|
|
|
|
var currentPopupWindow;
|
|
|
|
|
|
function popupWindow ( title , url, width, height, callbackFn , autoSizeWidth, autoSizeHeight,modal,showModalColor) {
|
|
|
|
|
|
modal = (modal===false)?false:true;
|
|
|
|
|
|
showModalColor = (showModalColor===false)?false:true;
|
|
|
|
|
|
var myPanel = new leimnud.module.panel();
|
|
|
|
|
|
currentPopupWindow = myPanel;
|
|
|
|
|
|
myPanel.options = {
|
2014-07-02 11:22:33 -04:00
|
|
|
|
id: 'panelFieldProperties',
|
|
|
|
|
|
limit: true,
|
2010-12-02 23:34:41 +00:00
|
|
|
|
size:{w:width,h:height},
|
|
|
|
|
|
position:{center:true},
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
theme: "processmaker",
|
|
|
|
|
|
control: { close :true, roll :false, drag :true, resize :false},
|
|
|
|
|
|
fx: {
|
|
|
|
|
|
//shadow :true,
|
|
|
|
|
|
blinkToFront:true,
|
|
|
|
|
|
opacity :true,
|
|
|
|
|
|
drag:true,
|
|
|
|
|
|
modal: modal
|
|
|
|
|
|
//opacityModal:{static:'1'}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if(showModalColor===true)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Panel.setStyle={modal:{backgroundColor:"#ECF3F6"}};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
myPanel.styles.fx.opacityModal.Static='0';
|
|
|
|
|
|
}
|
|
|
|
|
|
myPanel.make();
|
|
|
|
|
|
myPanel.loader.show();
|
|
|
|
|
|
var r = new leimnud.module.rpc.xmlhttp({url:url});
|
|
|
|
|
|
r.callback=leimnud.closure({Function:function(rpc,myPanel){
|
|
|
|
|
|
myPanel.addContent(rpc.xmlhttp.responseText);
|
|
|
|
|
|
var myScripts = myPanel.elements.content.getElementsByTagName('SCRIPT');
|
|
|
|
|
|
for(var rr=0; rr<myScripts.length ; rr++){
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (myScripts[rr].innerHTML!=='')
|
|
|
|
|
|
if (window.execScript)
|
|
|
|
|
|
window.execScript( myScripts[rr].innerHTML, 'javascript' );
|
|
|
|
|
|
else
|
|
|
|
|
|
window.setTimeout( myScripts[rr].innerHTML, 0 );
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
alert(e.description);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* Autosize of panels, to fill only the first child of the
|
|
|
|
|
|
* rendered page (take note)
|
|
|
|
|
|
*/
|
|
|
|
|
|
var panelNonContentHeight = 62;
|
|
|
|
|
|
var panelNonContentWidth = 28;
|
|
|
|
|
|
myPanel.elements.content.style.padding="0px;";
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (autoSizeWidth)
|
|
|
|
|
|
myPanel.resize({w:myPanel.elements.content.childNodes[0].clientWidth+panelNonContentWidth});
|
|
|
|
|
|
if (autoSizeHeight)
|
|
|
|
|
|
myPanel.resize({h:myPanel.elements.content.childNodes[0].clientHeight+panelNonContentHeight});
|
|
|
|
|
|
} catch (e) {
|
2012-07-11 19:07:58 -04:00
|
|
|
|
alert(_('ID_MSG_AJAX_FAILURE'));
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
delete newdiv;
|
|
|
|
|
|
delete myScripts;
|
|
|
|
|
|
myPanel.command(myPanel.loader.hide);
|
|
|
|
|
|
},args:[r, myPanel]});
|
|
|
|
|
|
r.make();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
myPanel.dialogCallback = function ( ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
delete myPanel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var lastPopupWindow;
|
|
|
|
|
|
function popupWindowObject ( title , url, width, height, callbackFn , autoSizeWidth, autoSizeHeight,modal,showModalColor) {
|
|
|
|
|
|
modal = (modal===false)?false:true;
|
|
|
|
|
|
showModalColor = (showModalColor===false)?false:true;
|
|
|
|
|
|
var myPanel = new leimnud.module.panel();
|
|
|
|
|
|
lastPopupWindow = myPanel;
|
|
|
|
|
|
myPanel.options = {
|
|
|
|
|
|
size:{w:width,h:height},
|
|
|
|
|
|
position:{center:true},
|
|
|
|
|
|
title: title,
|
|
|
|
|
|
theme: "processmaker",
|
|
|
|
|
|
control: { close :true, roll :false, drag :true, resize :false},
|
|
|
|
|
|
fx: {
|
|
|
|
|
|
//shadow :true,
|
|
|
|
|
|
blinkToFront:true,
|
|
|
|
|
|
opacity :true,
|
|
|
|
|
|
drag:true,
|
|
|
|
|
|
modal: modal
|
|
|
|
|
|
//opacityModal:{static:'1'}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if(showModalColor===true)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Panel.setStyle={modal:{backgroundColor:"#ECF3F6"}};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
myPanel.styles.fx.opacityModal.Static='0';
|
|
|
|
|
|
}
|
|
|
|
|
|
myPanel.make();
|
|
|
|
|
|
myPanel.loader.show();
|
|
|
|
|
|
var r = new leimnud.module.rpc.xmlhttp({url:url});
|
|
|
|
|
|
r.callback=leimnud.closure({Function:function(rpc,myPanel){
|
|
|
|
|
|
myPanel.addContent(rpc.xmlhttp.responseText);
|
|
|
|
|
|
var myScripts = myPanel.elements.content.getElementsByTagName('SCRIPT');
|
|
|
|
|
|
for(var rr=0; rr<myScripts.length ; rr++){
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (myScripts[rr].innerHTML!=='')
|
|
|
|
|
|
if (window.execScript)
|
|
|
|
|
|
window.execScript( myScripts[rr].innerHTML, 'javascript' );
|
|
|
|
|
|
else
|
|
|
|
|
|
window.setTimeout( myScripts[rr].innerHTML, 0 );
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
alert(e.description);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* Autosize of panels, to fill only the first child of the
|
|
|
|
|
|
* rendered page (take note)
|
|
|
|
|
|
*/
|
|
|
|
|
|
var panelNonContentHeight = 62;
|
|
|
|
|
|
var panelNonContentWidth = 28;
|
|
|
|
|
|
myPanel.elements.content.style.padding="0px;";
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (autoSizeWidth)
|
|
|
|
|
|
myPanel.resize({w:myPanel.elements.content.childNodes[0].clientWidth+panelNonContentWidth});
|
|
|
|
|
|
if (autoSizeHeight)
|
|
|
|
|
|
myPanel.resize({h:myPanel.elements.content.childNodes[0].clientHeight+panelNonContentHeight});
|
|
|
|
|
|
} catch (e) {
|
2012-07-11 19:07:58 -04:00
|
|
|
|
alert(_('ID_MSG_AJAX_FAILURE'));
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
delete newdiv;
|
|
|
|
|
|
delete myScripts;
|
|
|
|
|
|
myPanel.command(myPanel.loader.hide);
|
|
|
|
|
|
},args:[r, myPanel]});
|
|
|
|
|
|
r.make();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
myPanel.dialogCallback = function ( ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
return myPanel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get an object left position from the upper left viewport corner
|
|
|
|
|
|
// Tested with relative and nested objects
|
|
|
|
|
|
function getAbsoluteLeft(o) {
|
|
|
|
|
|
oLeft = o.offsetLeft // Get left position from the parent object
|
|
|
|
|
|
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
|
|
|
|
|
|
oParent = o.offsetParent // Get parent object reference
|
|
|
|
|
|
oLeft += oParent.offsetLeft // Add parent left position
|
|
|
|
|
|
o = oParent
|
|
|
|
|
|
}
|
|
|
|
|
|
// Return left postion
|
|
|
|
|
|
return oLeft
|
|
|
|
|
|
}
|
|
|
|
|
|
// Get an object top position from the upper left viewport corner
|
|
|
|
|
|
// Tested with relative and nested objects
|
|
|
|
|
|
function getAbsoluteTop(o) {
|
|
|
|
|
|
oTop = o.offsetTop // Get top position from the parent object
|
|
|
|
|
|
while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
|
|
|
|
|
|
oParent = o.offsetParent // Get parent object reference
|
|
|
|
|
|
oTop += oParent.offsetTop // Add parent top position
|
|
|
|
|
|
o = oParent
|
|
|
|
|
|
}
|
|
|
|
|
|
// Return top position
|
|
|
|
|
|
return oTop
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*/
|
|
|
|
|
|
function showHideElement(id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var element;
|
|
|
|
|
|
if (typeof(id)=='object') element=id;
|
|
|
|
|
|
else element=document.getElementById(id);
|
|
|
|
|
|
if (element.style.display==='none') {
|
|
|
|
|
|
switch(element.type) {
|
|
|
|
|
|
case 'table':
|
|
|
|
|
|
element.style.display = 'table';
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
element.style.display = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
element.style.display = 'none';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*/
|
|
|
|
|
|
function showHideSearch(id,aElement,openText,closeText)
|
|
|
|
|
|
{
|
|
|
|
|
|
var element=document.getElementById(id);
|
|
|
|
|
|
if (element.style.display==='none') {
|
|
|
|
|
|
if (!closeText) closeText=G_STRINGS.ID_CLOSE_SEARCH;
|
|
|
|
|
|
if (aElement) {
|
|
|
|
|
|
aElement.innerHTML=closeText;
|
|
|
|
|
|
var bullet = document.getElementById(aElement.id+'[bullet]');
|
|
|
|
|
|
bullet.src='/images/bulletButtonDown.gif';
|
|
|
|
|
|
}
|
|
|
|
|
|
switch(element.type) {
|
|
|
|
|
|
case 'table':
|
|
|
|
|
|
document.getElementById(id).style.display = 'table';
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
document.getElementById(id).style.display = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (!openText) openText=G_STRINGS.ID_OPEN_SEARCH;
|
|
|
|
|
|
if (aElement) {
|
|
|
|
|
|
aElement.innerHTML=openText;
|
|
|
|
|
|
var bullet = document.getElementById(aElement.id+'[bullet]');
|
|
|
|
|
|
bullet.src='/images/bulletButton.gif';
|
|
|
|
|
|
}
|
|
|
|
|
|
document.getElementById(id).style.display = 'none';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* Loads a page but in a non visible div with absolute on (x,y)
|
|
|
|
|
|
* and execute the javascript node that it contains.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function loadPage ( url, x, y , visibility , div ) {
|
2011-08-29 17:24:11 -04:00
|
|
|
|
visibility = typeof(visibility)==='undefined'?'hidden':visibility;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
var r = new leimnud.module.rpc.xmlhttp({url:url});
|
|
|
|
|
|
r.callback=leimnud.closure({Function:function(rpc,div){
|
|
|
|
|
|
if (typeof(div)==='undefined') div=createDiv('');
|
|
|
|
|
|
if (typeof(x)!=='undefined') div.style.left=x;
|
|
|
|
|
|
if (typeof(y)!=='undefined') div.style.top =y;
|
|
|
|
|
|
div.innerHTML=rpc.xmlhttp.responseText;
|
|
|
|
|
|
var myScripts = div.getElementsByTagName('SCRIPT');
|
|
|
|
|
|
for(var rr=0; rr<myScripts.length ; rr++){
|
|
|
|
|
|
try {
|
|
|
|
|
|
if (myScripts[rr].innerHTML!=='')
|
|
|
|
|
|
if (window.execScript)
|
|
|
|
|
|
window.execScript( myScripts[rr].innerHTML, 'javascript' );
|
|
|
|
|
|
else
|
|
|
|
|
|
window.setTimeout( myScripts[rr].innerHTML, 0 );
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
alert(e.description);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
delete div;
|
|
|
|
|
|
delete myScripts;
|
|
|
|
|
|
},args:[r,div]});
|
|
|
|
|
|
r.make();
|
|
|
|
|
|
}
|
|
|
|
|
|
function createDiv(id) {
|
|
|
|
|
|
|
|
|
|
|
|
var newdiv = document.createElement('div');
|
|
|
|
|
|
newdiv.setAttribute('id', id);
|
|
|
|
|
|
|
|
|
|
|
|
newdiv.style.position = "absolute";
|
|
|
|
|
|
newdiv.style.left = 0;
|
|
|
|
|
|
newdiv.style.top = 0;
|
|
|
|
|
|
|
|
|
|
|
|
newdiv.style.visibility="hidden";
|
|
|
|
|
|
|
|
|
|
|
|
document.body.appendChild(newdiv);
|
|
|
|
|
|
|
|
|
|
|
|
return newdiv;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* THIS FUNCTIONS WHERE COPIED FROM JSFORMS */
|
|
|
|
|
|
|
|
|
|
|
|
/*if (window.attachEvent)
|
|
|
|
|
|
window.attachEvent('onload', _OnLoad_);
|
|
|
|
|
|
else
|
|
|
|
|
|
window.addEventListener('load', _OnLoad_, true);*/
|
|
|
|
|
|
|
|
|
|
|
|
//function _OnLoad_() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*onload=function(){
|
|
|
|
|
|
|
|
|
|
|
|
if (self.setNewDates)
|
|
|
|
|
|
self.setNewDates();
|
|
|
|
|
|
|
|
|
|
|
|
if (self.setReloadFields)
|
|
|
|
|
|
self.setReloadFields();
|
|
|
|
|
|
|
|
|
|
|
|
if (self.enableHtmlEdit)
|
|
|
|
|
|
self.enableHtmlEdit();
|
|
|
|
|
|
|
|
|
|
|
|
if (self.dynaformOnloadUsers)
|
|
|
|
|
|
self.dynaformOnloadUsers();
|
|
|
|
|
|
|
|
|
|
|
|
if (self.dynaformOnload)
|
|
|
|
|
|
self.dynaformOnload();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function refillText( fldName, ajax_server, values ) {
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
objetus.open ("GET", ajax_server + "?" + values, false);
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
var textfield = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
if ( ! isdefined( textfield ))
|
|
|
|
|
|
var textfield = document.getElementById( fldName );
|
|
|
|
|
|
textfield.value = '';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
// alert ( objetus.responseText );
|
|
|
|
|
|
var xmlDoc = objetus.responseXML;
|
|
|
|
|
|
if ( xmlDoc ) {
|
|
|
|
|
|
var textfield = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
if ( ! isdefined( textfield ))
|
|
|
|
|
|
var textfield = document.getElementById( fldName );
|
|
|
|
|
|
var dataArray = xmlDoc.getElementsByTagName('value');
|
|
|
|
|
|
if (dataArray[0].firstChild)
|
|
|
|
|
|
if((dataArray[0].firstChild.xml)!='_vacio'){
|
|
|
|
|
|
textfield.value = dataArray[0].firstChild.xml;
|
|
|
|
|
|
if(textfield.type != 'hidden')
|
|
|
|
|
|
if ( textfield.onchange )
|
|
|
|
|
|
textfield.onchange();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function refillCaption( fldName, ajax_server, values ){
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
objetus.open ("GET", ajax_server + "?" + values, false);
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
var textfield = document.getElementById( 'FLD_' + fldName );
|
|
|
|
|
|
textfield.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
var xmlDoc = objetus.responseXML;
|
|
|
|
|
|
if ( xmlDoc ) {
|
|
|
|
|
|
var textfield = document.getElementById( 'FLD_' + fldName );
|
|
|
|
|
|
var dataArray = xmlDoc.getElementsByTagName('value');
|
|
|
|
|
|
if (dataArray[0].firstChild)
|
|
|
|
|
|
if((dataArray[0].firstChild.xml)!='_vacio')
|
|
|
|
|
|
//textfield.innerHTML = '<font size="1">' + dataArray[0].firstChild.xml + '</font>';
|
|
|
|
|
|
textfield.innerHTML = dataArray[0].firstChild.xml;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function refillDropdown( fldName, ajax_server, values , InitValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
objetus.open ("GET", ajax_server + "?" + values, false);
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
var dropdown = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
|
|
|
|
|
|
while ( dropdown.hasChildNodes() )
|
|
|
|
|
|
dropdown.removeChild(dropdown.childNodes[0]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
var xmlDoc = objetus.responseXML;
|
|
|
|
|
|
|
|
|
|
|
|
if ( xmlDoc ) {
|
|
|
|
|
|
var dropdown = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
var dataArray = xmlDoc.getElementsByTagName('item');
|
|
|
|
|
|
itemsNumber = dataArray.length;
|
|
|
|
|
|
|
|
|
|
|
|
if(InitValue == true) itemsNumber = dataArray.length-1;
|
|
|
|
|
|
for (var i=0; i<itemsNumber; i++){
|
|
|
|
|
|
dropdown.options[ dropdown.length] = new Option(dataArray[i].firstChild.xml, dataArray[i].attributes[0].value );
|
|
|
|
|
|
if(InitValue == true) {
|
|
|
|
|
|
if(dropdown.options[ dropdown.length-1].value == dataArray[dataArray.length-1].firstChild.xml)
|
|
|
|
|
|
dropdown.options[i].selected = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
dropdown.onchange();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function iframe_get_xmlhttp() {
|
|
|
|
|
|
try {
|
2011-02-05 08:05:49 +00:00
|
|
|
|
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP2');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
|
|
|
|
|
} catch (E) {
|
|
|
|
|
|
xmlhttp = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
|
|
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
|
|
|
}
|
|
|
|
|
|
return xmlhttp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_xmlhttp() {
|
2011-02-05 08:05:49 +00:00
|
|
|
|
try {
|
|
|
|
|
|
xmlhttp = false;
|
|
|
|
|
|
if ( window.ActiveXObject )
|
|
|
|
|
|
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-02-05 08:05:49 +00:00
|
|
|
|
catch (e) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-02-05 08:05:49 +00:00
|
|
|
|
catch (E) {
|
|
|
|
|
|
xmlhttp = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
|
|
|
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
|
|
|
}
|
|
|
|
|
|
return xmlhttp;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function refillTextError( div_container, fldName, ajax_server, values )
|
|
|
|
|
|
{
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = get_xmlhttp();
|
|
|
|
|
|
objetus.open ("GET", ajax_server + "?" + values, false);
|
|
|
|
|
|
objetus.onreadystatechange=function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
var textfield = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
textfield.value = '';
|
|
|
|
|
|
document.getElementById(div_container).innerHTML = '';
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else if ( objetus.readyState==4)
|
|
|
|
|
|
{
|
|
|
|
|
|
if( objetus.status==200)
|
|
|
|
|
|
{
|
|
|
|
|
|
var xmlDoc = objetus.responseXML;
|
|
|
|
|
|
if ( xmlDoc ) {
|
|
|
|
|
|
var textfield = document.getElementById( 'form[' + fldName + ']' );
|
|
|
|
|
|
var dataArray = xmlDoc.getElementsByTagName('value');
|
|
|
|
|
|
textfield.value = dataArray[0].firstChild.xml;
|
|
|
|
|
|
var dataArray = xmlDoc.getElementsByTagName('message');
|
|
|
|
|
|
if ( dataArray[0].firstChild )
|
|
|
|
|
|
document.getElementById(div_container).innerHTML = '<b>' + dataArray[0].firstChild.xml + '</b>';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function iframe_get_xmlhttp() {
|
|
|
|
|
|
try {
|
2011-02-05 08:05:49 +00:00
|
|
|
|
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP5');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
|
|
|
|
|
|
} catch (E) {
|
|
|
|
|
|
xmlhttp = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
|
|
|
|
|
xmlhttp = new XMLHttpRequest();
|
|
|
|
|
|
}
|
|
|
|
|
|
return xmlhttp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function iframe_ajax_init(ajax_server, div_container, values, callback) {
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = iframe_get_xmlhttp();
|
|
|
|
|
|
objetus.open ('GET', ajax_server + '?' + values, true);
|
|
|
|
|
|
objetus.onreadystatechange = function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 ) {
|
|
|
|
|
|
document.getElementById(div_container).style.display = '';
|
|
|
|
|
|
document.getElementById(div_container).innerHTML = '...';
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (objetus.readyState==4) {
|
|
|
|
|
|
if (objetus.status==200) {
|
|
|
|
|
|
document.getElementById(div_container).innerHTML = objetus.responseText;
|
|
|
|
|
|
if (callback != '')
|
|
|
|
|
|
callback();
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function iframe_ajax_init_2(ajax_server, div_container, values, callback) {
|
|
|
|
|
|
var objetus;
|
|
|
|
|
|
objetus = iframe_get_xmlhttp();
|
|
|
|
|
|
objetus.open ('GET', ajax_server + '?' + values, true);
|
|
|
|
|
|
objetus.onreadystatechange = function() {
|
|
|
|
|
|
if ( objetus.readyState == 1 ) {
|
|
|
|
|
|
div_container.style.display = '';
|
|
|
|
|
|
div_container.innerHTML = '...';
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (objetus.readyState==4) {
|
|
|
|
|
|
if (objetus.status==200) {
|
|
|
|
|
|
div_container.innerHTML = objetus.responseText;
|
|
|
|
|
|
if (callback != '')
|
|
|
|
|
|
callback();
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
window.alert('error-['+ objetus.status +']-' + objetus.responseText );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
objetus.send(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function myEmptyCallback() {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function disable (obj) {
|
|
|
|
|
|
obj.disabled = true;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function enable (obj) {
|
|
|
|
|
|
obj.disabled = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function disableById (id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
obj.disabled = true;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function enableById (id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
obj.disabled = false;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function visible (obj) {
|
|
|
|
|
|
if (obj.style) {
|
|
|
|
|
|
obj.style.visibility = 'visible';
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hidden (obj) {
|
|
|
|
|
|
if (obj.style) {
|
|
|
|
|
|
obj.style.visibility = 'hidden';
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function visibleById (id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
obj.style.visibility = 'visible';
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hiddenById (id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
obj.style.visibility = 'hidden';
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function hiddenRowById (id) {
|
|
|
|
|
|
row = 'DIV_'+ id +'.style.visibility = \'hidden\';';
|
|
|
|
|
|
hiden = 'DIV_'+ id +'.style.display = \'none\';';
|
|
|
|
|
|
eval(row);
|
|
|
|
|
|
eval(hiden);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
function visibleRowById (id) {
|
|
|
|
|
|
row = 'DIV_'+ id +'.style.visibility = \'visible\';';
|
|
|
|
|
|
block = 'DIV_'+ id +'.style.display = \'block\';';
|
|
|
|
|
|
eval(row);
|
|
|
|
|
|
eval(block);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setFocus (obj) {
|
|
|
|
|
|
obj.focus();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function setFocusById (id) {
|
|
|
|
|
|
obj = getField (id);
|
|
|
|
|
|
setFocus(obj);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function submitForm () {
|
2011-10-25 18:35:35 -04:00
|
|
|
|
document.forms[0].submit();
|
2010-12-02 23:34:41 +00:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function changeValue(id, newValue) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
obj.value = newValue;
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getValue(obj) {
|
|
|
|
|
|
return obj.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getValueById (id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
return obj.value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function removeCurrencySign (snumber) {
|
|
|
|
|
|
var aux = '';
|
|
|
|
|
|
var num = new String (snumber);
|
|
|
|
|
|
var len = num.length;
|
|
|
|
|
|
var i = 0;
|
|
|
|
|
|
for (i=0; !(i>=len); i++)
|
|
|
|
|
|
if (num.charAt(i) != ',' && num.charAt(i) != '$' && num.charAt(i) != ' ') aux = aux + num.charAt(i);
|
|
|
|
|
|
return aux;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function removePercentageSign (snumber) {
|
|
|
|
|
|
var aux = '';
|
|
|
|
|
|
var num = new String (snumber);
|
|
|
|
|
|
var len = num.length;
|
|
|
|
|
|
var i = 0;
|
|
|
|
|
|
for (i=0; !(i>=len); i++)
|
|
|
|
|
|
if (num.charAt(i) != ',' && num.charAt(i) != '%' && num.charAt(i) != ' ') aux = aux + num.charAt(i);
|
|
|
|
|
|
return aux;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toReadOnly(obj) {
|
|
|
|
|
|
if (obj) {
|
|
|
|
|
|
obj.readOnly = 'readOnly';
|
|
|
|
|
|
obj.style.background = '#CCCCCC';
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function toReadOnlyById(id) {
|
|
|
|
|
|
obj = getField(id);
|
|
|
|
|
|
if (obj) {
|
|
|
|
|
|
obj.readOnly = 'readOnly';
|
|
|
|
|
|
obj.style.background = '#CCCCCC';
|
|
|
|
|
|
}
|
|
|
|
|
|
return ;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getGridField(Grid, Row, Field) {
|
|
|
|
|
|
obj = document.getElementById('form[' + Grid + ']' + '[' + Row + ']' + '[' + Field + ']');
|
|
|
|
|
|
return obj;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getGridValueById(Grid, Row, Field) {
|
|
|
|
|
|
obj = getGridField(Grid, Row, Field);
|
|
|
|
|
|
if (obj)
|
|
|
|
|
|
return obj.value;
|
|
|
|
|
|
else
|
|
|
|
|
|
return '';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function Number_Rows_Grid(Grid, Field) {
|
|
|
|
|
|
Number_Rows = 1;
|
|
|
|
|
|
if (getGridField(Grid, Number_Rows, Field)) {
|
|
|
|
|
|
Number_Rows = 0;
|
|
|
|
|
|
while (getGridField(Grid, (Number_Rows + 1), Field))
|
|
|
|
|
|
Number_Rows++;
|
|
|
|
|
|
return Number_Rows;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function attachFunctionEventOnChange(Obj, TheFunction) {
|
|
|
|
|
|
Obj.oncustomize = TheFunction;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function attachFunctionEventOnChangeById(Id, TheFunction) {
|
|
|
|
|
|
Obj = getField(Id);
|
|
|
|
|
|
Obj.oncustomize = TheFunction;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function attachFunctionEventOnKeypress(Obj, TheFunction) {
|
|
|
|
|
|
Obj.attachEvent('onkeypress', TheFunction);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function attachFunctionEventOnKeypressById(Id, TheFunction) {
|
|
|
|
|
|
Obj = getField(Id);
|
|
|
|
|
|
Obj.attachEvent('onkeypress', TheFunction);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function unselectOptions ( field ) {
|
|
|
|
|
|
var radios = document.getElementById('form[' + field + ']');
|
|
|
|
|
|
if (radios) {
|
|
|
|
|
|
var inputs = radios.getElementsByTagName ('input');
|
|
|
|
|
|
if (inputs) {
|
|
|
|
|
|
for(var i = 0; i < inputs.length; ++i) {
|
|
|
|
|
|
inputs[i].checked = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
/* @author Alvaro Campos Sanchez
|
|
|
|
|
|
*/
|
2012-08-15 20:00:54 -04:00
|
|
|
|
function validDate(TheField, Required) {
|
2011-08-09 15:24:43 -04:00
|
|
|
|
|
|
|
|
|
|
var date = TheField.split("-");
|
|
|
|
|
|
var date1 = date[0];
|
|
|
|
|
|
var date2 = date[1];
|
|
|
|
|
|
var date3 = date[2];
|
|
|
|
|
|
var TheDay,TheMonth,TheYear;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
if ((date1.length==4)&&(!TheYear))
|
|
|
|
|
|
TheYear = date1;
|
|
|
|
|
|
if (date1.length==2)
|
2012-08-15 20:00:54 -04:00
|
|
|
|
if ((date1>0)&&(date1<=12)&&(!TheMonth))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheMonth = date1;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
else
|
|
|
|
|
|
if ((date1>0)&&(date1<=31)&&(!TheDay))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheDay = date1;
|
|
|
|
|
|
else
|
|
|
|
|
|
TheYear = date1;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
if ((date2.length==4)&&(!TheYear))
|
|
|
|
|
|
TheYear = date2;
|
|
|
|
|
|
if (date2.length==2)
|
2012-08-15 20:00:54 -04:00
|
|
|
|
if ((date2>0)&&(date2<=12)&&(!TheMonth))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheMonth = date2;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
else
|
|
|
|
|
|
if ((date2>0)&&(date2<=31)&&(!TheDay))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheDay = date2;
|
|
|
|
|
|
else
|
2012-08-15 20:00:54 -04:00
|
|
|
|
TheYear = date2;
|
|
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
if((date3.length==4)&&(!TheYear))
|
|
|
|
|
|
TheYear = date3;
|
|
|
|
|
|
if (date3.length==2)
|
2012-08-15 20:00:54 -04:00
|
|
|
|
if ((date3>0)&&(date3<=12)&&(!TheMonth))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheMonth = date3;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
else
|
|
|
|
|
|
if ((date3>0)&&(date3<=31)&&(!TheDay))
|
2011-08-09 15:24:43 -04:00
|
|
|
|
TheDay = date3;
|
|
|
|
|
|
else
|
2012-08-15 20:00:54 -04:00
|
|
|
|
TheYear = date3;
|
|
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
if (!TheYear || !TheMonth || !TheDay)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
if ((Required)||(Required=='true'))
|
|
|
|
|
|
if ((TheYear == 0) || (TheMonth == 0) || (TheDay == 0))
|
|
|
|
|
|
return false;
|
|
|
|
|
|
if (TheMonth == 02)
|
|
|
|
|
|
if (TheDay > 29)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
if ((TheMonth != 02)&&(TheMonth < 13)&&(TheMonth > 0))
|
|
|
|
|
|
if (TheDay > 30)
|
|
|
|
|
|
return false;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2011-08-09 15:24:43 -04:00
|
|
|
|
return true;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* @author David S. Callizaya S.
|
|
|
|
|
|
*/
|
|
|
|
|
|
function globalEval(scriptCode) {
|
|
|
|
|
|
if (scriptCode!=='')
|
|
|
|
|
|
if (window.execScript)
|
|
|
|
|
|
window.execScript( scriptCode, 'javascript' );
|
|
|
|
|
|
else
|
|
|
|
|
|
window.setTimeout( scriptCode, 0 );
|
|
|
|
|
|
}
|
|
|
|
|
|
function switchImage(oImg,url1,url2){
|
|
|
|
|
|
if (oImg && (url2!=='')) {
|
|
|
|
|
|
oImg.src=(oImg.src.substr(oImg.src.length-url1.length,url1.length)===url1)? url2: url1;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
function MM_preloadImages() { //v3.0
|
|
|
|
|
|
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
|
|
|
|
|
|
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
|
|
|
|
|
|
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
|
|
|
|
|
|
}
|
|
|
|
|
|
function backImage(oImg,p){
|
|
|
|
|
|
oImg.style.background=p;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* javascript para el toolbar */
|
|
|
|
|
|
var lc=false;
|
|
|
|
|
|
var sh=function(a,i)
|
|
|
|
|
|
{
|
|
|
|
|
|
var c = (a.nextSibling.nextSibling)?a.nextSibling.nextSibling:a.nextSibling;
|
|
|
|
|
|
if(lc && lc.c!=i){
|
|
|
|
|
|
lc.d.style.display='none';
|
|
|
|
|
|
lc.a.style.color='#666';
|
|
|
|
|
|
}
|
|
|
|
|
|
lc={d:c,c:i,a:a};
|
|
|
|
|
|
a.style.color=(c.style.display=='' || c.style.display=='none')?"black":"#666";
|
|
|
|
|
|
c.style.display=(!c.style.display || c.style.display=='none')?"block":"none";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Set focus to first field from a dynaform
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @return false
|
|
|
|
|
|
*/
|
|
|
|
|
|
function dynaformSetFocus(){
|
|
|
|
|
|
/* looking for the inputs fields */
|
|
|
|
|
|
var inputs = document.getElementsByTagName('input');
|
|
|
|
|
|
if(inputs.length > 0){
|
|
|
|
|
|
for(i in inputs){
|
|
|
|
|
|
type = inputs[i].type;
|
|
|
|
|
|
if(type == "text" || type == "radio" || type == "checkbox" || type == "file" || type == "password"){
|
|
|
|
|
|
try {
|
|
|
|
|
|
inputs[i].focus();
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
//nothing
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
/* if there is no inputs fields, maybe it has a textarea field */
|
|
|
|
|
|
var ta = document.getElementsByTagName('textarea');
|
|
|
|
|
|
if(ta.length > 0){
|
|
|
|
|
|
inputs[0].focus();
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-01-18 10:21:50 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* Set id from id_label if it does not exist
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author alvaro <alvaro@colosa.com, alvaro.cs@live.com>
|
|
|
|
|
|
* @return false
|
|
|
|
|
|
*/
|
2012-08-15 20:00:54 -04:00
|
|
|
|
function idSet(name){
|
2012-01-18 10:21:50 -04:00
|
|
|
|
var inputs = document.getElementsByTagName('input');
|
|
|
|
|
|
if(inputs.length > 0){
|
|
|
|
|
|
for(i in inputs){
|
2012-08-15 20:00:54 -04:00
|
|
|
|
id = inputs[i].id;
|
2012-01-18 10:21:50 -04:00
|
|
|
|
if(id == "form["+name+"_label]"){
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2012-01-18 10:21:50 -04:00
|
|
|
|
if(inputs[i].value.trim())
|
2012-08-15 20:00:54 -04:00
|
|
|
|
var valueLabel = inputs[i].value;
|
2012-01-18 10:21:50 -04:00
|
|
|
|
else
|
2012-08-15 20:00:54 -04:00
|
|
|
|
var valueLabel = "Empty";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-01-18 10:21:50 -04:00
|
|
|
|
if(id == "form["+name+"]"){
|
2012-08-15 20:00:54 -04:00
|
|
|
|
try {
|
2012-01-18 10:21:50 -04:00
|
|
|
|
if(valueLabel !="Empty"){
|
|
|
|
|
|
if (! inputs[i].value)
|
2012-08-15 20:00:54 -04:00
|
|
|
|
inputs[i].value = valueLabel;
|
|
|
|
|
|
}else
|
|
|
|
|
|
inputs[i].value = "";
|
|
|
|
|
|
|
2012-01-18 10:21:50 -04:00
|
|
|
|
} catch (e) {
|
|
|
|
|
|
//nothing
|
|
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2012-01-18 10:21:50 -04:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2012-01-18 10:21:50 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
/**
|
|
|
|
|
|
* ********************************* Misc Functions by Neyek ****************************************
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* get the htmlentities from a string
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param (string) string within the htmlentities to parse
|
|
|
|
|
|
* @Param (string) quote_style it can be (ENT_QUOTES or ENT_NOQUOTES)
|
|
|
|
|
|
* @Return (string) the parsed string with htmlentities at the string passed such as parameter
|
|
|
|
|
|
*/
|
2012-03-12 10:53:06 -04:00
|
|
|
|
function htmlentities (string, quote_style, charset, double_encode) {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
// Convert all applicable characters to HTML entities
|
|
|
|
|
|
//
|
2012-03-12 10:53:06 -04:00
|
|
|
|
// version: 1109.2015
|
|
|
|
|
|
// discuss at: http://phpjs.org/functions/htmlentities // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
|
|
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
|
|
// + improved by: nobbler
|
|
|
|
|
|
// + tweaked by: Jack
|
|
|
|
|
|
// + bugfixed by: Onno Marsman // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
|
|
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
|
|
// + input by: Ratheous
|
|
|
|
|
|
// + improved by: Rafał Kukawski (http://blog.kukawski.pl)
|
|
|
|
|
|
// + improved by: Dj (http://phpjs.org/functions/htmlentities:425#comment_134018) // - depends on: get_html_translation_table
|
|
|
|
|
|
// * example 1: htmlentities('Kevin & van Zonneveld');
|
|
|
|
|
|
// * returns 1: 'Kevin & van Zonneveld'
|
|
|
|
|
|
// * example 2: htmlentities("foo'bar","ENT_QUOTES");
|
2012-08-15 20:00:54 -04:00
|
|
|
|
// * returns 2: 'foo'bar'
|
|
|
|
|
|
var hash_map = get_html_translation_table('HTML_ENTITIES', quote_style), symbol = '';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
|
|
|
|
|
|
string = string == null ? '' : string + '';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
|
|
|
|
|
if (!hash_map) {
|
2012-03-12 10:53:06 -04:00
|
|
|
|
return false;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2012-03-12 10:53:06 -04:00
|
|
|
|
if (quote_style && quote_style === 'ENT_QUOTES') {
|
|
|
|
|
|
hash_map["'"] = '''; }
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2012-03-12 10:53:06 -04:00
|
|
|
|
if (!!double_encode || double_encode == null) {
|
|
|
|
|
|
for (symbol in hash_map) {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
if (hash_map.hasOwnProperty(symbol)) {
|
2012-03-12 10:53:06 -04:00
|
|
|
|
string = string.split(symbol).join(hash_map[symbol]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
string = string.replace(/([\s\S]*?)(&(?:#\d+|#x[\da-f]+|[a-zA-Z][\da-z]*);|$)/g, function (ignore, text, entity) {
|
2012-03-12 10:53:06 -04:00
|
|
|
|
for (symbol in hash_map) {
|
|
|
|
|
|
if (hash_map.hasOwnProperty(symbol)) {
|
|
|
|
|
|
text = text.split(symbol).join(hash_map[symbol]);
|
|
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2012-03-12 10:53:06 -04:00
|
|
|
|
return text + entity;
|
|
|
|
|
|
});
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-03-12 10:53:06 -04:00
|
|
|
|
return string.toString();
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-03-12 10:53:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
2011-06-28 12:02:12 -04:00
|
|
|
|
function utf8_encode (argString) {
|
|
|
|
|
|
var utftext = "",
|
|
|
|
|
|
start, end, stringl = 0;
|
|
|
|
|
|
var string = argString;
|
|
|
|
|
|
start = end = 0;
|
|
|
|
|
|
stringl = string.length;
|
|
|
|
|
|
for (var n = 0; n < stringl; n++) {
|
|
|
|
|
|
var c1 = string.charCodeAt(n);
|
|
|
|
|
|
var enc = null;
|
|
|
|
|
|
if (c1 < 128) {
|
|
|
|
|
|
end++;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (c1 > 127 && c1 < 2048) {
|
|
|
|
|
|
enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
|
|
|
enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-06-28 12:02:12 -04:00
|
|
|
|
if (enc !== null) {
|
|
|
|
|
|
if (end > start) {
|
|
|
|
|
|
utftext += string.slice(start, end);
|
|
|
|
|
|
}
|
|
|
|
|
|
utftext += enc;
|
|
|
|
|
|
start = end = n + 1;
|
|
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-06-28 12:02:12 -04:00
|
|
|
|
if (end > start) {
|
|
|
|
|
|
utftext += string.slice(start, stringl);
|
|
|
|
|
|
}
|
|
|
|
|
|
return utftext;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-06-28 12:02:12 -04:00
|
|
|
|
function base64_encode (data) {
|
|
|
|
|
|
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
|
|
|
|
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0,
|
|
|
|
|
|
ac = 0,
|
|
|
|
|
|
enc = "",
|
2012-08-15 20:00:54 -04:00
|
|
|
|
tmp_arr = [];
|
2011-06-28 12:02:12 -04:00
|
|
|
|
if (!data) {
|
|
|
|
|
|
return data;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
|
|
|
|
|
data = utf8_encode(data + '');
|
|
|
|
|
|
do {
|
2011-06-28 12:02:12 -04:00
|
|
|
|
o1 = data.charCodeAt(i++);
|
|
|
|
|
|
o2 = data.charCodeAt(i++);
|
2012-08-15 20:00:54 -04:00
|
|
|
|
o3 = data.charCodeAt(i++);
|
|
|
|
|
|
bits = o1 << 16 | o2 << 8 | o3;
|
2011-06-28 12:02:12 -04:00
|
|
|
|
h1 = bits >> 18 & 0x3f;
|
|
|
|
|
|
h2 = bits >> 12 & 0x3f;
|
|
|
|
|
|
h3 = bits >> 6 & 0x3f;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
h4 = bits & 0x3f;
|
2011-06-28 12:02:12 -04:00
|
|
|
|
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
|
2012-08-15 20:00:54 -04:00
|
|
|
|
} while (i < data.length);
|
|
|
|
|
|
enc = tmp_arr.join('');
|
2011-06-28 12:02:12 -04:00
|
|
|
|
switch (data.length % 3) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
enc = enc.slice(0, -2) + '==';
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
enc = enc.slice(0, -1) + '=';
|
|
|
|
|
|
break;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2011-06-28 12:02:12 -04:00
|
|
|
|
return enc;
|
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
2012-03-12 10:53:06 -04:00
|
|
|
|
function get_html_translation_table (table, quote_style) {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
// Returns the internal translation table used by htmlspecialchars and htmlentities
|
|
|
|
|
|
//
|
2012-03-12 10:53:06 -04:00
|
|
|
|
// version: 1109.2015
|
|
|
|
|
|
// discuss at: http://phpjs.org/functions/get_html_translation_table // + original by: Philip Peterson
|
|
|
|
|
|
// + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
|
|
|
// + bugfixed by: noname
|
|
|
|
|
|
// + bugfixed by: Alex
|
|
|
|
|
|
// + bugfixed by: Marco // + bugfixed by: madipta
|
|
|
|
|
|
// + improved by: KELAN
|
|
|
|
|
|
// + improved by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
|
|
// + bugfixed by: Brett Zamir (http://brett-zamir.me)
|
|
|
|
|
|
// + input by: Frank Forte // + bugfixed by: T.Wild
|
|
|
|
|
|
// + input by: Ratheous
|
|
|
|
|
|
// % note: It has been decided that we're not going to add global
|
|
|
|
|
|
// % note: dependencies to php.js, meaning the constants are not
|
|
|
|
|
|
// % note: real constants, but strings instead. Integers are also supported if someone // % note: chooses to create the constants themselves.
|
|
|
|
|
|
// * example 1: get_html_translation_table('HTML_SPECIALCHARS');
|
|
|
|
|
|
// * returns 1: {'"': '"', '&': '&', '<': '<', '>': '>'}
|
|
|
|
|
|
var entities = {},
|
|
|
|
|
|
hash_map = {}, decimal;
|
|
|
|
|
|
var constMappingTable = {},
|
|
|
|
|
|
constMappingQuoteStyle = {};
|
|
|
|
|
|
var useTable = {},
|
2012-08-15 20:00:54 -04:00
|
|
|
|
useQuoteStyle = {};
|
2010-12-02 23:34:41 +00:00
|
|
|
|
// Translate arguments
|
2012-03-12 10:53:06 -04:00
|
|
|
|
constMappingTable[0] = 'HTML_SPECIALCHARS';
|
|
|
|
|
|
constMappingTable[1] = 'HTML_ENTITIES';
|
|
|
|
|
|
constMappingQuoteStyle[0] = 'ENT_NOQUOTES'; constMappingQuoteStyle[2] = 'ENT_COMPAT';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
constMappingQuoteStyle[3] = 'ENT_QUOTES';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2012-03-12 10:53:06 -04:00
|
|
|
|
useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
|
2012-03-12 10:53:06 -04:00
|
|
|
|
throw new Error("Table: " + useTable + ' not supported');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
// return false;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['38'] = '&';
|
|
|
|
|
|
if (useTable === 'HTML_ENTITIES') {
|
|
|
|
|
|
entities['160'] = ' ';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['161'] = '¡'; entities['162'] = '¢';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['163'] = '£';
|
|
|
|
|
|
entities['164'] = '¤';
|
|
|
|
|
|
entities['165'] = '¥';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['166'] = '¦'; entities['167'] = '§';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['168'] = '¨';
|
|
|
|
|
|
entities['169'] = '©';
|
|
|
|
|
|
entities['170'] = 'ª';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['171'] = '«'; entities['172'] = '¬';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['173'] = '­';
|
|
|
|
|
|
entities['174'] = '®';
|
|
|
|
|
|
entities['175'] = '¯';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['176'] = '°'; entities['177'] = '±';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['178'] = '²';
|
|
|
|
|
|
entities['179'] = '³';
|
|
|
|
|
|
entities['180'] = '´';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['181'] = 'µ'; entities['182'] = '¶';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['183'] = '·';
|
|
|
|
|
|
entities['184'] = '¸';
|
|
|
|
|
|
entities['185'] = '¹';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['186'] = 'º'; entities['187'] = '»';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['188'] = '¼';
|
|
|
|
|
|
entities['189'] = '½';
|
|
|
|
|
|
entities['190'] = '¾';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['191'] = '¿'; entities['192'] = 'À';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['193'] = 'Á';
|
|
|
|
|
|
entities['194'] = 'Â';
|
|
|
|
|
|
entities['195'] = 'Ã';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['196'] = 'Ä'; entities['197'] = 'Å';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['198'] = 'Æ';
|
|
|
|
|
|
entities['199'] = 'Ç';
|
|
|
|
|
|
entities['200'] = 'È';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['201'] = 'É'; entities['202'] = 'Ê';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['203'] = 'Ë';
|
|
|
|
|
|
entities['204'] = 'Ì';
|
|
|
|
|
|
entities['205'] = 'Í';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['206'] = 'Î'; entities['207'] = 'Ï';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['208'] = 'Ð';
|
|
|
|
|
|
entities['209'] = 'Ñ';
|
|
|
|
|
|
entities['210'] = 'Ò';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['211'] = 'Ó'; entities['212'] = 'Ô';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['213'] = 'Õ';
|
|
|
|
|
|
entities['214'] = 'Ö';
|
|
|
|
|
|
entities['215'] = '×';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['216'] = 'Ø'; entities['217'] = 'Ù';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['218'] = 'Ú';
|
|
|
|
|
|
entities['219'] = 'Û';
|
|
|
|
|
|
entities['220'] = 'Ü';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['221'] = 'Ý'; entities['222'] = 'Þ';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['223'] = 'ß';
|
|
|
|
|
|
entities['224'] = 'à';
|
|
|
|
|
|
entities['225'] = 'á';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['226'] = 'â'; entities['227'] = 'ã';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['228'] = 'ä';
|
|
|
|
|
|
entities['229'] = 'å';
|
|
|
|
|
|
entities['230'] = 'æ';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['231'] = 'ç'; entities['232'] = 'è';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['233'] = 'é';
|
|
|
|
|
|
entities['234'] = 'ê';
|
|
|
|
|
|
entities['235'] = 'ë';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['236'] = 'ì'; entities['237'] = 'í';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['238'] = 'î';
|
|
|
|
|
|
entities['239'] = 'ï';
|
|
|
|
|
|
entities['240'] = 'ð';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['241'] = 'ñ'; entities['242'] = 'ò';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['243'] = 'ó';
|
|
|
|
|
|
entities['244'] = 'ô';
|
|
|
|
|
|
entities['245'] = 'õ';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['246'] = 'ö'; entities['247'] = '÷';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['248'] = 'ø';
|
|
|
|
|
|
entities['249'] = 'ù';
|
|
|
|
|
|
entities['250'] = 'ú';
|
2012-03-12 10:53:06 -04:00
|
|
|
|
entities['251'] = 'û'; entities['252'] = 'ü';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
entities['253'] = 'ý';
|
|
|
|
|
|
entities['254'] = 'þ';
|
|
|
|
|
|
entities['255'] = 'ÿ';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
if (useQuoteStyle !== 'ENT_NOQUOTES') {
|
|
|
|
|
|
entities['34'] = '"';
|
|
|
|
|
|
}
|
2012-03-12 10:53:06 -04:00
|
|
|
|
if (useQuoteStyle === 'ENT_QUOTES') { entities['39'] = ''';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
entities['60'] = '<';
|
|
|
|
|
|
entities['62'] = '>';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
// ascii decimals to real symbols
|
|
|
|
|
|
for (decimal in entities) {
|
2012-03-12 10:53:06 -04:00
|
|
|
|
if (entities.hasOwnProperty(decimal)) {
|
|
|
|
|
|
hash_map[String.fromCharCode(decimal)] = entities[decimal]; }
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
return hash_map;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function stripslashes (str) {
|
|
|
|
|
|
return (str+'').replace(/\\(.?)/g, function (s, n1) {
|
|
|
|
|
|
switch (n1) {
|
|
|
|
|
|
case '\\':
|
|
|
|
|
|
return '\\';
|
|
|
|
|
|
case '0':
|
|
|
|
|
|
return '\0';
|
|
|
|
|
|
case '':
|
|
|
|
|
|
return '';
|
|
|
|
|
|
default:
|
|
|
|
|
|
return n1;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addslashes (str) {
|
|
|
|
|
|
return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\u0000/g, "\\0");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* This function sets netsted properties to dom elements
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param (object) dom element refered by ID
|
|
|
|
|
|
* @Param (array) nested array of properties strings
|
|
|
|
|
|
* @Param (string) value to set
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*
|
|
|
|
|
|
* Example:
|
|
|
|
|
|
* setNestedProperty(document, ['body','style','backgroundColor'], 'black');
|
|
|
|
|
|
*/
|
|
|
|
|
|
function setNestedProperty(obj, propertyName, propertyValue){
|
|
|
|
|
|
var oTarget = obj;
|
|
|
|
|
|
for (var i=0; i<propertyName.length; i++){
|
|
|
|
|
|
if (i == (propertyName.length - 1)){
|
|
|
|
|
|
oTarget[propertyName[i]] = propertyValue;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
oTarget = oTarget[propertyName[i]];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* This function gets the user client browser and its version
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param <none>
|
|
|
|
|
|
* @Return (objeect) {browser:sBrowser, version:sVersion}
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getBrowserClient(){
|
|
|
|
|
|
var aBrowFull = new Array("opera", "msie", "firefox", "opera", "safari");
|
|
|
|
|
|
var sInfo = navigator.userAgent.toLowerCase();
|
|
|
|
|
|
sBrowser = "";
|
|
|
|
|
|
for (var i = 0; i < aBrowFull.length; i++){
|
|
|
|
|
|
if ((sBrowser == "") && (sInfo.indexOf(aBrowFull[i]) != -1)){
|
|
|
|
|
|
sBrowser = aBrowFull[i];
|
|
|
|
|
|
sVersion = String(parseFloat(sInfo.substr(sInfo.indexOf(aBrowFull[i]) + aBrowFull[i].length + 1)));
|
|
|
|
|
|
return {name:sBrowser, browser:sBrowser, version:sVersion}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
};
|
|
|
|
|
|
var _BROWSER = getBrowserClient();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Create and send cookie
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param (string) cookie name
|
|
|
|
|
|
* @Param (string) cookie value
|
|
|
|
|
|
* @Param (int) cookie number of days for expires
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function createCookie(name, value, days){
|
|
|
|
|
|
if (days) {
|
|
|
|
|
|
var date = new Date();
|
|
|
|
|
|
date.setTime(date.getTime()+(days*24*60*60*1000));
|
|
|
|
|
|
var expires = "; expires="+date.toGMTString();
|
|
|
|
|
|
} else var expires = "";
|
|
|
|
|
|
document.cookie = name+"="+value+expires+"; path=/";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* read a cookie
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param cookie name
|
|
|
|
|
|
* @Return (string) cookie content
|
|
|
|
|
|
*/
|
|
|
|
|
|
function readCookie(name){
|
|
|
|
|
|
var ca = document.cookie.split(';');
|
|
|
|
|
|
var nameEQ = name + "=";
|
|
|
|
|
|
for(var i=0; i < ca.length; i++) {
|
|
|
|
|
|
var c = ca[i];
|
|
|
|
|
|
while (c.charAt(0)==' ') c = c.substring(1, c.length); //delete spaces
|
|
|
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* delete a cookie
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param cookie name
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function eraseCookie(name){
|
|
|
|
|
|
createCookie(name, "", -1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* highlightRow a html element (setting background)
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param (object) html element
|
|
|
|
|
|
* @Param (string) some color in hexadecimal format
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function highlightRow(o, color){
|
|
|
|
|
|
o.style.background = color
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* left and right delete the blank characteres (String prototype)
|
|
|
|
|
|
*
|
|
|
|
|
|
* Example:
|
|
|
|
|
|
* var str = String(" some_string_with_spaces ");
|
|
|
|
|
|
* str.trim(); //clean the blank characteres
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param <none>
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*/
|
2012-08-16 15:37:15 -04:00
|
|
|
|
String.prototype.trim = function () {
|
|
|
|
|
|
return this.replace(/^\s+|\s+$/g, "");
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function clearCalendar(id){
|
|
|
|
|
|
document.getElementById(id).value='';
|
|
|
|
|
|
document.getElementById(id+'[div]').innerHTML = '';
|
|
|
|
|
|
setTimeout('enableCalendar()', 350);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function lockCalendar(){
|
|
|
|
|
|
G_CALENDAR_MEM_OFFSET = 'lock';
|
|
|
|
|
|
|
|
|
|
|
|
//G_CALENDAR_CURRENT_OBJ.hide();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function enableCalendar(){
|
|
|
|
|
|
G_CALENDAR_MEM_OFFSET = 'enable';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function parseDateFromMask (inputArray, mask){
|
|
|
|
|
|
/* inputArray is an associative array with properties
|
|
|
|
|
|
year, month, day, hour, minute */
|
|
|
|
|
|
|
|
|
|
|
|
/* format mask
|
|
|
|
|
|
* Y -> 2009
|
|
|
|
|
|
* y -> 09
|
|
|
|
|
|
* m -> 02
|
|
|
|
|
|
* d -> 01
|
|
|
|
|
|
*
|
|
|
|
|
|
* h -> 12
|
|
|
|
|
|
* i -> 59
|
|
|
|
|
|
*
|
|
|
|
|
|
* d/m/y -> 01/02/09
|
|
|
|
|
|
* d/m/Y -> 01/02/2009
|
|
|
|
|
|
* Y-m-d -> 2009-02-01
|
|
|
|
|
|
*
|
|
|
|
|
|
* Y-m-d h:m -> 2009-02-01 12:59
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
result = mask;
|
|
|
|
|
|
result = result.replace("Y", inputArray.year);
|
|
|
|
|
|
|
|
|
|
|
|
year = new String(inputArray.year);
|
|
|
|
|
|
result = result.replace("y", year.substr(2,3));
|
|
|
|
|
|
result = result.replace("m", inputArray.month);
|
|
|
|
|
|
result = result.replace("d", inputArray.day);
|
|
|
|
|
|
result = result.replace("h", inputArray.hour);
|
|
|
|
|
|
result = result.replace("i", inputArray.minute);
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Array.prototype.walk = function( funcionaplicada ) {
|
|
|
|
|
|
for(var i=0, parar=false; i<this.length && !parar; i++ )
|
|
|
|
|
|
parar = funcionaplicada( this[i], i);
|
|
|
|
|
|
return (this.length==i)? false : (i-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Array.prototype.find = function(q) {
|
|
|
|
|
|
var dev = this.walk(function(elem) {
|
|
|
|
|
|
if( elem==q )
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} );
|
|
|
|
|
|
if( this[dev]==q ) return dev;
|
|
|
|
|
|
else return -1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Array.prototype.drop = function(x) {
|
|
|
|
|
|
this.splice(x,1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Array.prototype.deleteByValue = function(val) {
|
|
|
|
|
|
var eindex = this.find(val);
|
|
|
|
|
|
this.drop(eindex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* schedule a action js callback
|
|
|
|
|
|
*
|
|
|
|
|
|
* @Author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
|
|
|
|
|
|
* @Param (string) function name
|
|
|
|
|
|
* @Param (int) time in seconds
|
|
|
|
|
|
* @Return <none>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function Timer(functionName, time) {
|
|
|
|
|
|
setTimeout(functionName, time*1000);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function PMOS_TemporalMessage(timeToHide){
|
|
|
|
|
|
fade('temporalMessageTD', 'inOut');
|
|
|
|
|
|
if( typeof(timeToHide) != 'undefined' ) {
|
|
|
|
|
|
Timer(
|
|
|
|
|
|
function(){
|
|
|
|
|
|
try{
|
|
|
|
|
|
document.getElementById('temporalMessageTD').style.display = 'none';
|
|
|
|
|
|
}catch(e){}
|
|
|
|
|
|
},
|
|
|
|
|
|
timeToHide
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* fast messagesbox
|
2012-08-15 20:00:54 -04:00
|
|
|
|
*
|
2010-12-02 23:34:41 +00:00
|
|
|
|
* @Param msg (string) : your message
|
|
|
|
|
|
* @Param type (string): {alert|info|confirm}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
* @Param type (string): xcallback, callback function name to execute after at user click on Accept
|
2010-12-02 23:34:41 +00:00
|
|
|
|
* @Author <erik@colosa.com>
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
function msgBox(msg, type, callbackAccept, callbackCancel){
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
//setting default type
|
|
|
|
|
|
type = typeof(type) != 'undefined'? type: 'info';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
//setting up the callback action
|
|
|
|
|
|
acceptEv = typeof(callbackAccept) != 'undefined'? callbackAccept: false;
|
|
|
|
|
|
cancelEv = typeof(callbackCancel) != 'undefined'? callbackCancel: false;
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
switch(type){
|
|
|
|
|
|
case 'alert':
|
|
|
|
|
|
new leimnud.module.app.alert().make({
|
|
|
|
|
|
label: msg,
|
|
|
|
|
|
width: 350,
|
|
|
|
|
|
action:function(){
|
|
|
|
|
|
if( acceptEv ){
|
|
|
|
|
|
setTimeout(acceptEv, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}.extend(this)
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'info':
|
|
|
|
|
|
new leimnud.module.app.info().make({
|
|
|
|
|
|
label: msg,
|
|
|
|
|
|
width: 350,
|
|
|
|
|
|
action:function(){
|
|
|
|
|
|
if( acceptEv ){
|
|
|
|
|
|
setTimeout(acceptEv, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}.extend(this)
|
|
|
|
|
|
});
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'confirm':
|
|
|
|
|
|
if( cancelEv ){
|
|
|
|
|
|
new leimnud.module.app.confirm().make({
|
|
|
|
|
|
label: msg,
|
|
|
|
|
|
action: function(){
|
|
|
|
|
|
if( acceptEv ){
|
|
|
|
|
|
setTimeout(acceptEv, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
}.extend(this),
|
|
|
|
|
|
cancel: function(){
|
|
|
|
|
|
setTimeout(cancelEv, 1);
|
|
|
|
|
|
}.extend(this)
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
new leimnud.module.app.confirm().make({
|
|
|
|
|
|
label: msg,
|
|
|
|
|
|
action: function(){
|
|
|
|
|
|
if( acceptEv ){
|
|
|
|
|
|
setTimeout(acceptEv, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}.extend(this)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
break;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function executeEvent(id, ev){
|
|
|
|
|
|
switch(ev){
|
|
|
|
|
|
case 'click':
|
|
|
|
|
|
document.getElementById(id).checked = true;
|
|
|
|
|
|
if(document.getElementById(id).onclick){
|
|
|
|
|
|
try{
|
2012-08-15 20:00:54 -04:00
|
|
|
|
document.getElementById(id).onclick();
|
|
|
|
|
|
}catch(e){}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* @By Erik
|
|
|
|
|
|
*/
|
|
|
|
|
|
function getClientWindowSize() {
|
2011-07-15 11:57:55 -04:00
|
|
|
|
var wSize = [1024, 768];
|
2010-12-02 23:34:41 +00:00
|
|
|
|
if (typeof window.innerWidth != 'undefined'){
|
|
|
|
|
|
wSize = [
|
|
|
|
|
|
window.innerWidth,
|
|
|
|
|
|
window.innerHeight
|
|
|
|
|
|
];
|
|
|
|
|
|
} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){
|
|
|
|
|
|
wSize = [
|
|
|
|
|
|
document.documentElement.clientWidth,
|
|
|
|
|
|
document.documentElement.clientHeight
|
|
|
|
|
|
];
|
|
|
|
|
|
} else {
|
2011-07-15 11:57:55 -04:00
|
|
|
|
var body = document.getElementsByTagName('body');
|
|
|
|
|
|
if(typeof body != 'undefined' && typeof body[0] != 'undefined' && typeof body[0].clientWidth != 'undefined') {
|
2010-12-02 23:34:41 +00:00
|
|
|
|
wSize = [
|
2011-07-15 11:57:55 -04:00
|
|
|
|
document.getElementsByTagName('body')[0].clientWidth,
|
|
|
|
|
|
document.getElementsByTagName('body')[0].clientHeight
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
return {width:wSize[0], height:wSize[1]};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function popUp(URL, width, height, left, top, resizable) {
|
|
|
|
|
|
window.open(URL, '', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable='+resizable+',width='+width+',height='+height+',left = '+left+',top = '+top+'');
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Alias for tedious large definition for ajax object - By Erik A.O. <erik@colosa.com>
|
|
|
|
|
|
*/
|
|
|
|
|
|
function XHRequest(){
|
|
|
|
|
|
return new leimnud.module.rpc.xmlhttp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function removeValue(id){
|
|
|
|
|
|
if( document.getElementById('form['+id+']') )
|
|
|
|
|
|
document.getElementById('form['+id+']').value = '';
|
|
|
|
|
|
else if( document.getElementById(id) )
|
|
|
|
|
|
document.getElementById(id).value = '';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2011-02-21 19:31:39 +00:00
|
|
|
|
fireEvent(document.getElementById(id), 'change');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-24 13:28:49 -04:00
|
|
|
|
var countButtonDone = 0;
|
|
|
|
|
|
|
2011-12-02 18:21:46 -04:00
|
|
|
|
function datePicker4(obj, id, mask, startDate, endDate, showTIme, idIsoDate)
|
2012-08-15 20:00:54 -04:00
|
|
|
|
{
|
2012-12-21 14:45:30 -04:00
|
|
|
|
var aux = id.replace(/[\[\]]/g, '_');
|
|
|
|
|
|
__lastMasks__[aux] = mask;
|
|
|
|
|
|
|
2011-12-02 18:21:46 -04:00
|
|
|
|
if (showTIme=='false') {
|
|
|
|
|
|
showTIme = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-24 13:28:49 -04:00
|
|
|
|
countButtonDone = countButtonDone + 1;
|
|
|
|
|
|
|
2011-09-20 12:02:28 -04:00
|
|
|
|
Calendar.setup({
|
2011-12-02 18:21:46 -04:00
|
|
|
|
inputField: id,
|
|
|
|
|
|
dateFormat: mask,
|
|
|
|
|
|
trigger: id + "[btn]",
|
|
|
|
|
|
bottomBar: true,
|
|
|
|
|
|
min:startDate,
|
|
|
|
|
|
max:endDate,
|
|
|
|
|
|
animation: _BROWSER.name =='msie'? false: true,
|
|
|
|
|
|
showTime: showTIme,
|
2013-05-24 13:28:49 -04:00
|
|
|
|
showButtonDone: (showTIme)? 1 : 0,
|
|
|
|
|
|
iButtonDone: countButtonDone,
|
2011-12-02 18:21:46 -04:00
|
|
|
|
opacity: 1,
|
2013-05-24 13:28:49 -04:00
|
|
|
|
onSelect: function ()
|
|
|
|
|
|
{
|
2011-12-02 18:21:46 -04:00
|
|
|
|
/* disabled temporarily by wrong functionality
|
|
|
|
|
|
auxid = id;
|
|
|
|
|
|
idIsoDate = auxid.substring(0,auxid.length-1)+'_isodate]';
|
|
|
|
|
|
var field= document.getElementById(idIsoDate);
|
|
|
|
|
|
field.value=this.selection.print("%Y-%m-%d", ""); */
|
2013-05-24 13:28:49 -04:00
|
|
|
|
|
|
|
|
|
|
if (!this.args.showButtonDone || this.args.showButtonDone == 0) {
|
|
|
|
|
|
this.hide();
|
|
|
|
|
|
|
|
|
|
|
|
fireEvent(document.getElementById(id), "change");
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
onFocus: function ()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.args.showButtonDone && this.args.showButtonDone == 1) {
|
|
|
|
|
|
var thisAux = this;
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById("btnDone" + thisAux.args.iButtonDone).onclick = function ()
|
|
|
|
|
|
{
|
|
|
|
|
|
var v;
|
|
|
|
|
|
|
|
|
|
|
|
if (thisAux.selection.sel.length == 0) {
|
|
|
|
|
|
//thisAux.args.showTime //default false //true for 24h //12 for am/pm
|
|
|
|
|
|
|
|
|
|
|
|
if (thisAux.args.showTime) {
|
|
|
|
|
|
thisAux.date.setHours(thisAux.selection.cal.getHours());
|
|
|
|
|
|
thisAux.date.setMinutes(thisAux.selection.cal.getMinutes());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
v = Calendar.printDate(Calendar.intToDate(thisAux.date), thisAux.args.dateFormat);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
v = thisAux.selection.print(thisAux.args.dateFormat);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById(thisAux.args.inputField).value = v;
|
|
|
|
|
|
|
|
|
|
|
|
//Event
|
|
|
|
|
|
thisAux.hide();
|
|
|
|
|
|
|
|
|
|
|
|
fireEvent(document.getElementById(id), "change");
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2011-12-02 18:21:46 -04:00
|
|
|
|
}
|
2011-01-04 20:51:36 +00:00
|
|
|
|
});
|
2010-12-02 23:34:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-02 18:21:46 -04:00
|
|
|
|
function fireEvent(element, event)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (document.createEventObject){
|
2010-12-24 13:38:03 +00:00
|
|
|
|
// dispatch for IE
|
|
|
|
|
|
var evt = document.createEventObject();
|
2011-12-02 18:21:46 -04:00
|
|
|
|
return element.fireEvent('on' + event,evt)
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
2010-12-24 13:38:03 +00:00
|
|
|
|
// dispatch for firefox + others
|
|
|
|
|
|
var evt = document.createEvent("HTMLEvents");
|
|
|
|
|
|
evt.initEvent(event, true, true ); // event type,bubbling,cancelable
|
|
|
|
|
|
return !element.dispatchEvent(evt);
|
2011-12-02 18:21:46 -04:00
|
|
|
|
}
|
2010-12-24 13:38:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-08-15 20:00:54 -04:00
|
|
|
|
function elementAttributesNS(e, ns)
|
2011-12-02 18:21:46 -04:00
|
|
|
|
{
|
2010-12-02 23:34:41 +00:00
|
|
|
|
if (!this.__namespaceRegexps)
|
|
|
|
|
|
this.__namespaceRegexps = {};
|
|
|
|
|
|
var regexp = this.__namespaceRegexps[ns];
|
|
|
|
|
|
if (!regexp) {
|
|
|
|
|
|
this.__namespaceRegexps[ns] = regexp =
|
|
|
|
|
|
ns ? eval("/^" + ns + ":(.+)/") : /^([^:]*)$/;
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = {};
|
|
|
|
|
|
var atts = e.attributes;
|
|
|
|
|
|
var l = atts.length;
|
|
|
|
|
|
for (var i = 0; i < l; i++) {
|
|
|
|
|
|
var m = atts[i].name.match(regexp);
|
|
|
|
|
|
if (m)
|
|
|
|
|
|
result[m[1]] = atts[i].value;
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2011-01-04 20:51:36 +00:00
|
|
|
|
|
2012-08-15 20:00:54 -04:00
|
|
|
|
/**
|
2012-04-03 20:04:28 -04:00
|
|
|
|
* Translator function for internationalization
|
|
|
|
|
|
*/
|
|
|
|
|
|
function _()
|
|
|
|
|
|
{
|
|
|
|
|
|
var argv = _.arguments;
|
|
|
|
|
|
var argc = argv.length;
|
|
|
|
|
|
|
|
|
|
|
|
if( typeof TRANSLATIONS != 'undefined' && TRANSLATIONS) {
|
|
|
|
|
|
if( typeof TRANSLATIONS[argv[0]] != 'undefined' ) {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
if (argc > 1) {
|
2012-04-03 20:04:28 -04:00
|
|
|
|
trn = TRANSLATIONS[argv[0]];
|
|
|
|
|
|
for (i = 1; i < argv.length; i++) {
|
|
|
|
|
|
trn = trn.replace('{'+(i-1)+'}', argv[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else {
|
2012-08-15 20:00:54 -04:00
|
|
|
|
trn = TRANSLATIONS[argv[0]];
|
2012-04-03 20:04:28 -04:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2012-04-03 20:04:28 -04:00
|
|
|
|
else {
|
|
|
|
|
|
trn = '**' + argv[0] + '**';
|
|
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
}
|
2012-04-03 20:04:28 -04:00
|
|
|
|
else {
|
|
|
|
|
|
PMExt.error('Processmaker JS Core Error', 'The TRANSLATIONS global object is not loaded!');
|
|
|
|
|
|
trn = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
return trn;
|
2012-07-11 19:07:58 -04:00
|
|
|
|
}
|
2012-08-15 20:00:54 -04:00
|
|
|
|
|
2013-03-11 10:29:33 -04:00
|
|
|
|
/**
|
|
|
|
|
|
* Translator function for internationalization to plugins
|
|
|
|
|
|
*/
|
|
|
|
|
|
function __()
|
|
|
|
|
|
{
|
|
|
|
|
|
var argv = __.arguments;
|
|
|
|
|
|
var argc = argv.length;
|
|
|
|
|
|
|
|
|
|
|
|
//argv[0] => NAME PLUGIN
|
|
|
|
|
|
//argv[1] => ID
|
|
|
|
|
|
//argv[2] => VARIABLES
|
|
|
|
|
|
|
|
|
|
|
|
var existTranslations = true;
|
|
|
|
|
|
var existIdLabel = true;
|
2013-03-15 16:07:18 +00:00
|
|
|
|
eval("if( typeof TRANSLATIONS_" + argv[0].toUpperCase() + " != 'undefined' && TRANSLATIONS_" + argv[0].toUpperCase() + ") { existTranslations = true; } else { existTranslations = false; }");
|
|
|
|
|
|
if (existTranslations) {
|
|
|
|
|
|
eval("if( typeof TRANSLATIONS_" + argv[0].toUpperCase() + "[argv[1]] != 'undefined' ) { existIdLabel = true; } else { existIdLabel = false; }");
|
2013-03-11 10:29:33 -04:00
|
|
|
|
if (existIdLabel) {
|
|
|
|
|
|
if (argc > 2) {
|
2013-03-15 16:07:18 +00:00
|
|
|
|
eval("trn = TRANSLATIONS_" + argv[0].toUpperCase() + "[argv[0]];");
|
2013-03-11 10:29:33 -04:00
|
|
|
|
for (i = 2; i < argv.length; i++) {
|
|
|
|
|
|
trn = trn.replace('{'+(i-2)+'}', argv[i]);
|
2013-05-24 13:28:49 -04:00
|
|
|
|
}
|
2013-03-11 10:29:33 -04:00
|
|
|
|
} else {
|
2013-03-15 16:07:18 +00:00
|
|
|
|
eval("trn = TRANSLATIONS_" + argv[0].toUpperCase() + "[argv[1]];");
|
2013-03-11 10:29:33 -04:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
trn = '**' + argv[1] + '**';
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2013-03-15 16:07:18 +00:00
|
|
|
|
PMExt.error('Processmaker JS Core Error', 'The TRANSLATIONS ' + argv[0].toUpperCase() + ' global object is not loaded!');
|
2013-03-11 10:29:33 -04:00
|
|
|
|
trn = '';
|
|
|
|
|
|
}
|
|
|
|
|
|
return trn;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-08-16 15:37:15 -04:00
|
|
|
|
/**
|
2012-12-11 10:26:10 -04:00
|
|
|
|
* String Replace function, if strSearch has special characters "(", "[", must be escape "\\(", "\\[".
|
|
|
|
|
|
*
|
2012-08-16 15:37:15 -04:00
|
|
|
|
*/
|
2012-12-11 10:26:10 -04:00
|
|
|
|
function stringReplace(strSearch, strReplace, str)
|
2012-08-16 15:37:15 -04:00
|
|
|
|
{
|
|
|
|
|
|
var expression = eval("/" + strSearch + "/g");
|
|
|
|
|
|
|
2012-12-11 10:26:10 -04:00
|
|
|
|
return str.replace(expression, strReplace);
|
2012-08-16 15:37:15 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-08-15 20:00:54 -04:00
|
|
|
|
var mb_strlen = function(str) {
|
2012-11-12 18:48:15 -04:00
|
|
|
|
str = str || '';
|
2012-08-15 20:00:54 -04:00
|
|
|
|
var len = 0;
|
|
|
|
|
|
for (var i = 0; i < str.length; i++) {
|
|
|
|
|
|
len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? 2 : 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
return len;
|
2012-08-16 15:37:15 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
2012-09-24 01:35:34 -04:00
|
|
|
|
var stripNonNumeric = function (str) {
|
|
|
|
|
|
str += ''; //force str to be a string
|
|
|
|
|
|
var rgx = /^\d|\.|-$/;
|
|
|
|
|
|
var out = '';
|
|
|
|
|
|
for (var i = 0; i < str.length; i++) {
|
|
|
|
|
|
if (rgx.test(str.charAt(i))) {
|
|
|
|
|
|
if (!((str.charAt(i) == '.' && out.indexOf('.') != -1) || (str.charAt(i) == '-' && out.length != 0 ))) {
|
|
|
|
|
|
out += str.charAt(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return out;
|
|
|
|
|
|
};
|