Skip to content
Snippets Groups Projects
Commit c326e269 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Replace javascript by jQuery

parent 45472330
Branches
Tags
No related merge requests found
...@@ -29,12 +29,14 @@ function autofilltownfromzip_PopupPostalCode(url_root, postalcode,objecttown,obj ...@@ -29,12 +29,14 @@ function autofilltownfromzip_PopupPostalCode(url_root, postalcode,objecttown,obj
} }
/*================================================================= /*
Purpose: Pour la saisie des dates par calendrier * =================================================================
Input: base "/theme/eldy" * Purpose:
dateFieldID "dateo" Nom du champ * Pour la saisie des dates par calendrier Input: base "/theme/eldy" dateFieldID
format "dd/MM/yyyy" Format issu de Dolibarr de SimpleDateFormat a utiliser pour retour * "dateo" Nom du champ format "dd/MM/yyyy" Format issu de Dolibarr de
==================================================================*/ * SimpleDateFormat a utiliser pour retour
* ==================================================================
*/
function showDP(base,dateFieldID,format,codelang) function showDP(base,dateFieldID,format,codelang)
{ {
// check to see if another box is already showing // check to see if another box is already showing
...@@ -131,7 +133,8 @@ function loadMonth(base,month,year,ymd,codelang) ...@@ -131,7 +133,8 @@ function loadMonth(base,month,year,ymd,codelang)
req=loadXMLDoc(theURL,null,false); req=loadXMLDoc(theURL,null,false);
if (req.responseText == '') alert('Failed to get URL '.theURL); if (req.responseText == '') alert('Failed to get URL '.theURL);
//alert(theURL+' - '+req.responseText); // L'url doit avoir la meme racine que la pages et elements sinon pb de securite. // alert(theURL+' - '+req.responseText); // L'url doit avoir la meme racine
// que la pages et elements sinon pb de securite.
showDP.box.innerHTML=req.responseText; showDP.box.innerHTML=req.responseText;
} }
...@@ -296,7 +299,8 @@ function loadXMLDoc(url,readyStateFunction,async) ...@@ -296,7 +299,8 @@ function loadXMLDoc(url,readyStateFunction,async)
return req; return req;
} }
// To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and not put popup completely on the front) // To hide/show select Boxes with IE6 (and only IE6 because IE6 has a bug and
// not put popup completely on the front)
function hideSelectBoxes() { function hideSelectBoxes() {
var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10); var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1) if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE 6") > -1)
...@@ -324,23 +328,19 @@ function displaySelectBoxes() { ...@@ -324,23 +328,19 @@ function displaySelectBoxes() {
/*================================================================= /*
Function: formatDate (javascript object Date(), format) * =================================================================
Purpose: Returns a date in the output format specified. * Function:
The format string can use the following tags: * formatDate (javascript object Date(), format) Purpose: Returns a date in the
Field | Tags * output format specified. The format string can use the following tags: Field |
-------------+------------------------------- * Tags -------------+------------------------------- Year | yyyy (4 digits), yy
Year | yyyy (4 digits), yy (2 digits) * (2 digits) Month | MM (2 digits) Day of Month | dd (2 digits) Hour (1-12) |
Month | MM (2 digits) * hh (2 digits) Hour (0-23) | HH (2 digits) Minute | mm (2 digits) Second | ss
Day of Month | dd (2 digits) * (2 digits) Author: Laurent Destailleur Author: Matelli (see
Hour (1-12) | hh (2 digits) * http://matelli.fr/showcases/patchs-dolibarr/update-date-input-in-action-form.html)
Hour (0-23) | HH (2 digits) * Licence: GPL
Minute | mm (2 digits) * ==================================================================
Second | ss (2 digits) */
Author: Laurent Destailleur
Author: Matelli (see http://matelli.fr/showcases/patchs-dolibarr/update-date-input-in-action-form.html)
Licence: GPL
==================================================================*/
function formatDate(date,format) function formatDate(date,format)
{ {
// alert('formatDate date='+date+' format='+format); // alert('formatDate date='+date+' format='+format);
...@@ -363,7 +363,9 @@ function formatDate(date,format) ...@@ -363,7 +363,9 @@ function formatDate(date,format)
c=format.charAt(i); // Recupere char du format c=format.charAt(i); // Recupere char du format
substr=""; substr="";
j=i; j=i;
while ((format.charAt(j)==c) && (j < format.length)) // Recupere char successif identiques while ((format.charAt(j)==c) && (j < format.length)) // Recupere char
// successif
// identiques
{ {
substr += format.charAt(j++); substr += format.charAt(j++);
} }
...@@ -389,25 +391,19 @@ function formatDate(date,format) ...@@ -389,25 +391,19 @@ function formatDate(date,format)
} }
/*================================================================= /*
Function: getDateFromFormat(date_string, format_string) * =================================================================
Purpose: This function takes a date string and a format string. * Function:
It parses the date string with format and it returns * getDateFromFormat(date_string, format_string) Purpose: This function takes a
the date as a javascript Date() object. * date string and a format string. It parses the date string with format and it
If date does not match format, it returns 0. * returns the date as a javascript Date() object. If date does not match
The format string can use the following tags: * format, it returns 0. The format string can use the following tags: Field |
Field | Tags * Tags -------------+------------------------------- Year | yyyy (4 digits), yy
-------------+------------------------------- * (2 digits) Month | MM (2 digits) Day of Month | dd (2 digits) Hour (1-12) |
Year | yyyy (4 digits), yy (2 digits) * hh (2 digits) Hour (0-23) | HH (2 digits) Minute | mm (2 digits) Second | ss
Month | MM (2 digits) * (2 digits) Author: Laurent Destailleur Licence: GPL
Day of Month | dd (2 digits) * ==================================================================
Hour (1-12) | hh (2 digits) */
Hour (0-23) | HH (2 digits)
Minute | mm (2 digits)
Second | ss (2 digits)
Author: Laurent Destailleur
Licence: GPL
==================================================================*/
function getDateFromFormat(val,format) function getDateFromFormat(val,format)
{ {
// alert('getDateFromFormat val='+val+' format='+format); // alert('getDateFromFormat val='+val+' format='+format);
...@@ -425,14 +421,17 @@ function getDateFromFormat(val,format) ...@@ -425,14 +421,17 @@ function getDateFromFormat(val,format)
var seconde=now.getSeconds(); var seconde=now.getSeconds();
var i=0; var i=0;
var d=0; // -d- follows the date string while -i- follows the format string var d=0; // -d- follows the date string while -i- follows the format
// string
while (i < format.length) while (i < format.length)
{ {
c=format.charAt(i); // Recupere char du format c=format.charAt(i); // Recupere char du format
substr=""; substr="";
j=i; j=i;
while ((format.charAt(j)==c) && (j < format.length)) // Recupere char successif identiques while ((format.charAt(j)==c) && (j < format.length)) // Recupere char
// successif
// identiques
{ {
substr += format.charAt(j++); substr += format.charAt(j++);
} }
...@@ -483,10 +482,12 @@ function getDateFromFormat(val,format) ...@@ -483,10 +482,12 @@ function getDateFromFormat(val,format)
return newdate; return newdate;
} }
/*================================================================= /*
Function: stringIsInteger(string) * =================================================================
Purpose: Return true if string is an integer * Function:
==================================================================*/ * stringIsInteger(string) Purpose: Return true if string is an integer
* ==================================================================
*/
function stringIsInteger(str) function stringIsInteger(str)
{ {
var digits="1234567890"; var digits="1234567890";
...@@ -500,10 +501,13 @@ function stringIsInteger(str) ...@@ -500,10 +501,13 @@ function stringIsInteger(str)
return true; return true;
} }
/*================================================================= /*
Function: getIntegerInString(string,pos,minlength,maxlength) * =================================================================
Purpose: Return part of string from position i that is integer * Function:
==================================================================*/ * getIntegerInString(string,pos,minlength,maxlength) Purpose: Return part of
* string from position i that is integer
* ==================================================================
*/
function getIntegerInString(str,i,minlength,maxlength) function getIntegerInString(str,i,minlength,maxlength)
{ {
for (var x=maxlength; x>=minlength; x--) for (var x=maxlength; x>=minlength; x--)
...@@ -516,23 +520,24 @@ function getIntegerInString(str,i,minlength,maxlength) ...@@ -516,23 +520,24 @@ function getIntegerInString(str,i,minlength,maxlength)
} }
/*================================================================= /*
Purpose: Clean string to have it url encoded * =================================================================
Input: s * Purpose:
Author: Laurent Destailleur * Clean string to have it url encoded Input: s Author: Laurent Destailleur
Licence: GPL * Licence: GPL
==================================================================*/ * ==================================================================
*/
function urlencode(s) { function urlencode(s) {
return s.replace(/\+/gi,'%2B'); return s.replace(/\+/gi,'%2B');
} }
/*================================================================= /*
Purpose: Show a popup HTML page. * =================================================================
Input: url,title * Purpose:
Author: Laurent Destailleur * Show a popup HTML page. Input: url,title Author: Laurent Destailleur Licence:
Licence: GPL * GPL ==================================================================
==================================================================*/ */
function newpopup(url,title) { function newpopup(url,title) {
var argv = newpopup.arguments; var argv = newpopup.arguments;
var argc = newpopup.arguments.length; var argc = newpopup.arguments.length;
...@@ -545,21 +550,24 @@ return false; ...@@ -545,21 +550,24 @@ return false;
} }
/*================================================================= /*
Purpose: Fonction pour champ saisie en mode ajax. Used for autocompletion of products. * =================================================================
Author: Laurent Destailleur * Purpose:
Licence: GPL * Fonction pour champ saisie en mode ajax. Used for autocompletion of products.
==================================================================*/ * Author: Laurent Destailleur Licence: GPL
* ==================================================================
*/
function publish_selvalue(obj) { $(obj.name).value = obj.options[obj.selectedIndex].value; } function publish_selvalue(obj) { $(obj.name).value = obj.options[obj.selectedIndex].value; }
/*================================================================= /*
Purpose: Set value of a field after return of Ajax call. Used for autocompletion. * =================================================================
Input: HTML field name, val * Purpose:
Author: Regis Houssin * Set value of a field after return of Ajax call. Used for autocompletion.
Licence: GPL * Input: HTML field name, val Author: Regis Houssin Licence: GPL
==================================================================*/ * ==================================================================
*/
function ac_return(field, val){ function ac_return(field, val){
/* alert('field.name='+field.name+'-'+val.innerHTML); */ /* alert('field.name='+field.name+'-'+val.innerHTML); */
/* on met en place l'expression reguliere */ /* on met en place l'expression reguliere */
...@@ -574,25 +582,26 @@ function ac_return(field, val){ ...@@ -574,25 +582,26 @@ function ac_return(field, val){
$(field.name+'_id').value = id; $(field.name+'_id').value = id;
} }
/*================================================================= /*
Purpose: Applique un delai avant execution. Used for autocompletion of companies. * =================================================================
Input: funct, delay * Purpose:
Author: Regis Houssin * Applique un delai avant execution. Used for autocompletion of companies.
Licence: GPL * Input: funct, delay Author: Regis Houssin Licence: GPL
==================================================================*/ * ==================================================================
*/
function ac_delay(funct,delay) { function ac_delay(funct,delay) {
// delay before start of action // delay before start of action
setTimeout(funct,delay); setTimeout(funct,delay);
} }
/*================================================================= /*
Purpose: Clean values of a "Sortable.serialize". * =================================================================
Used by drag and drop. Works for Scriptaculous and jQuery. * Purpose:
Input: expr * Clean values of a "Sortable.serialize". Used by drag and drop. Works for
Author: Regis Houssin * Scriptaculous and jQuery. Input: expr Author: Regis Houssin Licence: GPL
Licence: GPL * ==================================================================
==================================================================*/ */
function cleanSerialize(expr) { function cleanSerialize(expr) {
var reg = new RegExp("(&)", "g"); var reg = new RegExp("(&)", "g");
var reg2 = new RegExp("[^A-Z0-9,]", "g"); var reg2 = new RegExp("[^A-Z0-9,]", "g");
...@@ -602,13 +611,13 @@ function cleanSerialize(expr) { ...@@ -602,13 +611,13 @@ function cleanSerialize(expr) {
} }
/*================================================================= /*
Purpose: Display a temporary message in input text fields (For showing help message on input field). * =================================================================
Input: fieldId * Purpose:
Input: message * Display a temporary message in input text fields (For showing help message on
Author: Regis Houssin * input field). Input: fieldId Input: message Author: Regis Houssin Licence:
Licence: GPL * GPL ==================================================================
==================================================================*/ */
function displayMessage(fieldId,message) { function displayMessage(fieldId,message) {
var textbox = document.getElementById(fieldId); var textbox = document.getElementById(fieldId);
if (textbox.value == '') { if (textbox.value == '') {
...@@ -617,25 +626,27 @@ function displayMessage(fieldId,message) { ...@@ -617,25 +626,27 @@ function displayMessage(fieldId,message) {
} }
} }
/*================================================================= /*
Purpose: Hide a temporary message in input text fields (For showing help message on input field). * =================================================================
Input: fiedId * Purpose:
Input: message * Hide a temporary message in input text fields (For showing help message on
Author: Regis Houssin * input field). Input: fiedId Input: message Author: Regis Houssin Licence: GPL
Licence: GPL * ==================================================================
==================================================================*/ */
function hideMessage(fieldId,message) { function hideMessage(fieldId,message) {
var textbox = document.getElementById(fieldId); var textbox = document.getElementById(fieldId);
textbox.style.color = 'black'; textbox.style.color = 'black';
if (textbox.value == message) textbox.value = ''; if (textbox.value == message) textbox.value = '';
} }
/*=================================================================
Purpose: To show an element (To support multiselect of checkboxes in some pages) /*
Input: fieldId * =================================================================
Author: Regis Houssin * Purpose: To
Licence: GPL * show an element (To support multiselect of checkboxes in some pages) Input:
==================================================================*/ * fieldId Author: Regis Houssin Licence: GPL
* ==================================================================
*/
function displayElement(fieldId) { function displayElement(fieldId) {
var elementId = document.getElementById(fieldId); var elementId = document.getElementById(fieldId);
if (elementId.style.visibility == 'hidden') { if (elementId.style.visibility == 'hidden') {
...@@ -643,12 +654,13 @@ function displayElement(fieldId) { ...@@ -643,12 +654,13 @@ function displayElement(fieldId) {
} }
} }
/*================================================================= /*
Purpose: To hide an element (To support multiselect of checkboxes in some pages) * =================================================================
Input: fieldId * Purpose: To
Author: Regis Houssin * hide an element (To support multiselect of checkboxes in some pages) Input:
Licence: GPL * fieldId Author: Regis Houssin Licence: GPL
==================================================================*/ * ==================================================================
*/
function hideElement(fieldId) { function hideElement(fieldId) {
var elementId = document.getElementById(fieldId); var elementId = document.getElementById(fieldId);
if (elementId.style.visibility == 'visible') { if (elementId.style.visibility == 'visible') {
...@@ -656,12 +668,13 @@ function hideElement(fieldId) { ...@@ -656,12 +668,13 @@ function hideElement(fieldId) {
} }
} }
/*================================================================= /*
Purpose: To check a checkbox (To support multiselect of checkboxes in some pages) * =================================================================
Input: fieldId * Purpose: To
Author: Regis Houssin * check a checkbox (To support multiselect of checkboxes in some pages) Input:
Licence: GPL * fieldId Author: Regis Houssin Licence: GPL
==================================================================*/ * ==================================================================
*/
function checkBox(boxId) { function checkBox(boxId) {
var elementId = document.getElementById(boxId); var elementId = document.getElementById(boxId);
if (elementId.checked == false) { if (elementId.checked == false) {
...@@ -669,12 +682,13 @@ function checkBox(boxId) { ...@@ -669,12 +682,13 @@ function checkBox(boxId) {
} }
} }
/*================================================================= /*
Purpose: To uncheck a checkbox (To support multiselect of checkboxes in some pages) * =================================================================
Input: fieldId * Purpose: To
Author: Regis Houssin * uncheck a checkbox (To support multiselect of checkboxes in some pages)
Licence: GPL * Input: fieldId Author: Regis Houssin Licence: GPL
==================================================================*/ * ==================================================================
*/
function uncheckBox(boxId) { function uncheckBox(boxId) {
var elementId = document.getElementById(boxId); var elementId = document.getElementById(boxId);
if (elementId.checked == true) { if (elementId.checked == true) {
...@@ -682,4 +696,3 @@ function uncheckBox(boxId) { ...@@ -682,4 +696,3 @@ function uncheckBox(boxId) {
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment