Migration SVN

This commit is contained in:
2016-02-21 14:28:40 +01:00
commit df45f10305
1455 changed files with 20440 additions and 0 deletions

230
web/javascript/forms.js Executable file
View File

@@ -0,0 +1,230 @@
// Critical error, when exception is captured
var critical_error = 'Critical error : The script has generated an error. Our team was informed.';
// Regular exp to use
var field_format = {
'last_name': /^[a-zA-Z., -]{1,35}$/,
'first_name': /^[a-zA-Z., -]{1,35}$/,
'company': /^[a-zA-Z0-9.,& -]{0,35}$/,
'address': /^[a-zA-Z0-9.,& -]{0,250}$/,
'city': /^[a-zA-Z -]{1,35}$/,
'zipcode': /^[a-zA-Z0-9-]{1,12}$/,
'email': /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/,
'pseudo': /^[a-z0-9]{1,9}$/,
'id': /^[0-9]{1,11}$/,
'template': /^[a-zA-Z]{0,20}$/,
'password': /^[^'"]{4,15}$/,
'new_password1': /^[^'"]{4,15}$/,
'new_password2': /^[^'"]{4,15}$/,
'subject': /^[a-z0-9éèàçù].{4,99}$/i, // 5 to 100 chars, begining with an alphanumeric one
'message': /^[a-z0-9éèàçù].{4,499}$/mi, // 5 to 500 chars, begining with an alphanumeric one, multiline
'url': /^(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/i,
'frequency': /^[0-9]{1,11}$/,
'first_start': /^[0-9]{1,11}$/,
'user_folder': /^\/{1}([a-z0-9_-]*\.?[a-z0-9_-]*\/{1})?$/i,
'host': /^([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i,
'sql_def_host': /^([a-z0-9]([a-z0-9\-]{0,61}[a-z0-9])?\.)+[a-z]{2,6}$/i,
'sql_def_user': /^[a-z0-9]{1,9}$/,
'sql_def_pwd': /^[^'"]{4,15}$/
}
// Relatives paths
var rel_path = {
0: '.',
1: '..',
2: '../..'
}
// Adding the 'trim' method to class String
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g,'');
}
function checkRequiredState(field)
{
var id=field.id.toLowerCase();
// If the field ID doesn't start with 'req', this field is not required
// We can stop here and return true
if (id.indexOf('req_')!=0) return true;
var ftype=field.type;
var fval=$('#'+id).val();
fval.trim();
if ((ftype == 'text') || (ftype == 'password') || (ftype == 'textarea')) {
if (fval=='') return false;
} else if (ftype == 'select-one') {
if (fval == '') return false;
if (parseInt(fval) == -1) return false;
} else if (ftype == 'checkbox') {
if (field.checked == false) return false;
} else {
// If we come here, the field type hasn't been trated yet
// Returning false for security
return false;
}
// If we come here, the field is ok
return true;
}
function checkFieldFormat(field)
{
var id=field.id.toLowerCase();
var fval=$('#'+id).val();
// If the field is empty and not required, we don't have to make the verification
if ((fval=='') && (id.indexOf('req_')!=0)) return true;
if (typeof(field_format[id])!='undefined') {
if ( field_format[id].exec(fval) ) return true;
else return false;
} else if ( id.indexOf('_usrfldr') != -1) {
if ( field_format['user_folder'].exec(fval) ) return true;
else return false;
} else if (id.indexOf('req_')==0) {
id=id.substr(4);
if ( typeof(field_format[id])!='undefined') {
if ( field_format[id].exec(fval) ) return true;
else return false;
} else {
return false;
}
}
return false;
}
function validateForm( form_id , relativePath)
{
var all_is_ok = true;
// Closing the results area
$('#result_datas').slideUp('slow');
$('#result_datas > p').each(function() { $('#'+this.id).slideUp(); });
$('#'+form_id+' :input').each(
function ()
{
var field_id=this.id;
if (( this.type != 'button' ) && ( this.type != 'radio' ) && (this.type != 'hidden')) {
var is_ok=checkRequiredState(this);
if (is_ok==false) {
all_is_ok=false;
$('#err_'+field_id+'_missing').slideDown('slow');
$('#err_'+field_id).slideUp('slow');
} else {
$('#err_'+field_id+'_missing').slideUp('slow');
if ((this.type!='checkbox') && (this.type!='select-one')) {
is_ok=checkFieldFormat(this);
if (is_ok==false) {
all_is_ok=false;
$('#err_'+field_id).slideDown('slow');
} else {
$('#err_'+field_id).slideUp('slow');
}
}
}
var css_class1 = (is_ok==true?'success':'error');
var css_class2 = (is_ok==true?'error':'success');
if (this.type != 'checkbox') {
css_class1 = 'b' + css_class1;
css_class2 = 'b' + css_class2;
field_id = '#' + field_id;
} else {
field_id = '#lbl_' + field_id;
}
if ($(field_id).hasClass(css_class2)) $(field_id).removeClass(css_class2);
if (! $(field_id).hasClass(css_class1)) $(field_id).addClass(css_class1);
}
});
// If there was errors at verification time, we stop here
if (all_is_ok==false) {
$('#result_datas').slideDown('slow');
return false;
}
if (relativePath==undefined) {
relativePath=0;
} else if (typeof(rel_path[relativePath])=='undefined') {
relativePath=0;
}
var strurl=rel_path[relativePath];
strurl += '/ajax.php?frm_id=' + form_id;
// Executing the request
var frm_datas = $('#'+form_id+' :input').serialize();
$.ajax({
url: strurl,
data: frm_datas,
type: 'POST',
start: $('#'+ form_id +' :input').attr('disabled','disabled'),
error: function(responseText) { alert(critical_error);},
success: function(responseText){displayFormResults( form_id, responseText);},
});
}
function displayFormResults(form_id,responseText)
{
var hide_form=true;
if (responseText == 'critical_error') {
alert(critical_error);
return;
}
responseText = eval(responseText);
// If the first code is 1, we can hide the form
// Elsewhere, we do not hide it
if (responseText[0]!=1) hide_form=false;
for (var i = 1; i < responseText.length; i++)
{
if ( isNaN(responseText[i]))
$('#'+responseText[i]).slideDown();
else
$('#ret_code_'+responseText[i]).slideDown();
}
if ( hide_form ) {
$('#'+form_id+'_container').slideUp("slow", function(){$('#result_datas').slideDown("slow");});
} else {
$('#'+form_id+' select,input,textarea').attr('disabled','');
$('#result_datas').slideDown("slow");
}
}
function doSingleRequest(reqID, value, onSuccess, onFailure, relativePath)
{
// Checking values of callbacks
if (onSuccess == undefined || onSuccess == '') {
alert('onSuccess callback undefined !');
return false;
}
if (onFailure == undefined || onSuccess == '') {
alert('onFailure callback undefined !');
return false;
}
if (relativePath==undefined) {
relativePath=0;
} else if (typeof(rel_path[relativePath])=='undefined') {
relativePath=0;
}
var strurl=rel_path[relativePath];
strurl += '/ajax.php?frm_id=' + reqID;
var datas='value=' + value;
$.ajax({
url: strurl,
data: datas,
type: 'POST',
error: function(responseText) { alert(critical_error);},
success: function(responseText){displaySingleRequestResults( responseText, onSuccess, onFailure);},
});
}
function displaySingleRequestResults(results, onSuccess, onFailure)
{
if (results == 'critical_error') {
alert(critical_error);
return;
}
results = eval(results);
// If the first code is 1, we call the onSuccess function
// Elsewhere, we call the onFailure function
if (results[0]==1) {
onSuccess(results);
} else {
onFailure(results);
}
}

9
web/javascript/general.js Executable file
View File

@@ -0,0 +1,9 @@
// Critical error, when exception is captured
var critical_error = 'Critical error : The script has generated an error. Our team was informed.';
// color of the inputs for tests
var color_ok = '#02bc6d';
var background_ok = '#c5fae4';
var color_nok = '#e00000';
var background_nok = '#efc0c0'

View File

@@ -0,0 +1,268 @@
/*
* Gritter for jQuery
* http://www.boedesign.com/
*
* Copyright (c) 2009 Jordan Boesch
* Dual licensed under the MIT and GPL licenses.
*
* Date: June 26, 2009
* Version: 1.0
*/
jQuery(document).ready(function($){
/********************************************
* First, we'll define our object
*/
Gritter = {
// PUBLIC - touch all you want
fade_speed: 2000, // how fast the notices fade out
timer_stay: 6000, // how long you want the message to hang on screen for
// PRIVATE - no touchy the private parts
_custom_timer: 0,
_item_count: 0,
_tpl_close: '<div class="gritter-close"></div>',
_tpl_item: '<div id="gritter-item-[[number]]" class="gritter-item-wrapper" style="display:none"><div class="gritter-top"></div><div class="gritter-item">[[image]]<div class="[[class_name]]"><span class="gritter-title">[[username]]</span><p>[[text]]</p></div><div style="clear:both"></div></div><div class="gritter-bottom"></div></div>',
_tpl_wrap: '<div id="gritter-notice-wrapper"></div>',
// Add a notification to the screen
add: function(user, text, image, sticky, time_alive){
// This is also called from init, we just added it here because
// some people might just call the "add" method
this.verifyWrapper();
var tmp = this._tpl_item;
this._item_count++;
// reset
this._custom_timer = 0;
// a custom fade time set
if(time_alive){
this._custom_timer = time_alive;
}
var image_str = (image != '') ? '<img src="' + image + '" class="gritter-image" />' : '';
var class_name = (image != '') ? 'gritter-with-image' : 'gritter-without-image';
tmp = this.str_replace(
['[[username]]', '[[text]]', '[[image]]', '[[number]]', '[[class_name]]'],
[user, text, image_str, this._item_count, class_name], tmp
);
$('#gritter-notice-wrapper').append(tmp);
var item = $('#gritter-item-' + this._item_count);
var number = this._item_count;
item.fadeIn();
if(!sticky){
this.setFadeTimer(item, number);
}
$(item).hover(function(){
if(!sticky){
Gritter.restoreItemIfFading(this, number);
}
Gritter.hoveringItem(this);
},
function(){
if(!sticky){
Gritter.setFadeTimer(this, number);
}
Gritter.unhoveringItem(this);
});
return number;
},
// If we don't have any more gritter notifications, get rid of the wrapper
countRemoveWrapper: function(){
if($('.gritter-item-wrapper').length == 0){
$('#gritter-notice-wrapper').remove();
}
},
// Fade the item and slide it up nicely... once its completely faded, remove it
fade: function(e){
$(e).animate({
opacity:0
}, Gritter.fade_speed, function(){
$(e).animate({ height: 0 }, 300, function(){
$(e).remove();
Gritter.countRemoveWrapper();
})
})
},
// Change the border styles and add the (X) close button when you hover
hoveringItem: function(e){
$(e).addClass('hover');
if($(e).find('img').length){
$(e).find('img').before(this._tpl_close);
}
else {
$(e).find('span').before(this._tpl_close);
}
$(e).find('.gritter-close').click(function(){
Gritter.remove(this);
});
},
// Remove a notification, this is called from the inline "onclick" event
remove: function(e){
$(e).parents('.gritter-item-wrapper').fadeOut('medium', function(){ $(this).remove(); });
this.countRemoveWrapper();
},
// Remove a specific notification based on an id (int)
removeSpecific: function(id, params){
var e = $('#gritter-item-' + id);
if(typeof(params) === 'object'){
if(params.fade){
var speed = this.fade_speed;
if(params.speed){
speed = params.speed;
}
e.fadeOut(speed);
}
}
else {
e.remove();
}
this.countRemoveWrapper();
},
// If the item is fading out and we hover over it, restore it!
restoreItemIfFading: function(e, number){
eval("window.clearTimeout(Gritter._int_id_" + number + ")");
$(e).stop().css({ opacity: 1 });
},
// Set the notification to fade out after a certain amount of time
setFadeTimer: function(item, number){
var timer_str = (this._custom_timer) ? this._custom_timer : this.timer_stay;
eval("Gritter._int_id_" + number + " = window.setTimeout(function(){ Gritter.fade(item); }, timer_str)");
},
// Bring everything to a halt!
stop: function(){
$('#gritter-notice-wrapper').fadeOut(function(){
$(this).remove();
});
},
// A handy PHP function ported to js!
str_replace: function(search, replace, subject, count) {
var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
f = [].concat(search),
r = [].concat(replace),
s = subject,
ra = r instanceof Array, sa = s instanceof Array;
s = [].concat(s);
if (count) {
this.window[count] = 0;
}
for (i=0, sl=s.length; i < sl; i++) {
if (s[i] === '') {
continue;
}
for (j=0, fl=f.length; j < fl; j++) {
temp = s[i]+'';
repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
s[i] = (temp).split(f[j]).join(repl);
if (count && s[i] !== temp) {
this.window[count] += (temp.length-s[i].length)/f[j].length;}
}
}
return sa ? s : s[0];
},
// Remove the border styles and (X) close button when you mouse out
unhoveringItem: function(e){
$(e).removeClass('hover');
$(e).find('.gritter-close').remove();
},
// Make sure we have something to wrap our notices with
verifyWrapper: function(){
if($('#gritter-notice-wrapper').length == 0){
$('body').append(this._tpl_wrap);
}
}
}
/********************************************
* Now lets turn it into some jQuery Magic!
*/
// Set it up as an object
$.gritter = {};
// Add a gritter notification
$.gritter.add = function(params){
try {
if(!params.title || !params.text){
throw "Missing_Fields";
}
} catch(e) {
if(e == "Missing_Fields"){
alert('Gritter Error: You need to fill out the first 2 params: "title" and "text"');
}
}
var id = Gritter.add(
params.title,
params.text,
params.image || '',
params.sticky || false,
params.time || ''
);
return id;
}
// Remove a specific notification
$.gritter.remove = function(id, params){
Gritter.removeSpecific(id, params || '');
}
// Remove all gritter notifications
$.gritter.removeAll = function(){
Gritter.stop();
}
});

View File

@@ -0,0 +1,59 @@
(function($) {
$.fn.tipsy = function(opts) {
opts = $.extend({fade: false, gravity: 'n'}, opts || {});
var tip = null, cancelHide = false;
this.hover(function() {
$.data(this, 'cancel.tipsy', true);
var tip = $.data(this, 'active.tipsy');
if (!tip) {
tip = $('<div class="tipsy"><div class="tipsy-inner">' + $(this).attr('title') + '</div></div>');
tip.css({position: 'absolute', zIndex: 100000});
$(this).attr('title', '');
$.data(this, 'active.tipsy', tip);
}
var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
switch (opts.gravity.charAt(0)) {
case 'n':
tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
break;
case 's':
tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
break;
case 'e':
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
break;
case 'w':
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
break;
}
if (opts.fade) {
tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 1});
} else {
tip.css({visibility: 'visible'});
}
}, function() {
$.data(this, 'cancel.tipsy', false);
var self = this;
setTimeout(function() {
if ($.data(this, 'cancel.tipsy')) return;
var tip = $.data(self, 'active.tipsy');
if (opts.fade) {
tip.stop().fadeOut(function() { $(this).remove(); });
} else {
tip.remove();
}
}, 100);
});
};
})(jQuery);

19
web/javascript/jquery/jquery-1.3.2.min.js vendored Executable file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

123
web/javascript/pagination.js Executable file
View File

@@ -0,0 +1,123 @@
function makeTable(id, json)
{
json = eval(json);
var tbody = $('#'+id);
tbody.html('');
jQuery.each(json, function(tr, tr_content)
{
var dom_tr = $(document.createElement('tr'));
jQuery.each(json[tr][0], function(opt, value)
{
dom_tr.attr(opt, value);
});
jQuery.each(json[tr][1], function(opt, value)
{
var dom_td = $(document.createElement('td'));
jQuery.each(json[tr][1][opt], function(_opt, _value)
{
if(_opt != 'html') {
dom_td.attr(_opt, _value);
} else {
dom_td.html(_value);
}
});
dom_tr.append(dom_td);
});
tbody.append(dom_tr);
});
}
function getPage(tableID, numPage, maxPages, relativePath, addValue)
{
if (relativePath==undefined) {
relativePath=0;
} else if (typeof(rel_path[relativePath])=='undefined') {
relativePath=0;
}
var strurl=rel_path[relativePath];
strurl += '/ajax.php?frm_id=' + tableID;
var datas='p='+numPage;
if (addValue!=undefined) {
datas += '&value=' + addValue;
}
$.ajax({
url: strurl,
data: datas,
type: 'GET',
error: function(responseText)
{
alert(critical_error);
},
success: function(responseText)
{
makeTable(tableID, responseText);
if ( maxPages > 1) {
makePagesLinks(tableID, maxPages, numPage, relativePath, addValue);
}
}
});
}
function makePageLink(tableID, page, content, nbPages, relativePath, addValue)
{
var a = $(document.createElement('a'));
a.html(content);
a.attr('rel', page);
a.attr('style', 'cursor: pointer;');
a.click(function()
{
var n = parseInt($(this).attr('rel'));
getPage(tableID, n, nbPages, relativePath, addValue);
});
return a;
}
function makePagesLinks(tableID, nbPages, currentPage, relativePath, addValue)
{
var p = $('#' + tableID + '_pg_links');
p.html('');
p.attr('style', 'text-align: center;');
p.append(makePageLink(tableID, 1, '|<', nbPages, relativePath, addValue));
p.append('&nbsp;');
p.append(makePageLink(tableID, Math.max(currentPage-1, 1), '<<', nbPages, relativePath, addValue));
p.append('&nbsp;');
if(nbPages > 15) {
var start = Math.max(1, currentPage-3);
var end = Math.min(nbPages, currentPage+3);
if(start == 1) {
end = 7;
} else {
p.append('<a>...</a>&nbsp;');
}
if(end == nbPages) {
start = nbPages-6;
}
} else {
var start = 1;
var end = nbPages;
}
for(var u=start; u<=end; u++) {
a=makePageLink(tableID, u, u, nbPages, relativePath, addValue);
if(u == currentPage) {
a.attr('class', 'current');
}
p.append(a);
p.append('&nbsp;');
}
if(end != nbPages) {
p.append('<a>...</a>&nbsp;');
}
p.append(makePageLink(tableID, Math.min( currentPage+1, nbPages), '>>', nbPages, relativePath, addValue));
p.append('&nbsp;');
p.append(makePageLink(tableID, nbPages, '>|', nbPages, relativePath, addValue));
}