403Webshell
Server IP : 89.108.64.180  /  Your IP : 216.73.217.92
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux 89-108-64-180.cloudvps.regruhosting.ru 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-root ( 1010)
PHP Version : 8.0.30
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/ainlanhotel.ru/wp-content/plugins/fwdrl/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/ainlanhotel.ru/wp-content/plugins/fwdrl/js/playlist_manager.js
/**
 * Revolution Lightbox PACKAGED v2.0
 * Galleries manager.
 *
 * @author Tibi - FWDesign [https://webdesign-flash.ro/]
 * Copyright © 2006 All Rights Reserved.
 */
 
jQuery(document).ready(function($){

	'use strict';

	fwdMainPlaylistsAr = unescapeHtml(fwdMainPlaylistsAr);
	if(fwdMainPlaylistsAr == 'null'){
		fwdMainPlaylistsAr = []
	}else{
		fwdMainPlaylistsAr = JSON.parse(fwdMainPlaylistsAr);
	}
  	if(!fwdMainPlaylistsAr) fwdMainPlaylistsAr = [];
	
	$("#main_playlists").accordion({
		header: ".playlist-header",
		collapsible: true,
		heightStyle: "content",
		active: false
	}).sortable({
		axis: "x,y",
		handle: ".playlist-header-sort",
		start: startPlaylistsOrder,
		update: updatePlaylistsOrder
	});       
	
	$(".pls").accordion({
		header: ".playlist-header",
    	collapsible: true,
    	heightStyle: "content",
    	active: false
    }).sortable({
        axis: "x,y",
        handle: ".playlist-header-sort",
        start: startPlaylistsOrder,
        update: updatePlaylistsOrder
    });
	
	$(".fwd-playlist").mouseover(function(){
		$(this).addClass("pl_over");
		$(this).find(".pl-header").css("color", "#212121");
	});
	
	$(".fwd-playlist").mouseout(function(){
		$(this).removeClass("pl_over");
		$(this).find(".pl-header").css("color", "#555555");
	});
	
	var imgPath = fwdrlIconsPath + "normal-icon.png";
	var img = '<img class="playlist-icon" src="' + imgPath + '"/>';
	
	$(".playlist > h3").prepend(img);
	$(".playlist-header .ui-accordion-header-icon").css("left", "22px");

	$(".items").sortable({
        axis: "x,y",
        handle: ".item-header",
        start: startItemesOrder,
        update: updateItemesOrder
    });
	
	$(".fwd-item").mouseover(function(){
		$(this).addClass("item_over");
		$(this).find(".item-header").css("color", "#212121");
	});
	
	$(".fwd-item").mouseout(function(){
		$(this).removeClass("item_over");
		$(this).find(".item-header").css("color", "#555555");
	});
	
	if ($("#main_playlists .playlist-count").length > 0){
		$("#mp_em").hide();
	}
	
	$("img").fwdTooltip({
    });


	/**
	  * Sortable and draggable.
	  */
    var cur_pl_id,
    	cur_item_id,
    	curPlOrderId,
        curItemOrderId,
        newItemOrderId;

	function startPlaylistsOrder(ev, ui){
		var allMpItems = $(this).sortable("toArray");	
		curPlOrderId = allMpItems.indexOf($(ui.item).attr("id"));
	}
	
	function updatePlaylistsOrder(ev, ui){
		var allMpItems = $(this).sortable("toArray");
   		newPlOrderId = allMpItems.indexOf($(ui.item).attr("id"));
   		
   		var curItem = fwdMainPlaylistsAr.splice(curPlOrderId, 1)[0];
   	    fwdMainPlaylistsAr.splice(newPlOrderId, 0, curItem);
	};
	
	function startItemesOrder(ev, ui){
		var allItemItems = $(this).sortable("toArray");
		curItemOrderId = allItemItems.indexOf($(ui.item).attr("id"));
	}
	
	function updateItemesOrder(ev, ui){
		var allItemItems = $(this).sortable("toArray");
   		newItemOrderId = allItemItems.indexOf($(ui.item).attr("id"));
		
   		var allPlItems = $("#main_playlists").sortable("toArray");
   		var plParent = $(this).closest(".playlist");
		
   		curPlOrderId = allPlItems.indexOf($(plParent).attr("id"));
   		var curItem = fwdMainPlaylistsAr[curPlOrderId].items.splice(curItemOrderId, 1)[0];

		fwdMainPlaylistsAr[curPlOrderId].items.splice(newItemOrderId, 0, curItem);
	}
	

	/**
	  * Main gallery.
	  */
	$("#add_main_playlist_btn").click(function(e){
		e.preventDefault();
        $("#add-playlist-dialog").dialog("open");
    });
	
	var curPlOrderId;
	var newPlOrderId;
	var pl_name = $("#pl_name");
    var pl_type = $("#pl_type");
	var pl_source = $("#pl_source");
	var allFieldsPl = $([]).add(pl_name).add(pl_source);
	var pl_name_edit = $("#pl_name_edit");
	var allFieldsPlEdit = $([]).add(pl_name_edit);
	
	$("#add-playlist-dialog").dialog({
		autoOpen: false,
		width: 380,
	    height: 210,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlAdd__,
	        "click": function(){
	         	
				var fValid = true;
	         	var tips = $("#add_pl_tips");
	         	
	          	allFieldsPl.removeClass("ui-state-error");
	 
	          	fValid = fValid && checkLength(tips, pl_name, "playlist name", 1, 64);
				
				if (fValid){
					
					var pid = $("#main_playlists .playlist-count").length;
	          		var plsIdsAr = [];
	          		
	          		if(pid > 0){
	          			$.each(fwdMainPlaylistsAr, function(i, el){
							plsIdsAr.push(el.id);
						});
	          			
    	          		for(var i=0; i<fwdMainPlaylistsAr.length; i++){
    	          			if($.inArray(i, plsIdsAr) == -1){
    	          				pid = i;
    	          				break;
    	          			}
    	          		}
	          		}else{
	          			$("#mp_em").hide();
	          		}
					
					$("#main_playlists").prepend("<div id='pl" + pid + "' class='playlist playlist-count'>"
						+ "<h3 class='playlist-header-sort playlist-header'><span>" + pl_name.val().replace(/"/g, "'") + "</span></h3>"
						+ "<div>"
						+ "<div id='pl" + pid + "_items' class='items'></div>"
						+ "<button class='add_item_btn' id='pl" + pid + "_btn'>" + fwdrlAddNewItem__ + "</button>"
						+ "<button class='add_bulk_btn' id='pl" + pid + "_bulk_btn'>" + fwdrlAddBulkItems__ + "</button>"
						+ "<button class='edit_playlist_btn' id='pl" + pid + "_edit_btn'>" + fwdrlEdit__ + "</button>"
						+ "<button class='delete_playlist_btn' id='pl" + pid + "_del_btn'>" + fwdrlDelete__ + "</button>"
						+ "</div>"
					+ "</div>");
					
					var imgPath = fwdrlIconsPath + "normal-icon.png";		
					var img = '<img class="playlist-icon" src="' + imgPath + '"/>';
					
					$(".playlist > h3").prepend(img);
					
					$(".add_item_btn").off('click');
					$(".add_item_btn").on('click', function(e){
						var reg_exp = /pl[0-9]+_/;
						
						cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
						
						$("#add-item-dialog").dialog("open");
						return false;
					});
					
					$(".add_bulk_btn").off('click');
					$(".add_bulk_btn").on('click', function(e){
						var reg_exp = /pl[0-9]+_/;
					
						cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
						openBulkUploader(e);
						return false;
					});
					
					$(".edit_playlist_btn, .edit_playlist_btn2").click(function(e){
					e.preventDefault();
				
					var reg_exp1 = /pl[0-9]+_/;
				
					cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
					
					var allMpItems = $("#main_playlists").sortable("toArray");
					curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);
					
					$("#edit-playlist-dialog").dialog("open");
				});
				
				$(".delete_playlist_btn, .delete_playlist_btn2").off('click');
				$(".delete_playlist_btn, .delete_playlist_btn2").on('click', function(e){
					e.preventDefault();
				
					var reg_exp = /pl[0-9]+_/;
					cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
					
					$("#delete-playlist-dialog").dialog("open");
				});
				
				$("#pl" + pid + "_items").sortable({
					axis: "x,y",
					handle: ".item-header",
					start: startItemesOrder,
					update: updateItemesOrder
				});

				$("#main_playlists").sortable("refresh");
				$("#main_playlists").accordion("refresh");
				
				$(".playlist .ui-accordion-header-icon").css("left", "22px");
				
				var newPl ={
					id:pid,
					name: pl_name.val().replace(/"/g, "'"),
					items: []
				};
	
				fwdMainPlaylistsAr.unshift(newPl);
				
				$(this).dialog("close");
				}
	         	 
	        }},
	        {	
	        	text: fwdrlCancel__,
	        	'click': function() {
	        	$(this).dialog("close");
	        }}
	    ],
	    close: function(){
		    allFieldsPl.removeClass("ui-state-error");  
		    $("#add_pl_tips").removeClass("fwd-error");
	    },
	    open: function(){
	    	$("#pl_name").val("");
			$("#pl_type").val("normal");
			$("#pl_source").val("");
			$("#pl_source_div").hide();
	    	$("#add_pl_tips").text("The gallery name is required.");
	    	$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	$(".add_playlist_btn").click(function(e){
		e.preventDefault();
	
		var reg_exp = /mp[0-9]+_/;	
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
		
        $("#add-playlist-dialog").dialog("open");
    });
    
	$("#edit-playlist-dialog").dialog({
		autoOpen: false,
		width: 380,
	    height: 210,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlUpdate__,
	        'click': function(){
				var fValid = true;
				var tips = $("#edit_pl_tips");
				
				allFieldsPlEdit.removeClass("ui-state-error");
				
				fValid = fValid && checkLength(tips, pl_name_edit, "playlist name", 1, 64);
		 
				if (fValid){
					var content = $("#pl" + cur_pl_id + " > h3").html();
	          		var pos = content.indexOf(fwdMainPlaylistsAr[curPlOrderId].name + "<") 
					content = content.slice(0, pos);
	          		$("#pl" + cur_pl_id + " > h3").html(content + pl_name_edit.val().replace(/"/g, "'"));
					
					fwdMainPlaylistsAr[curPlOrderId].name = pl_name_edit.val().replace(/"/g, "'");
					
					$(this).dialog("close");
				}	
	         	 	
	        }},
	        {
	        	text: fwdrlCancel__,
	        	'click': function(){
	        	$(this).dialog("close");
	        }}
	    ],
	    close: function(){
		    allFieldsPlEdit.removeClass("ui-state-error");
		    $("#edit_pl_tips").removeClass("fwd-error");
	    },
	    open: function(){
			$("#edit_pl_tips").text("The gallery name is required:");
			$("#pl_name_edit").val(fwdMainPlaylistsAr[curPlOrderId].name);
			$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	$(".edit_playlist_btn, .edit_playlist_btn2").click(function(e){
		e.preventDefault();
	
		var reg_exp1 = /pl[0-9]+_/;
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
		
		var allMpItems = $("#main_playlists").sortable("toArray");
		curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);

		$("#edit-playlist-dialog").dialog("open");
	});
	
	$("#delete-playlist-dialog").dialog({
		autoOpen: false,
		width: 300,
	    height: 160,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlYes__,
	        click: function(){
	            var allMpItems = $("#main_playlists").sortable("toArray");
	       		curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);
	            
	       		fwdMainPlaylistsAr.splice(curPlOrderId, 1);
	       		
	       		$("#pl" + cur_pl_id).remove();
	       		$(".main_playlists").accordion("option", "active", false);

	       		$(".main_playlists").sortable("refresh");
	            $(".main_playlists").accordion("refresh");
				
				if ($("#main_playlists .playlist-count").length == 0){
	            	$("#mp_em").show();
	            }
	            $(this).dialog("close");
	        }},
	        {	
	        	text: fwdrlNo__,
	        	click: function(){
	        	$(this).dialog("close");
	        }}
	    ],
	    open: function(){
       		$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	$(".delete_playlist_btn, .delete_playlist_btn2").click(function(e){
		e.preventDefault();
	
		var reg_exp = /pl[0-9]+_/;
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
	
		$("#delete-playlist-dialog").dialog("open");
	});
	

	/**
	  * Items manager.
	  */
	var item_name = $("#item_name");
    var item_source = $("#item_source");
    var item_thumb = $("#item_thumb");
	var video_poster_source = $("#video_poster_source");
	var item_max_width = $("#item_max_width");
	var item_max_height = $("#item_max_height");
	var showAds = false;
    
	var allFieldsItem = $([]).add(item_name).add(item_source).add(item_thumb).add(item_max_width).add(item_max_height);

	$("#add-item-dialog").dialog({
		autoOpen: false,
		width: 640,
	    height: 740,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlAdd__,
	        click: function() {
	         	var fValid = true;
	         	var tips = $("#add_item_tips");
	         	
	          	allFieldsItem.removeClass("ui-state-error");
	          	fValid = fValid && checkLength(tips, item_name, "item name", 1, 64);
	       		fValid = fValid && checkLength(tips, item_source, "item source", 1, 456);
				
				if(item_max_width.val().length != 0){
					fValid = fValid && checkIfIntegerAndLength(tips, item_max_width, "item maximum width", 1, 256);
				}
				
				if(item_max_height.val().length != 0){
					fValid = fValid && checkIfIntegerAndLength(tips, item_max_height, "item maximum height", 1, 256);
				}
	       		
	          	if (fValid){
	          		var itemId = $("#pl" + cur_pl_id + "_items .fwd-item").length;
	          		var itemsIdsAr = [];
	          		
	          		var allMpItems = $("#main_playlists").sortable("toArray");
		       		curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);


	          		$.each($("#pl" + cur_pl_id + "_items .fwd-item"), function(i, el){
	          			var reg_exp = /item[0-9]+/;
            			var item_id = parseInt($(el).attr("id").match(reg_exp)[0].slice(4));
            			itemsIdsAr.push(item_id);
      				});
					
				
	          		for (var i=0; i<fwdMainPlaylistsAr[curPlOrderId].items.length; i++){
						if ($.inArray(i, itemsIdsAr) == -1){
	          				itemId = i;
	          				break;
	          			}
	          		}
					var source = item_source.val().replace(/"/g, "'");
					
					if(source.indexOf(".jpg") != -1 || source.indexOf(".jpeg") != -1 || source.indexOf(".png") != -1){
						$("#pl" + cur_pl_id +  "_items").prepend("<div id='pl" + cur_pl_id + "_item" + itemId + "' class='fwd-item'>"
							+ "<h3 class='item-header'>" + item_name.val().replace(/"/g, "'") + "</h3>"
							+ "<button class='delete_item_btn' id='pl" + cur_pl_id + "_item" + itemId + "_del_btn'>" + fwdrlDelete__ + "</button>"
							+ "<button class='edit_item_btn' id='pl" + cur_pl_id +  "_item" + itemId + "_edit_btn'>" + fwdrlEdit__ + "</button>"
							+ "<img src='" + source + "' class='fwd-item-playlist-img' id='pl" + cur_pl_id + "_item" + itemId + "_img'></img>"
						+ "</div>");
					}else{
						$("#pl" + cur_pl_id +  "_items").prepend("<div id='pl" + cur_pl_id + "_item" + itemId + "' class='fwd-item'>"
							+ "<h3 class='item-header'>" + item_name.val().replace(/"/g, "'") + "</h3>"
							+ "<button class='delete_item_btn' id='pl" + cur_pl_id + "_item" + itemId + "_del_btn'>" + fwdrlDelete__ + "</button>"
							+ "<button class='edit_item_btn' id='pl" + cur_pl_id +  "_item" + itemId + "_edit_btn'>" + fwdrlEdit__ + "</button>"
						+ "</div>");
					}
					
	          		$(".edit_item_btn").click(function(e){
						e.preventDefault();
				
      					var reg_exp1 = /pl[0-9]+_/;
      					var reg_exp2 = /item[0-9]+_/;
      					
      					cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
      					cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));
						
      					var allMpItems = $("#main_playlists").sortable("toArray");
      			   		curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);
      			        
      			   		var allItemItems = $("#pl" + cur_pl_id + "_items").sortable("toArray");
      			   		curItemOrderId = allItemItems.indexOf("pl" + cur_pl_id + "_item" + cur_item_id);

      			        $("#edit-item-dialog").dialog("open");
      			    });
	          		
	          		$(".delete_item_btn").click(function(e){
						e.preventDefault();
					
      					var reg_exp1 = /pl[0-9]+_/;
      					var reg_exp2 = /item[0-9]+_/;
      					
      					cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
      					cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));
      					
      			        $("#delete-item-dialog").dialog("open");
      			    });

		            $(".items").sortable("refresh");
		            
		            $(".fwd-item").mouseover(function(){
            			$(this).addClass("item_over");
            			$(this).find(".item-header").css("color", "#212121");
            		});
            		
            		$(".fwd-item").mouseout(function(){
            			$(this).removeClass("item_over");
            			$(this).find(".item-header").css("color", "#555555");
            		});
		            
		            var newItem ={
		            	name: item_name.val().replace(/"/g, "'"),
		            	source: item_source.val().replace(/"/g, "'"),
		            	thumb: item_thumb.val().replace(/"/g, "'"),
						video_poster_source: video_poster_source.val().length > 0 ? video_poster_source.val().replace(/"/g, "'") : undefined,
						max_width: item_max_width.val().length > 0 ? item_max_width.val().replace(/"/g, "'") : undefined,
						max_height:item_max_height.val().length > 0 ? item_max_height.val().replace(/"/g, "'") : undefined,
						subtitle: $("#videoSubtitle").val().replace(/"/g, "'"),
						thumbnailsPreview: $("#videoThumbPreview").val().replace(/"/g, "'"),
						vast:$("#vast").val().replace(/"/g, "'"),
						pass:$("#pass").val().replace(/"/g, "'"),
						dsecription: getItemDescription().replace(/"/g, "'"),
		            };
		            fwdMainPlaylistsAr[curPlOrderId].items.unshift(newItem);

		            $(this).dialog("close");
	         	}else{
	          		$("#add-item-dialog").scrollTop(0);
	          	}
	        }},
	        {	text: fwdrlCancel__,
	        	click: function(){
	        	$(this).dialog("close");
	        }}
	    ],
	    close: function(){
		    allFieldsItem.removeClass("ui-state-error");
		    $("#add_item_tips").removeClass("fwd-error");
	    },
	    open: function(){
			
	    	$("#item_name").val("");
	    	$("#item_source").val("");
	    	$("#item_thumb").val("");
			$("#video_poster_source").val("");
			$("#item_max_width").val("");
			$("#item_max_height").val("");
			$("#videoSubtitle").val("");
			$("#videoThumbPreview").val("");
			$("#vast").val("");
			$("#pass").val("")
		    setItemDescription("");
		  
			$("#thumb_source").attr("src", "");
			$("#upload_thumb").attr("src", "");
		    $("#wp-itemdescription-wrap").attr("style", "margin-top:-30px;");
		    $("#itemdescription-html").html("HTML");
		    
		    $("#add_item_tips").text("The item name and item source are required.");
       		
       		$("#itemdescription_ifr").height(181);
       		$("#itemdecrp_ifr").height(181);
       		$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	function setItemDescription(str){
		if (typeof tinyMCE !== "undefined" && tinyMCE.get("itemdescription")){
			tinyMCE.get("itemdescription").setContent(str);
		}
	    
	    $("#itemdescription").val(str);
	}
	
	function getItemDescription(){
		var item_description;
		
		if (typeof tinyMCE !== "undefined" && tinyMCE.get("itemdescription")){
			if ($("#wp-itemdescription-wrap").hasClass("tmce-active")){
				item_description = tinyMCE.get("itemdescription").getContent();
				
				if (item_description.length < 1){
					item_description = $("#itemdescription").val();
				}
			}else{
				item_description = $("#itemdescription").val();
			}
	    }else{
			item_description = $("#itemdescription").val();
		}

        return item_description.replace(/"/g, "'").replace(/\n/g, "");
	}
	

	$(".add_item_btn").click(function(e){
		e.preventDefault();
		
		var reg_exp = /pl[0-9]+_/;
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));
		
        $("#add-item-dialog").dialog("open");
    });
	
	$(".add_bulk_btn").click(function(e){
		var reg_exp = /pl[0-9]+_/;
	
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp)[0].slice(2, -1));

		openBulkUploader(e);
		return false;
	});
	
	var item_name_edit = $("#item_name_edit");
    var item_source_edit = $("#item_source_edit");
    var item_thumb_edit = $("#item_thumb_edit");
	var video_poster_source_edit = $("#video_poster_source_edit");
	var item_max_width_edit = $("#item_max_width_edit");
	var item_max_height_edit = $("#item_max_height_edit");
	var showAdsEdit = false;
    var allFieldsItemEdit = $([]).add(item_name_edit).add(item_source_edit).add(item_thumb_edit).add(item_max_width_edit).add(item_max_height_edit);

	$("#edit-item-dialog").dialog({
		autoOpen: false,
		width: 640,
	    height: 740,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlUpdate__,
	        click: function(){
	         	var fValid = true;
	         	var tips = $("#edit_item_tips");
	         	
	          	allFieldsItemEdit.removeClass("ui-state-error");
				
				fValid = fValid && checkLength(tips, item_name_edit, "item name", 1, 64);
	       		fValid = fValid && checkLength(tips, item_source_edit, "item source", 1, 456);
				
				if(item_max_width_edit.val().length != 0){
					fValid = fValid && checkIfIntegerAndLength(tips, item_max_width_edit, "item maximum width", 1, 256);
				}
				
				if(item_max_height_edit.val().length != 0){
					fValid = fValid && checkIfIntegerAndLength(tips, item_max_height_edit, "item maximum height", 1, 256);
				}
				
	          	if (fValid){
	          		var content = $("#pl" + cur_pl_id + "_item" + cur_item_id + " > h3").html();
			
	          		var pos = content.indexOf(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].name);
	          		
	          		content = content.slice(0, pos);
	          		
	          		$("#pl" + cur_pl_id + "_item" + cur_item_id + " > h3").html(content + item_name_edit.val().replace(/"/g, "'"));
	          		fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].name = item_name_edit.val().replace(/"/g, "'");
	          		fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].thumb = item_thumb_edit.val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].video_poster_source = video_poster_source_edit.val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source = item_source_edit.val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].max_width = item_max_width_edit.val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].max_height = item_max_height_edit.val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].subtitle = $("#videoSubtitleEdit").val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].thumbnailsPreview = $("#videoThumbPreviewEdit").val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].vast = $("#vastEdit").val().replace(/"/g, "'");
					fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].pass = $("#passEdit").val().replace(/"/g, "'");
	          		fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].dsecription = getItemDescriptionEdit();
					
					var parent  = document.getElementById("pl" + cur_pl_id + "_item" + cur_item_id);
					var child = document.getElementById("pl" + cur_pl_id + "_item" + cur_item_id + "_img");
					
					if(item_source_edit.val().replace(/"/g, "'").indexOf(".jpg") != -1 
					|| item_source_edit.val().replace(/"/g, "'").indexOf(".jpeg") != -1
					|| item_source_edit.val().replace(/"/g, "'").indexOf(".png") != -1){
						if($.contains(parent,child)){
							$("#pl" + cur_pl_id + "_item" + cur_item_id + "_img").attr("src", item_source_edit.val().replace(/"/g, "'"));
						}else{
							$("#pl" + cur_pl_id + "_item" + cur_item_id).append("<img src='" + item_source_edit.val() + "' id='pl" + cur_pl_id + "_item" + cur_item_id + "_img' class='fwd-item-playlist-img'></img>")
							
							$("#pl" + cur_pl_id + "_item" + cur_item_id + "_img").attr("src", item_source_edit.val().replace(/"/g, "'"));
						}
						
					}else{
						$("#pl" + cur_pl_id + "_item" + cur_item_id + "_img").remove();
					}				
					
					
		            $(this).dialog("close");
	         	}else{
	          		$("#edit-item-dialog").scrollTop(0);
	          	}
	        }},
	        {	
	        	text: fwdrlCancel__,
	        	click: function(){
	        	$(this).dialog("close");
	        }}
	    ],
	    close: function(){
		    allFieldsItemEdit.removeClass("ui-state-error");
		    $("#edit_item_tips").removeClass("fwd-error");
	    },
	    open: function(){

	    	$("#item_name_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].name);
	    	$("#item_thumb_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].thumb);
			$("#item_source_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source);
			if(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source.indexOf(".jpg") != -1
			  || fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source.indexOf(".jpeg") != -1
			  || fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source.indexOf(".png") != -1
			){
				$("#thumb_source_edit").attr("src", fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].source);
			}else{
				$("#thumb_source_edit").attr("src", "");
			}
			
			$("#video_poster_source_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].video_poster_source);
			$("#video_poster_thumb_edit").attr("src", fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].video_poster_source);
			$("#upload_thumb_edit").attr("src", fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].thumb);
			$("#item_max_width_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].max_width);
			$("#item_max_height_edit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].max_height);
			$("#videoSubtitleEdit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].subtitle);
			$("#videoThumbPreviewEdit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].thumbnailsPreview);
			$("#vastEdit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].vast);
			$("#passEdit").val(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].pass);
		    setItemDescriptionEdit(fwdMainPlaylistsAr[curPlOrderId].items[curItemOrderId].dsecription);
			
			showAdsEdit = false;
			
		    $("#wp-itemdescriptionedit-wrap").attr("style", "margin-top:-30px;");
		    $("#itemdescriptionedit-html").html("HTML");
			$("#wp-itemdecrpedit-wrap").attr("style", "margin-top:-30px;");
		    $("#itemdecrpedit-html").html("HTML");
		    $("#edit_item_tips").text("The item name and item source are required.");
       		$("#itemdescriptionedit_ifr").height(181);
       		$("#itemdecrpedit_ifr").height(181);
       		$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	
	function setItemDescriptionEdit(str){
		if (typeof tinyMCE !== "undefined" && tinyMCE.get("itemdescriptionedit")){
	    	tinyMCE.get("itemdescriptionedit").setContent(str);
	    }
	    
	    $("#itemdescriptionedit").val(str);
	}
	
	function getItemDescriptionEdit(){
		var item_description_edit;
		
		if (typeof tinyMCE !== "undefined" && tinyMCE.get("itemdescriptionedit")){
			if ($("#wp-itemdescriptionedit-wrap").hasClass("tmce-active")){
				item_description_edit = tinyMCE.get("itemdescriptionedit").getContent();
				
				if (item_description_edit.length < 1){
					item_description_edit = $("#itemdescriptionedit").val();
				}
			}else{
				item_description_edit = $("#itemdescriptionedit").val();
			}
	    }else{
			item_description_edit = $("#itemdescriptionedit").val();
		}
		
		

        return item_description_edit.replace(/"/g, "'").replace(/\n/g, "");
	}
	
	$(".edit_item_btn").click(function(e){
		e.preventDefault();
				
		var reg_exp1 = /pl[0-9]+_/;
		var reg_exp2 = /item[0-9]+_/;
		
		cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
		cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));
		
		var allMpItems = $("#main_playlists").sortable("toArray");
		curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);
		
		var allItemItems = $("#pl" + cur_pl_id + "_items").sortable("toArray");
		curItemOrderId = allItemItems.indexOf("pl" + cur_pl_id + "_item" + cur_item_id);

        $("#edit-item-dialog").dialog("open");
    });
	
	$("#delete-item-dialog").dialog({
		autoOpen: false,
		width: 300,
	    height: 160,
	    dialogClass:'fwdrl',
	    modal: true,
	    buttons:[{
	    	text: fwdrlYes__,
	        click: function(){
				var allPlItems = $("#main_playlists").sortable("toArray");
		   		curPlOrderId = allPlItems.indexOf("pl" + cur_pl_id);
		       
		   		var allItemItems = $("#pl" + cur_pl_id + "_items").sortable("toArray");
		   		curItemOrderId = allItemItems.indexOf("pl" + cur_pl_id + "_item" + cur_item_id);
		   		
		   		fwdMainPlaylistsAr[curPlOrderId].items.splice(curItemOrderId, 1);
		   		
		   		$("#pl" + cur_pl_id  + "_item" + cur_item_id).remove();
			
		   		$(".items").sortable("refresh");
			
		        $(this).dialog("close");
	        }},
	        {
	        	text: fwdrlNo__,
	        	click: function(){
	        	$(this).dialog("close");
	        }}
	    ],
	    open: function(){
       		$('.ui-widget-overlay').addClass('fwdrl');
		}
	});
	
	$(".delete_item_btn").click(function(e){
		e.preventDefault();
	
		var reg_exp1 = /pl[0-9]+_/;
		var reg_exp2 = /item[0-9]+_/;

		cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
		cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));
		
        $("#delete-item-dialog").dialog("open");
    });
	
	
	/**
	  * Media uploaders.
	  */
	var custom_uploader4,
		curScroll4,
		custom_uploader7,
		custom_uploader8,
		curScroll7,
		custom_uploader22,
		curScroll8,
		custom_uploader,
		curScroll,
		custom_uploader5,
		curScroll5,
		custom_uploader_edit,
		curScrollEdit,
		custom_bullk,
		curScrollEdit;
    
    $("#upload_thumb_button").click(function(e) {
        e.preventDefault();
		
		curScroll = $("#add-item-dialog").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader4){
            custom_uploader4.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader4 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseImage__,
            button:{
                text: fwdrlAddImage__
            },library:
            {
            	type: "image"
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader4.on("select", function(){
            var attachment = custom_uploader4.state().get("selection").first().toJSON();
      
            $("#item_thumb").val(attachment.url);
			$("#upload_thumb").attr("src", attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader4.open();
		
		custom_uploader4.on("close", function(){
            $("#add-item-dialog").scrollTop(curScroll);
        });
    });

    $("#videoThumbPreviewButton").click(function(e) {
        e.preventDefault();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader8){
            custom_uploader8.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader8 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseVTT__,
            button:{
                text: fwdrlAddVTT__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader8.on("select", function(){
            var attachment = custom_uploader8.state().get("selection").first().toJSON();
            $("#videoThumbPreview").val(attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader8.open();
    });

    $("#videoThumbPreviewButtonEdit").click(function(e) {
        e.preventDefault();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader8){
            custom_uploader8.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader8 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseVTT__,
            button:{
                text: fwdrlAddVTT__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader8.on("select", function(){
            var attachment = custom_uploader8.state().get("selection").first().toJSON();
            $("#videoThumbPreviewEdit").val(attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader8.open();
    });

    $("#videoSubtitleButton").click(function(e) {
        e.preventDefault();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader7){
            custom_uploader7.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader7 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseSubtitle__,
            button:{
                text: fwdrlAddSubtitle__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader7.on("select", function(){
            var attachment = custom_uploader7.state().get("selection").first().toJSON();
         
            $("#videoSubtitle").val(attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader7.open();
    });

    $("#videoSubtitleEditButton").click(function(e) {
        e.preventDefault();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader7){
            custom_uploader7.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader7 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseSubtitle__,
            button:{
                text: fwdrlAddSubtitle__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader7.on("select", function(){
            var attachment = custom_uploader7.state().get("selection").first().toJSON();
            
            $("#videoSubtitleEdit").val(attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader7.open();
    });
	
    $("#video_poster_upload_button").click(function(e) {
        e.preventDefault();
		
		curScroll7 = $("#add-item-dialog").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader22){
            custom_uploader22.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader22 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseImage__,
            button:{
                text: fwdrlAddImage__
            },library:{
            	type: "image"
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader22.on("select", function(){
            var attachment = custom_uploader22.state().get("selection").first().toJSON();
            
            $("#video_poster_source").val(attachment.url);
			$("#video_poster_thumb").attr("src", attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader22.open();
		
		custom_uploader22.on("close", function(){
            $("#add-item-dialog").scrollTop(curScroll7);
        });
    });
	
    $("#video_poster_upload_button_edit").click(function(e) {
        e.preventDefault();
		
		curScroll8 = $("#add-item-dialog-edit").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader22){
            custom_uploader22.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader22 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseImage__,
            button:{
                text: fwdrlAddImage__
            },library:{
            	type: "image"
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader22.on("select", function(){
            var attachment = custom_uploader22.state().get("selection").first().toJSON();
            
            $("#video_poster_source_edit").val(attachment.url);
			$("#video_poster_thumb_edit").attr("src", attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader22.open();
		
		custom_uploader22.on("close", function(){
            $("#add-item-dialog-edit").scrollTop(curScroll8);
        });
    });
	
    $("#upload_item_source_button").click(function(e) {
        e.preventDefault();
		
		curScroll = $("#add-item-dialog").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader){
            custom_uploader.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseItem__,
            button:{
                text: fwdrlAddItem__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader.on("select", function(){
            var attachment = custom_uploader.state().get("selection").first().toJSON();
            
            $("#item_source").val(attachment.url);
			if(attachment.url.indexOf(".jpg") != -1
			  || attachment.url.indexOf(".jpeg") != -1
			  ||  attachment.url.indexOf(".png") != -1
			){
				$("#thumb_source").attr("src", attachment.url);
			}else{
				$("#thumb_source").attr("src", "");
			}
        });
 
        // Open the uploader dialog.
        custom_uploader.open();
		
		custom_uploader.on("close", function(){
            $("#add-item-dialog").scrollTop(curScroll);
        });
    });
	
	
    $("#upload_thumb_button_edit").click(function(e) {
        e.preventDefault();
		
		curScroll5 = $("#add-item-dialog").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader5){
            custom_uploader5.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader5 = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseImage__,
            button:{
                text: fwdrlAddImage__
            },library:{
            	type: "image"
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader5.on("select", function(){
            var attachment = custom_uploader5.state().get("selection").first().toJSON();
            
            $("#item_thumb_edit").val(attachment.url);
			$("#upload_thumb_edit").attr("src", attachment.url);
        });
 
        // Open the uploader dialog.
        custom_uploader5.open();
		
		custom_uploader5.on("close", function(){
            $("#add-item-dialog-edit").scrollTop(curScroll5);
        });
    });

    $("#upload_item_button_edit").click(function(e){
        e.preventDefault();
		
		curScrollEdit = $("#edit-item-dialog").scrollTop();
 
        // If the uploader object has already been created, reopen the dialog.
        if (custom_uploader_edit){
            custom_uploader_edit.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_uploader_edit = wp.media.frames.file_frame = wp.media(
        {
            title: fwdrlChooseItem__,
            button:{
                text: fwdrlAddItem__
            },
            multiple: false
        });
 
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_uploader_edit.on("select", function(){
            var attachment = custom_uploader_edit.state().get("selection").first().toJSON();   
            $("#item_source_edit").val(attachment.url);
			$("#thumb_source_edit").attr("src", attachment.url);
			
			if(attachment.url.indexOf(".jpg") != -1
			  || attachment.url.indexOf(".jpeg") != -1
			  || attachment.url.indexOf(".png") != -1
			){
				$("#thumb_source_edit").attr("src", attachment.url);
			}else{
				$("#thumb_source_edit").attr("src", "");
			}
        });
 
        // Open the uploader dialog.
        custom_uploader_edit.open();
		
		custom_uploader_edit.on("close", function() {
            $("#edit-item-dialog").scrollTop(curScrollEdit);
        });
    });

    
    /**
      * Add bulk items.
      */
    function openBulkUploader(e){
   		
        e.preventDefault();
		
        // If the uploader object has already been created, reopen the dialog.
        if (custom_bullk){
            custom_bullk.open();
            return;
        }
        
        // Extend the wp.media object.
        custom_bullk = wp.media.frames.file_frame = wp.media({
            title: fwdrlChooseMultipleItems__,
            button:{
                text: fwdrlAddItem__
            },library:{
            	type: "image, video, audio"
            },
            multiple: true
        });

  		
        // When a file is selected, grab the URL and set it as the text field's value.
        custom_bullk.on("select", function(){
        	var allMpItems = $("#main_playlists").sortable("toArray");
			curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);

           	var attachment = custom_bullk.state().get("selection").toJSON();
			for(var i = 0; i<attachment.length; i++){
				var isDuplicate = false;
				
				for(var j=0; j<fwdMainPlaylistsAr[curPlOrderId].items.length; j++){
					if(fwdMainPlaylistsAr[curPlOrderId].items[j].source == attachment[i].url){
						isDuplicate = true;
					}
				}

				if(!isDuplicate){
					var itemId = fwdMainPlaylistsAr[curPlOrderId].items.length;
					var itemsIdsAr = [];
								
					$.each($("#pl" + cur_pl_id + "_items .fwd-item"), function(i, el){
						var reg_exp = /item[0-9]+/;
						var item_id = parseInt($(el).attr("id").match(reg_exp)[0].slice(4));
						itemsIdsAr.push(item_id);
					});
				
					for (var k=0; k<fwdMainPlaylistsAr[curPlOrderId].items.length; k++){
						if ($.inArray(k, itemsIdsAr) == -1){
							itemId = k;
							break;
						}
					}
					
					addBulkItems(curPlOrderId, cur_pl_id, itemId, attachment[i].title, attachment[i].url);
				}
			}

			$(".edit_item_btn").off('click');
			$(".edit_item_btn").on('click', function(e){
				e.preventDefault();
		
				var reg_exp1 = /pl[0-9]+_/;
				var reg_exp2 = /item[0-9]+_/;

				cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
				cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));

				
				var allMpItems = $("#main_playlists").sortable("toArray");
				curPlOrderId = allMpItems.indexOf("pl" + cur_pl_id);

				var allItemItems = $("#pl" + cur_pl_id + "_items").sortable("toArray");
				curItemOrderId = allItemItems.indexOf("pl" + cur_pl_id + "_item" + cur_item_id);

				$("#edit-item-dialog").dialog("open");
			});
			
			$(".delete_item_btn").on('click', function(e){
				e.preventDefault();
			
				var reg_exp1 = /pl[0-9]+_/;
				var reg_exp2 = /item[0-9]+_/;
				
				cur_pl_id = parseInt($(this).attr("id").match(reg_exp1)[0].slice(2, -1));
				cur_item_id = parseInt($(this).attr("id").match(reg_exp2)[0].slice(4, -1));
				
				$("#delete-item-dialog").dialog("open");
			});
        });

        //Open the uploader dialog
        custom_bullk.open();
    };
	
	function addBulkItems(curPlOrderId, cur_pl_id, itemId, title, source){
		if(source.indexOf(".jpg") != -1 || source.indexOf(".jpeg") != -1 || source.indexOf(".png") != -1){
			$("#pl" + cur_pl_id +  "_items").prepend("<div id='pl" + cur_pl_id + "_item" + itemId + "' class='fwd-item'>"
				+ "<h3 class='item-header'>" + title.replace(/"/g, "'") + "</h3>"
				+ "<button class='delete_item_btn' id='pl" + cur_pl_id + "_item" + itemId + "_del_btn'>" + fwdrlDelete__ + "</button>"
				+ "<button class='edit_item_btn' id='pl" + cur_pl_id +  "_item" + itemId + "_edit_btn'>" + fwdrlEdit__ + "</button>"
				+ "<img class='fwd-item-playlist-img' id='pl" + cur_pl_id + "_item" + itemId + "_img'></img>"
			+ "</div>");
			$("#pl" + cur_pl_id + "_item" + itemId + "_img").attr("src", source);
		}else{
			$("#pl" + cur_pl_id +  "_items").prepend("<div id='pl" + cur_pl_id + "_item" + itemId + "' class='fwd-item'>"
				+ "<h3 class='item-header'>" + title.replace(/"/g, "'") + "</h3>"
				+ "<button class='delete_item_btn' id='pl" + cur_pl_id + "_item" + itemId + "_del_btn'>" + fwdrlDelete__ + "</button>"
				+ "<button class='edit_item_btn' id='pl" + cur_pl_id +  "_item" + itemId + "_edit_btn'>" + fwdrlEdit__ + "</button>"
			+ "</div>");
		}
	
		$(".items").sortable("refresh");
		
		$(".fwd-item").mouseover(function(){
			$(this).addClass("item_over");
			$(this).find(".item-header").css("color", "#212121");
		});
		
		$(".fwd-item").mouseout(function(){
			$(this).removeClass("item_over");
			$(this).find(".item-header").css("color", "#555555");
		});
		
		var newItem ={
			name: title.replace(/"/g, "'"),
			source: source.replace(/"/g, "'"),
			thumb: "",
			video_poster_source: undefined,
			max_width: undefined,
			max_height: undefined,
			subtitle: undefined,
			thumbnailsPreview:undefined,
			vast: undefined,
			pass: undefined,
			dsecription:"",
		};
		
		fwdMainPlaylistsAr[curPlOrderId].items.unshift(newItem);
	}
	
    $("#update_btn").click(function(){
    	$("#playlist_data").val(JSON.stringify(fwdMainPlaylistsAr));
    });


    /**
      * Utils.
      */
    function checkLength(tips, el, prop, min, max){
      	if ((el.val().length > max) || (el.val().length < min)){
        	el.addClass("ui-state-error");
        	updateTips(tips, "Length of " + prop + " must be between " + min + " and " + max + ".");
        	
        	return false;
      	}else{
        	return true;
      	}
	}
	
    function checkIfIntegerAndLength(tips, el, prop, min, max){

    	var int_reg_exp = /-?[0-9]+/;
    	var str = el.val();
    	var res = str.match(int_reg_exp);
    	
    	if (res && (res[0] == str)){
    		if ((el.val().length > max) || (el.val().length < min)){
            	el.addClass("ui-state-error");
				updateTips(tips, "Length of " + prop + " must be between " + min + " and " + max + ".");
            	return false;
          	}else{
            	return true;
          	}
        }else{
        	el.addClass("ui-state-error");
        	updateTips(tips, "The " + prop + " field value must be an integer.");
        	return false;
        }
	}
	
	function updateTips(tips, txt){
	    tips.text(txt).addClass("ui-state-highlight");
	    setTimeout(function(){
	    	tips.removeClass("ui-state-highlight", 1500);
	    }, 500);
	    
	    tips.addClass("fwd-error");
	}

    function checkTimeFormat(tips, el, prop, min, max){
		var timeRegExp = /^(?:2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]$/;
      	if(!timeRegExp.test(el.val())){
        	el.addClass("ui-state-error");
        	updateTips(tips, "The  " + prop + " field must have the format hh:mm:ss ex:00:10:48 .");
        	return false;
      	}else{
        	return true;
      	}
	}

    function escapeHtml(str) {
	    var map = {
	        "&": "&amp;",
	        "<": "&lt;",
	        ">": "&gt;",
	        "\"": "&quot;",
	    "'": "&#039;"
	    };
	    str = str.replace(/'/g, "\"");
	    return str.replace(/[&<>"']/g, function(m) { return map[m]; });
	}

	function unescapeHtml(str) {
	    var map = {
	        "&amp;": "&",
	        "&lt;": "<",
	        "&gt;": ">",
	        "&quot;": "\"",
	        "&#039;": "'"
	    };
	    return str.replace(/(&amp;|&lt;|&gt;|&quot;|&#039;)/g, function(m) { return map[m]; });
	}

	function removeFirstAndLastChar(str){
	    str = str.substring(1);
	    str = str.slice(0, -1);
	    return str;
	}
})

Youez - 2016 - github.com/yon3zu
LinuXploit