| Server IP : 54.36.91.62 / Your IP : 216.73.217.94 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/administrator/components/com_jlexreview/assets/ |
Upload File : |
function RatingFlag($,data)
{
var jsondata = null;
if(typeof data=='object') jsondata=data;
var addNewRow = function(data)
{
var _el = $(".rating-flag-layout").clone();
_el.removeClass("rating-flag-layout")
.addClass("rating-flag-item");
if (typeof data=="object")
{
$.each(data, function(k,v){
_el.find('input[data-name='+k+']').val(v);
});
}
// pick color
_el.find("input[data-name=color]").colpick({
layout:'hex',
colorScheme:'dark',
onSubmit:function(hsb,hex,rgb,el) {
$(el).css('background','#'+hex);
$(el).colpickHide();
$(el).val(hex);
}
}).keyup(function(){
$(this).colpickSetColor(this.value);
}).each(function(){
$(this).css('background-color','#'+$(this).val());
$(this).colpickSetColor(this.value);
});
// number format
_el.find("input.number").keypress(function(e) {
if (e.which!=8&&(e.which<48||e.which>57)) {
e.preventDefault();
return false;
}
if (e.which==8) return;
if ($(this).val()=='0') {
$(this).val( e.key );
e.preventDefault();
return;
}
var _no=$(this).val()+e.key;// string
_no=parseInt(_no);
if (_no>100) return false;
});
_el.find("._remove").click(function(){
_el.fadeOut("fast",function(){
_el.remove();
});
});
_el.insertBefore( $("#rating-flag-text button._add") );
return _el;
}
// events
$("#rating-flag-text button._add").click(function() {
addNewRow();
});
if (jsondata!=null)
{
$.each(jsondata, function(k,v){
addNewRow(v);
});
}
// check structure when submit
Joomla.submitbutton=(function(task) {
if (task=='apply'||task=='save') {
var error=false,
regexColor=/^[A-Fa-f0-9]{6}$/;
var enable = $('input[name="jform[rating_text]"]:checked').val();
if (enable!="1")
{
Joomla.submitform(task);
return;
}
$('.rating-flag-item input').each(function(){
var vl=$(this).val();
if ($.trim(vl)=='') {
$(this).focus();
alert("Field value not empty.");
error=true;
return;
}
// number
if ($(this).hasClass('number')&&isNaN(vl)) {
$(this).focus();
alert("Field value must number type.");
error=true;
return;
}
// color
if ($(this).hasClass('color')&&!regexColor.test(vl)) {
$(this).focus();
alert("Color format incorrect.");
error=true;
return;
}
});
/* Check period number */
var $nums = $('#rating-flag-text input.number');
if ($nums.length<2||$nums.length%2!=0) return false;
$nums.each(function(){
var id=$nums.index( $(this) )*1,
vl=parseInt( $(this).val() );
if ((id==0&&vl!=0)||(id+1==$nums.length&&vl!=100)) {
error=true;
$(this).focus();
return;
}
if (id==0||id+1==$nums.length) {
return true;
} else {
if (vl<0||vl>100) {
error=true;
alert("Maximum value is 100 and minium is 0.");
$(this).focus();
return;
}
}
if ((id+1)%2==0&&(
vl<=$nums.eq(id-1).val()*1
||
vl+1!=$nums.eq(id+1).val()*1
)) {
error=true;
$(this).focus();
return;
}
});
if (error) return false;
}
// output
var outputs = [];
$('.rating-flag-item').each(function(){
var output = {};
$(this).find("input").each(function(){
output[$(this).attr("data-name")] = $(this).val();
});
outputs.push(output);
});
$("#rating-flag-datajson").val(JSON.stringify(outputs));
Joomla.submitform(task);
});
}