<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<html:html lang="true">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title></title>
<meta http-equiv="pragma" content="no-cache"/>
<meta http-equiv="cache-control" content="no-cache"/>
<meta http-equiv="expires" content="0"/>
<link type="text/css" rel="stylesheet" href="./css/common.css"></link>
<link type="text/css" rel="stylesheet" href="./css/screen.css"></link>
<link rel="stylesheet" type="text/css" href="./css/jquery.multiselect.css" />
<link rel="stylesheet" type="text/css" href="./css/jquery-ui.css"/>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery-ui.min.js"></script>
<script type="text/javascript" src="./js/jquery.multiselect.min.js"></script>
<script type="text/javascript" src="./js/prettify.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="./js/ajaxupload.js"></script>
<script type="text/javascript" src="./js/jquery/jquery.validate.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery/additional-methods.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery/jquery.metadata.js"></script>
<script type="text/javascript">
var menuDoFlg = false;
$(document).ready(function(){
//add confirm flag start
$("#confirmFlg").val("true");
$("body").find("input,select,textarea").live('change', function(){
//do flag
menuDoFlg = true;
});
//add confirm flag end
//advancedBtn button show additional information
$("#advancedBtn").click(function(){
$("#advancedTog").slideToggle("fast");
});
/* ico update delete 3
//Publisher ajax request company's ico
$("#companyID").change(function(){
var url = $("#urlrequest").val()+"/searchICOURLinfoAction.do?companyID="+$("#companyID").val();
$.ajax({
url: url,
type:'post',
dataType:"json",
success:function (data){
if(data.message=="success"){
$("#iconURL").val(data.companyICOURLinfo.iconURL);
$("#iconURLS").val(data.companyICOURLinfo.iconurls);
$("#iconURLU").val(data.companyICOURLinfo.iconurlu);
}
}
});
});
*/
//decide flag for new.jsp(preview)\reuse.jsp(preview)\edit.jsp
if($("#neworeditFlag").val()=="new"){
$("#pageid").text("New Ads");
$("title").val("New Ads");
document.title="New Ads";
$("#adsNametxt").removeAttr("readonly");
$("#adsNametxt").bind("keydown");
$("#accessState").val("first");
//do flag
menuDoFlg = true;
}else if($("#neworeditFlag").val()=="reuse"){
$("#pageid").text("Reuse Ads");
$("title").val("Reuse Ads");
document.title="Reuse Ads";
$("#adsNametxt").removeAttr("readonly");
$("#adsNametxt").bind("keydown");
//do flag
menuDoFlg = true;
}else{
$("#pageid").text("Edit Ads");
$("title").val("Edit Ads");
document.title="Edit Ads";
$("#neworeditFlag").val("edit");
$("#adsNametxt").attr("readonly","readonly");
$("#adsNametxt").keydown(function(){
return false;
});
}
var newItem = $('#newItem');
//Line up multiselect
var elLineUp= $("#targetLineUpCheckBox").multiselect({
header: true,
minWidth: 146,
height: 100,
Options:true,
noneSelectedText: 'Line Up',
selectedText: 'Line Up',
checkAll:function(event){
//do flag
menuDoFlg = true;
//check all models of Line up by clicked
//$.each(event.target.options,function(i,item){
var linestr = $.map(elModels.multiselect("getChecked"), function( input ){
return input.title;
});
//ajax request models target function parameter1: selected parameter2: short model(0) or full model(1)
chageLevel2fn(linestr,$("#modelType").val()=="0"?"short":"full");
//});
},
uncheckAll:function(event){
//do flag
menuDoFlg = true;
//disabled
elModels.empty();
elModels.multiselect('refresh');
elModels.multiselect('disable');
},
click: function(event, ui){
//do flag
menuDoFlg = true;
//get models by clicked
var linestr = $.map(elModels.multiselect("getChecked"), function( input ){
return input.title;
});
//ajax request models target function parameter1: selected parameter2: short model(0) or full model(1)
chageLevel2fn(linestr,$("#modelType").val()=="0"?"short":"full");
}
});
//Models multiselect
var elModels= $("#targetModelsCheckBox").multiselect({
header: true,
minWidth: 146,
height: 100,
noneSelectedText: 'Models',
selectedText: 'Models'
});
//Country multiselect
var elCountry= $("#targetCountryCheckBox").multiselect({
header: true,
minWidth: 146,
height: 100,
noneSelectedText: 'Country',
selectedText: 'Country',
checkAll:function(event){
//do flag
menuDoFlg = true;
//check all languages of Country by clicked
//$.each(event.target.options,function(i,item){
var selstr = $.map(elLanguage.multiselect("getChecked"), function( input ){
return input.title;
});
//get blue language value
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//ajax request language target function parameter1: selected
chageLevel4fn(selstr,false);
//});
//remove disabled
$("#titleTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#advancedBtn").removeAttr("disabled");
$("#messageTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#actionTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#uploadpictureShow").css({background: "#FFFFFF"});
$("#uploadpicture").css('display','block');
},
uncheckAll:function(event){
//do flag
menuDoFlg = true;
//disabled
elLanguage.empty();
elLanguage.multiselect('refresh');
elLanguage.multiselect('disable');
$("#hiddenshow").empty();
$("#langButtonDiv").empty();
$("#titleTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#advancedBtn").attr('disabled',"true");
$("#messageTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#actionTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#uploadpictureShow").css({background: "#f0f0f0"}).val("");
$("#uploadpicture").css('display','none');
$("#targetOperationCheckBox").val("open");
$("#targetParameters").val("");
$("#targetDirectory").val("");
$("#targetDisplayCheckBox").val("1");
$("#RegKeyDisplay").val("");
$("#regKeyDoNotDisplay").val("");
$("#languageStr").val("");
$("#deldiv").empty();
//validate331 empty error
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
//default 8 start
$("#defaultPictureU").val("");
$("#defaultPictureS").val("");
$("#defaultAction").val("");
$("#defaultFlag").val("0");
//default 8 end
//disabled advancedBtn 1
$("#advancedTog").hide();
},
click: function(event, ui){
//do flag
menuDoFlg = true;
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//get Country clicked
var counstr = $.map(elCountry.multiselect("getChecked"), function( input ){
return input.title;
});
//get Language clicked
var selstr = $.map(elLanguage.multiselect("getChecked"), function( input ){
return input.title;
});
if(ui.checked){
//remove disabled
$("#titleTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#advancedBtn").removeAttr("disabled");
$("#messageTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#actionTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#uploadpictureShow").css({background: "#FFFFFF"});
$("#uploadpicture").css('display','block');
}
//country target is not selected, initialize page
if(counstr==""||counstr==null){
$("#hiddenshow").empty();
$("#langButtonDiv").empty();
elLanguage.empty();
elLanguage.multiselect('refresh');
$("#titleTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#advancedBtn").attr('disabled',"true");
$("#messageTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#actionTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#uploadpictureShow").css({background: "#f0f0f0"}).val("");
$("#uploadpicture").css('display','none');
$("#targetOperationCheckBox").val("open");
$("#targetParameters").val("");
$("#targetDirectory").val("");
$("#targetDisplayCheckBox").val("1");
$("#RegKeyDisplay").val("");
$("#regKeyDoNotDisplay").val("");
$("#languageStr").val("");
$("#deldiv").empty();
//validate332 empty error
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
//default 5 default information
$("#defaultPictureU").val("");
$("#defaultPictureS").val("");
$("#defaultAction").val("");
$("#defaultFlag").val("0");
//default 5 end
//disabled advancedBtn 2
$("#advancedTog").hide();
}
//ajax request language target function parameter1: selected
chageLevel4fn(selstr,false);
}
});
//Language multiselect
var elLanguage= $("#targetLanguageCheckBox").multiselect({
header: true,
minWidth: 146,
height: 100,
noneSelectedText: 'Language',
selectedText: 'Language',
checkAll:function(event){
//do flag
menuDoFlg = true;
var selstr = $.map(elLanguage.multiselect("getChecked"), function( input ){
return input.title;
});
//get blue language value
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//ajax request language target function parameter1: selected
chageLevel4fn(selstr,false);
//remove disabled
$("#titleTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#advancedBtn").removeAttr("disabled");
$("#messageTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#actionTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#uploadpictureShow").css({background: "#FFFFFF"});
$("#uploadpicture").css('display','block');
},
uncheckAll:function(event){
//do flag
menuDoFlg = true;
//disabled
$("#hiddenshow").empty();
$("#langButtonDiv").empty();
$("#titleTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#advancedBtn").attr('disabled',"true");
$("#messageTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#actionTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#uploadpictureShow").css({background: "#f0f0f0"}).val("");
$("#uploadpicture").css('display','none');
$("#targetOperationCheckBox").val("open");
$("#targetParameters").val("");
$("#targetDirectory").val("");
$("#targetDisplayCheckBox").val("1");
$("#RegKeyDisplay").val("");
$("#regKeyDoNotDisplay").val("");
$("#languageStr").val("");
$("#deldiv").empty();
//validate333 empty error
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
//default 8 start
$("#defaultPictureU").val("");
$("#defaultPictureS").val("");
$("#defaultAction").val("");
$("#defaultFlag").val("0");
//default 8 end
//disabled advancedBtn 3
$("#advancedTog").hide();
},
click:function(event, ui){
//do flag
menuDoFlg = true;
//validate1 empty error
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//validate1 end
//default 9 set default start
if($("#defaultFlag").val()=="0"&&($("#titleTxt1").val()!=""||$("#messageTxt1").val()!=""||$("#actionTxt1").val()!=""||$("#uploadpictureShow").val()!="")){
$("#defaultPictureU").val($("#"+$(".Button_langblue").val()+"_pictureshow").val());
$("#defaultPictureS").val($("#"+$(".Button_langblue").val()+"_picture").val());
$("#defaultAction").val($("#"+$(".Button_langblue").val()+"_action").val());
$("#defaultFlag").val("1");
}
//default 9 set default end
$("#langButtonDiv").empty();
//get selected languages
var array_of_checked_values = $("#targetLanguageCheckBox").multiselect("getChecked").map(function(){return $(this).parent().children("span").text();}).get();
var i=0;
var targetFlg = false;
var content;
var languageStr="";
//each language create button and value
for(i in array_of_checked_values){
if (i == 0){//first language
$("#langButtonDiv").append("<input type='button' class='Button_langblue' id='"+array_of_checked_values[i]+"' name='"+array_of_checked_values[i]+"' value='"+array_of_checked_values[i]+"'/> ");
targetFlg = true;
$("#titleTxt1").val($("#"+$(".Button_langblue").val()+"_title").val());
$("#messageTxt1").val($("#"+$(".Button_langblue").val()+"_message").val());
$("#uploadpictureShow").val($("#"+$(".Button_langblue").val()+"_pictureshow").val());
$("#actionTxt1").val($("#"+$(".Button_langblue").val()+"_action").val());
$("#targetOperationCheckBox").attr("value",$("#"+$(".Button_langblue").val()+"_targetOperations").val());
$("#targetParameters").val($("#"+$(".Button_langblue").val()+"_targetParameters").val());
$("#targetDirectory").val($("#"+$(".Button_langblue").val()+"_targetDirectory").val());
$("#targetDisplayCheckBox").val($("#"+$(".Button_langblue").val()+"_targetDisplay").val());
$("#regKeyDisplay").val($("#"+$(".Button_langblue").val()+"_regKeyDisplay").val());
$("#regKeyDoNotDisplay").val($("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val());
} else {
$("#langButtonDiv").append("<input type='button' class='Button_langwhite' id='"+array_of_checked_values[i]+"' name='"+array_of_checked_values[i]+"' value='"+array_of_checked_values[i]+"'/> ");
}
//produce string
languageStr+=array_of_checked_values[i]+",";
//attaching event for language buttons
$("#"+array_of_checked_values[i]).click(function(){
$("#langButtonDiv").find("input").each(function () {
if($(this).attr('class')=="Button_langblue"){
//validate2 start
if($("#titleTxt1").val()==""||$("#titleTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
if($("#messageTxt1").val()==""||$("#messageTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
if($("#actionTxt1").val()==""||$("#actionTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
//validate2 end
$("#"+$(this).val()+"_title").val($("#titleTxt1").val());
$("#"+$(this).val()+"_message").val($("#messageTxt1").val());
$("#"+$(this).val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(this).val()+"_action").val($("#actionTxt1").val());
$("#"+$(this).val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(this).val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(this).val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(this).val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(this).val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(this).val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//default 1 start
if($("#defaultFlag").val()=="0"){
$("#defaultPictureU").val($("#"+$(this).val()+"_pictureshow").val());
$("#defaultPictureS").val($("#"+$(this).val()+"_picture").val());
$("#defaultAction").val($("#"+$(this).val()+"_action").val());
$("#defaultFlag").val("1");
}
//default 1 end
$(this).removeClass("Button_langblue").addClass("Button_langwhite");
return false;
}
});
$(this).removeClass("Button_langwhite").addClass("Button_langblue");
if($("#"+$(this).attr("id")+"_targetOperations").val()!=""){
$("#targetOperationCheckBox").attr("value",$("#"+$(this).attr("id")+"_targetOperations").val());
}else{
$("#targetOperationCheckBox").attr("value","open");
}
if($("#"+$(this).attr("id")+"_targetOperations").val()!=""){
$("#targetDisplayCheckBox").val($("#"+$(this).attr("id")+"_targetDisplay").val());
}else{
$("#targetDisplayCheckBox").val("1");
}
//default 3 start
if($("#"+$(this).attr("id")+"_pictureshow").val()!=null&&$("#"+$(this).attr("id")+"_pictureshow").val()!=""){
$("#uploadpictureShow").val($("#"+$(this).attr("id")+"_pictureshow").val());
}else if($("#"+$(this).attr("id")+"_title").val()==""&&$("#"+$(this).attr("id")+"_message").val()==""&&$("#"+$(this).attr("id")+"_action").val()==""&&$("#"+$(this).attr("id")+"_pictureshow").val()==""){
$("#uploadpictureShow").val($("#defaultPictureU").val());
$("#"+$(this).attr("id")+"_picture").val($("#defaultPictureS").val())
}else{
$("#uploadpictureShow").val("");
}
if($("#"+$(this).attr("id")+"_action").val()!=null&&$("#"+$(this).attr("id")+"_action").val()!=""){
$("#actionTxt1").val($("#"+$(this).attr("id")+"_action").val());
}else if($("#"+$(this).attr("id")+"_title").val()==""&&$("#"+$(this).attr("id")+"_message").val()==""&&$("#"+$(this).attr("id")+"_action").val()==""&&$("#"+$(this).attr("id")+"_pictureshow").val()==""){
$("#actionTxt1").val($("#defaultAction").val());
}else{
$("#actionTxt1").val("");
}
//default 3 end
$("#titleTxt1").val($("#"+$(this).attr("id")+"_title").val());
$("#messageTxt1").val($("#"+$(this).attr("id")+"_message").val());
$("#targetParameters").val($("#"+$(this).attr("id")+"_targetParameters").val());
$("#targetDirectory").val($("#"+$(this).attr("id")+"_targetDirectory").val());
$("#regKeyDisplay").val($("#"+$(this).attr("id")+"_regKeyDisplay").val());
$("#regKeyDoNotDisplay").val($("#"+$(this).attr("id")+"_regKeyDoNotDisplay").val());
if($("#"+$(".Button_langblue").val()+"_picture").val()!=null&&$("#"+$(".Button_langblue").val()+"_picture").val()!=""){
$("#deldiv").empty().append(" "+"<input type='button' class='delbotton' id='"+$(".Button_langblue").val()+"_delbutton' name = '"+$(".Button_langblue").val()+"_delbutton' value='Delete'/> ");
$("#"+$(".Button_langblue").val()+"_delbutton").click(function(){
//do flag
menuDoFlg = true;
$("#deldiv").empty();
$("#uploadpictureShow").val("");
$("#"+$(".Button_langblue").val()+"_picture").val("");
$("#"+$(".Button_langblue").val()+"_pictureshow").val("");
});
}else{
$("#deldiv").empty();
}
//validate3 start
if($(this).css("background-color")=="RGB\(255, 0, 0\)"||$(this).css("background-color")=="rgb\(255, 0, 0\)"||$(this).css("background-color")=="#ff0000"||$(this).css("background-color")=="#FF0000"){
$("#titleTxt1").trigger("focusout");
$("#messageTxt1").trigger("focusout");
$("#actionTxt1").trigger("focusout");
}else{
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
}
//validate3 end
});
}
//language empty
if(i==0&&$("#languageStr").val().split(",").length==1){
$("#titleTxt1").val($("#"+array_of_checked_values[0]+"_title").val());
$("#messageTxt1").val($("#"+array_of_checked_values[0]+"_message").val());
$("#actionTxt1").val($("#"+array_of_checked_values[0]+"_action").val());
$("#uploadpictureShow").val($("#"+array_of_checked_values[0]+"_pictureshow").val());
//disabled
$("#titleTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#advancedBtn").attr('disabled',"true");
$("#messageTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#actionTxt1").attr('disabled',"true").css({background: "#f0f0f0"}).val("");
$("#uploadpictureShow").css({background: "#f0f0f0"}).val("");
$("#uploadpicture").css('display','none');
$("#targetOperationCheckBox").val("open");
$("#targetParameters").val("");
$("#targetDirectory").val("");
$("#targetDisplayCheckBox").val("1");
$("#RegKeyDisplay").val("");
$("#regKeyDoNotDisplay").val("");
$("#languageStr").val("");
$("#deldiv").empty();
//validate334 empty error
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
//default 6 start
$("#defaultPictureU").val("");
$("#defaultPictureS").val("");
$("#defaultAction").val("");
$("#defaultFlag").val("0");
//default 6 end
//disabled advancedBtn 4
$("#advancedTog").hide();
}
languageStr = languageStr.substring(0,languageStr.length-1);
$("#languageStr").val(languageStr);
if(!ui.checked){//cancel checked
$("#hiddenshow").children().each(function () {
if(ui.text==$(this).attr("id").substring(0,$(this).attr("id").indexOf("_"))){
$(this).remove();
}
});
//default 7 start
if($("#uploadpictureShow").val()==""||$("#uploadpictureShow").val()==null){
$("#deldiv").empty();
}
if($("#"+$(".Button_langblue").val()+"_picture").val()!=null&&$("#"+$(".Button_langblue").val()+"_picture").val()!=""){
$("#deldiv").empty().append(" "+"<input type='button' class='delbotton' id='"+$(".Button_langblue").val()+"_delbutton' name = '"+$(".Button_langblue").val()+"_delbutton' value='Delete'/> ");
$("#"+$(".Button_langblue").val()+"_delbutton").click(function(){
//do flag
menuDoFlg = true;
$("#deldiv").empty();
$("#uploadpictureShow").val("");
$("#"+$(".Button_langblue").val()+"_picture").val("");
$("#"+$(".Button_langblue").val()+"_pictureshow").val("");
});
}else{
$("#deldiv").empty();
}
//default 7 end
}else if(ui.checked){//checked
if(i==0){
$("#hiddenshow").empty();
};
var lanFlag = true;
$("#hiddenshow").children().each(function () {
if(ui.text==$(this).attr("id").substring(0,$(this).attr("id").indexOf("_"))){
$(this).empty();
lanFlag=false;
}
});
content=
"<input type='hidden' name='"+ui.text+"_title' id='"+ui.text+"_title' />"+
"<input type='hidden' name='"+ui.text+"_message' id='"+ui.text+"_message' />"+
"<input type='hidden' name='"+ui.text+"_picture' id='"+ui.text+"_picture' value='"+$("#defaultPictureS").val()+"' />"+
"<input type='hidden' name='"+ui.text+"_pictureshow' id='"+ui.text+"_pictureshow' value='"+$("#defaultPictureU").val()+"' />"+
"<input type='hidden' name='"+ui.text+"_action' id='"+ui.text+"_action' value='"+$("#defaultAction").val()+"' />"+
"<input type='hidden' name='"+ui.text+"_targetOperations' id='"+ui.text+"_targetOperations' />"+
"<input type='hidden' name='"+ui.text+"_targetParameters' id='"+ui.text+"_targetParameters' />"+
"<input type='hidden' name='"+ui.text+"_targetDirectory' id='"+ui.text+"_targetDirectory' />"+
"<input type='hidden' name='"+ui.text+"_targetDisplay' id='"+ui.text+"_targetDisplay' />"+
"<input type='hidden' name='"+ui.text+"_regKeyDisplay' id='"+ui.text+"_regKeyDisplay' />"+
"<input type='hidden' name='"+ui.text+"_regKeyDoNotDisplay' id='"+ui.text+"_regKeyDoNotDisplay' />";
//default 10 start
if(ui.text==$(".Button_langblue").val()){
if($("#defaultFlag").val()=="1"){
if($("#"+ui.text+"_pictureshow").val()!=null&&$("#"+ui.text+"_pictureshow").val()!=""){
$("#uploadpictureShow").val($("#"+ui.text+"_pictureshow").val());
}else{
$("#uploadpictureShow").val($("#defaultPictureU").val());
$("#"+ui.text+"_picture").val($("#defaultPictureS").val())
}
if($("#"+ui.text+"_action").val()!=null&&$("#"+ui.text+"_action").val()!=""){
$("#actionTxt1").val($("#"+ui.text+"_action").val());
}else{
$("#actionTxt1").val($("#defaultAction").val());
}
}
}
//default 10 end
if(lanFlag){
$("#hiddenshow").append(content);
}
}
if (targetFlg) {
$("#titleTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#advancedBtn").removeAttr("disabled");
$("#messageTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#actionTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#uploadpictureShow").css({background: "#FFFFFF"});
$("#uploadpicture").css('display','block');
}
}
});
//language function
function chageLevel4fn(val,firstFlg){
var url = $("#urlrequest").val()+"/changeComboxAction.do";
var dataStr = 'selectedValLan='+$.map(elCountry.multiselect("getChecked"), function( input ){
return input.value;
});
if ('selectedValLan='==dataStr) {
elLanguage.multiselect('disable');
} else {
elCountry.multiselect('disable');
elLanguage.multiselect('disable');
$.ajax({
url: url,
type:'post',
data:dataStr,
success:function (data){
elLanguage.empty();
elLanguage.multiselect('refresh');
var obj = jQuery.parseJSON(data);
var tarParam = obj.items;
var key = val+"";
var languageChange = "";
$.each(tarParam,function(i,item){
var optionVal = item.id;
var optionLabel = item.label;
var optionflag = false;
if(firstFlg){
if(key.indexOf(item.label)>-1){
optionflag = true;
}
}else{
optionflag = true;
}
var v = newItem.val(), opt = $('<option />', {
value: optionVal,
text: optionLabel,
selected:optionflag
});
if(optionflag){
languageChange +=item.label+",";
}
opt.appendTo(elLanguage);
});
elLanguage.multiselect('refresh');
if(languageChange!=""){
languageChange = languageChange.substring(0,languageChange.length-1);
}
if(languageChange.length>0){
//all sign end 2
if($("#defaultFlag").val()=="0"&&($("#titleTxt1").val()!=""||$("#messageTxt1").val()!=""||$("#actionTxt1").val()!=""||$("#uploadpictureShow").val()!="")){
$("#defaultPictureU").val($("#"+$(".Button_langblue").val()+"_pictureshow").val());
$("#defaultPictureS").val($("#"+$(".Button_langblue").val()+"_picture").val());
$("#defaultAction").val($("#"+$(".Button_langblue").val()+"_action").val());
$("#defaultFlag").val("1");
}
//all sign end 2
$("#langButtonDiv").empty();
$.each(languageChange.split(","),function(i,item){
//all sign start 1
var content1=
"<input type='hidden' name='"+item+"_title' id='"+item+"_title' />"+
"<input type='hidden' name='"+item+"_message' id='"+item+"_message' />"+
"<input type='hidden' name='"+item+"_picture' id='"+item+"_picture' value='"+$("#defaultPictureS").val()+"' />"+
"<input type='hidden' name='"+item+"_pictureshow' id='"+item+"_pictureshow' value='"+$("#defaultPictureU").val()+"' />"+
"<input type='hidden' name='"+item+"_action' id='"+item+"_action' value='"+$("#defaultAction").val()+"' />"+
"<input type='hidden' name='"+item+"_targetOperations' id='"+item+"_targetOperations' />"+
"<input type='hidden' name='"+item+"_targetParameters' id='"+item+"_targetParameters' />"+
"<input type='hidden' name='"+item+"_targetDirectory' id='"+item+"_targetDirectory' />"+
"<input type='hidden' name='"+item+"_targetDisplay' id='"+item+"_targetDisplay' />"+
"<input type='hidden' name='"+item+"_regKeyDisplay' id='"+item+"_regKeyDisplay' />"+
"<input type='hidden' name='"+item+"_regKeyDoNotDisplay' id='"+item+"_regKeyDoNotDisplay' />";
if($("#languageStr").val()!=null&&$("#languageStr").val()!=""){
if(!($("#languageStr").val().indexOf(item)>-1)){
$("#hiddenshow").append(content1);
}
}else{
$("#hiddenshow").append(content1);
}
//all sign end 1
if(i==0){
$("#langButtonDiv").append("<input type='button' class='Button_langblue' id='"+item+"' name='"+item+"' value='"+item+"'/> ");
$("#titleTxt1").val($("#"+$(".Button_langblue").val()+"_title").val());
$("#messageTxt1").val($("#"+$(".Button_langblue").val()+"_message").val());
$("#uploadpictureShow").val($("#"+$(".Button_langblue").val()+"_pictureshow").val());
$("#actionTxt1").val($("#"+$(".Button_langblue").val()+"_action").val());
$("#targetOperationCheckBox").attr("value",$("#"+$(".Button_langblue").val()+"_targetOperations").val());
$("#targetParameters").val($("#"+$(".Button_langblue").val()+"_targetParameters").val());
$("#targetDirectory").val($("#"+$(".Button_langblue").val()+"_targetDirectory").val());
$("#targetDisplayCheckBox").val($("#"+$(".Button_langblue").val()+"_targetDisplay").val());
$("#regKeyDisplay").val($("#"+$(".Button_langblue").val()+"_regKeyDisplay").val());
$("#regKeyDoNotDisplay").val($("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val());
if($("#"+$(".Button_langblue").val()+"_pictureshow").val()!=null&&$("#"+$(".Button_langblue").val()+"_pictureshow").val()!=""){
$("#deldiv").empty().append(" "+"<input type='button' class='delbotton' id='"+$(".Button_langblue").val()+"_delbutton' name = '"+$(".Button_langblue").val()+"_delbutton' value='Delete'/> ");
$("#"+$(".Button_langblue").val()+"_delbutton").click(function(){
//do flag
menuDoFlg = true;
$("#deldiv").empty();
$("#uploadpictureShow").val("");
$("#"+$(".Button_langblue").val()+"_picture").val("");
$("#"+$(".Button_langblue").val()+"_pictureshow").val("");
});
}
}else{
$("#langButtonDiv").append("<input type='button' class='Button_langwhite' id='"+item+"' name='"+item+"' value='"+item+"'/> ");
}
$("#"+item).click(function(){
$("#langButtonDiv").find("input").each(function () {
if($(this).attr('class')=="Button_langblue"){
//validate21 start
if($("#titleTxt1").val()==""||$("#titleTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
if($("#messageTxt1").val()==""||$("#messageTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
if($("#actionTxt1").val()==""||$("#actionTxt1").val()==null){
$(this).css({"background-color": "#FF0000"});
}
//validate21 end
$("#"+$(this).val()+"_title").val($("#titleTxt1").val());
$("#"+$(this).val()+"_message").val($("#messageTxt1").val());
$("#"+$(this).val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(this).val()+"_action").val($("#actionTxt1").val());
$("#"+$(this).val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(this).val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(this).val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(this).val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(this).val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(this).val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
//show click button value
if($("#defaultFlag").val()=="0"){
$("#defaultPictureU").val($("#"+$(this).val()+"_pictureshow").val());
$("#defaultPictureS").val($("#"+$(this).val()+"_picture").val());
$("#defaultAction").val($("#"+$(this).val()+"_action").val());
$("#defaultFlag").val("1");
}
$(this).removeClass("Button_langblue").addClass("Button_langwhite");
return false;
}
});
$(this).removeClass("Button_langwhite").addClass("Button_langblue");
if($("#"+$(this).attr("id")+"_targetOperations").val()!=""){
$("#targetOperationCheckBox").attr("value",$("#"+$(this).attr("id")+"_targetOperations").val());
}else{
$("#targetOperationCheckBox").attr("value","open");
}
if($("#"+$(this).attr("id")+"_targetOperations").val()!=""){
$("#targetDisplayCheckBox").val($("#"+$(this).attr("id")+"_targetDisplay").val());
}else{
$("#targetDisplayCheckBox").val("1");
}
//default 4
if($("#"+$(this).attr("id")+"_pictureshow").val()!=null&&$("#"+$(this).attr("id")+"_pictureshow").val()!=""){
$("#uploadpictureShow").val($("#"+$(this).attr("id")+"_pictureshow").val());
}else if($("#"+$(this).attr("id")+"_title").val()==""&&$("#"+$(this).attr("id")+"_message").val()==""&&$("#"+$(this).attr("id")+"_action").val()==""&&$("#"+$(this).attr("id")+"_pictureshow").val()==""){
$("#uploadpictureShow").val($("#defaultPictureU").val());
$("#"+$(this).attr("id")+"_picture").val($("#defaultPictureS").val())
}else{
$("#uploadpictureShow").val("");
}
if($("#"+$(this).attr("id")+"_action").val()!=null&&$("#"+$(this).attr("id")+"_action").val()!=""){
$("#actionTxt1").val($("#"+$(this).attr("id")+"_action").val());
}else if($("#"+$(this).attr("id")+"_title").val()==""&&$("#"+$(this).attr("id")+"_message").val()==""&&$("#"+$(this).attr("id")+"_action").val()==""&&$("#"+$(this).attr("id")+"_pictureshow").val()==""){
$("#actionTxt1").val($("#defaultAction").val());
}else{
$("#actionTxt1").val("");
}
$("#titleTxt1").val($("#"+$(this).attr("id")+"_title").val());
$("#messageTxt1").val($("#"+$(this).attr("id")+"_message").val());
$("#targetParameters").val($("#"+$(this).attr("id")+"_targetParameters").val());
$("#targetDirectory").val($("#"+$(this).attr("id")+"_targetDirectory").val());
$("#regKeyDisplay").val($("#"+$(this).attr("id")+"_regKeyDisplay").val());
$("#regKeyDoNotDisplay").val($("#"+$(this).attr("id")+"_regKeyDoNotDisplay").val());
if($("#"+$(".Button_langblue").val()+"_picture").val()!=null&&$("#"+$(".Button_langblue").val()+"_picture").val()!=""){
$("#deldiv").empty().append(" "+"<input type='button' class='delbotton' id='"+$(".Button_langblue").val()+"_delbutton' name = '"+$(".Button_langblue").val()+"_delbutton' value='Delete'/> ");
$("#"+$(".Button_langblue").val()+"_delbutton").click(function(){
//do flag
menuDoFlg = true;
$("#deldiv").empty();
$("#uploadpictureShow").val("");
$("#"+$(".Button_langblue").val()+"_picture").val("");
$("#"+$(".Button_langblue").val()+"_pictureshow").val("");
});
}else{
$("#deldiv").empty();
}
//validate31
if($(this).css("background-color")=="RGB\(255, 0, 0\)"||$(this).css("background-color")=="rgb\(255, 0, 0\)"||$(this).css("background-color")=="#ff0000"||$(this).css("background-color")=="#FF0000"){
$("#titleTxt1").trigger("focusout");
$("#messageTxt1").trigger("focusout");
$("#actionTxt1").trigger("focusout");
}else{
$("#titleTxt1").removeClass("error").parent().next().next().empty();
$("#messageTxt1").removeClass("error").parent().next().next().empty();
$("#actionTxt1").removeClass("error").parent().next().next().empty();
}
//validate31
});
});
}
$("#languageStr").val(languageChange);
elCountry.multiselect('enable');
elLanguage.multiselect('enable');
$("#hiddenshow").children().each(function () {
if($("#targetLanguageCheckBox").text().indexOf($(this).attr("id").substring(0,$(this).attr("id").indexOf("_")))<0){
$(this).remove();
}
});
}
});
}
}
function chageLevel2fn(val,modelType){
var url = $("#urlrequest").val()+"/changeComboxAction.do";
//add by liuyan start
if(modelType!=null){
//short to full
var selectedShortVal;
if ("full"==modelType) {
selectedShortVal = $.map(elModels.multiselect("getChecked"), function( input ){return input.value;});
}
var dataStr = "selectedShortVal="+selectedShortVal+"&langButton="+modelType+'&selectedVal='+$.map(elLineUp.multiselect("getChecked"), function( input ){
return input.value;
});
}else{
var dataStr = 'selectedVal='+$.map(elLineUp.multiselect("getChecked"), function( input ){
return input.value;
});
}
//add by liuyan end
if ('selectedVal='==dataStr) {
elModels.multiselect('disable');
} else {
elLineUp.multiselect('disable');
elModels.multiselect('disable');
$.ajax({
url: url,
type:'post',
data:dataStr,
success:function(data){
elModels.empty();
elModels.multiselect('refresh');
var obj = jQuery.parseJSON(data);
var tarParam = obj.items;
var chagekey = val+"";
if(tarParam!=null&&tarParam!=""){
$.each(tarParam,function(i,item){
var optionVal = item.id;
var optionLabel = item.label;
var optionFlg = item.flg;
var chageoptionflag = false;
if(chagekey.indexOf(item.label)>-1){
chageoptionflag = true;
}
//short to full
if(optionFlg=="1"){
chageoptionflag = true;
}
var v = newItem.val(), opt = $('<option />', {
value: optionVal,
text: optionLabel,
selected:chageoptionflag
});
opt.appendTo(elModels);
});
elModels.multiselect('refresh');
elModels.multiselect('enable');
}
elLineUp.multiselect('enable');
}
});
}
}
//add short button full button click event start liuyan
if($("#modelType").val()=="0"){
$("#shortButton").attr("class","Button_Model_Light");
$("#fullButton").attr("class","Button_Model_Yet");
}else if($("#modelType").val()=="1"){
$("#shortButton").attr("class","Button_Model_Yet");
$("#fullButton").attr("class","Button_Model_Light");
}
$("#shortButton").click(
function(){
$("#shortButton").attr("class","Button_Model_Light");
$("#fullButton").attr("class","Button_Model_Yet");
if($("#modelType").val()=="1"){
//do flag
menuDoFlg = true;
chageLevel2fn(null,"short");
}
$("#modelType").val("0");//short
}
);
$("#fullButton").click(
function(){
$("#shortButton").attr("class","Button_Model_Yet");
$("#fullButton").attr("class","Button_Model_Light");
if($("#modelType").val()=="0"){
//do flag
menuDoFlg = true;
chageLevel2fn(null,"full");
}
$("#modelType").val("1");//full
}
);
//add short button full button click event end
//edit.jsp Initialization assignment
if($("#languageStr").val()!=null&&$("#languageStr").val()!=""&&$("#languageStr").val()!="null"){
chageLevel4fn($("#languageStr").val(),true);
$("#titleTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#advancedBtn").removeAttr("disabled");
$("#messageTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#actionTxt1").removeAttr("disabled").css({background: "#FFFFFF"});
$("#uploadpictureShow").css({background: "#FFFFFF"});
$("#uploadpicture").css('display','block');
}
if($("#modelType").val()!=null&&$("#modelType").val()!=""){
chageLevel2fn($("#modelStr").val(),$("#modelType").val()=="0"?"short":"full");
}
});
$(document).ready(function(){
/* ico update delete 2
//upload ico/png
new AjaxUpload('#uploadicon', {
action: $("#urlrequest").val()+'/fileUploadAction.do?type=changeImg',
name: 'myfile1',
onSubmit:function(file, extension){
if (!(extension && /^(ico|png)$/i.test(extension)))
{
alert("Please upload ico or png format file!");
return false;
}else{
$("#iconURLU").removeClass("error").parent().next().next().empty();
}
},
onComplete : function(file, response){
if(response=="error1"){
alert("The image file must be smaller than 1MB!");
return false;
//}else if(response=="error2"){
// alert("Upload image file error!");
// return false;
}else{
//do flag
menuDoFlg = true;
$("#iconURL").val(response.substring(0,response.indexOf("|")));
$("#iconURLU").val(file);
$("#iconURLS").val(response.substring(response.indexOf("|")+1,response.length));
}
}
});
*/
//upload picture png|jpg|gif|bmp|jpeg
new AjaxUpload('#uploadpicture', {
action: $("#urlrequest").val()+'/fileUploadAction.do?type=picture',
name: 'myfile2',
onSubmit:function(file, extension){
if (!(extension && /^(png|jpg|gif|bmp|jpeg)$/i.test(extension)))
{
alert("Pictures only support format of png, jpg, gif, bmp and jpeg!");
return false;
}
},
onComplete : function(file, response){
if(response=="error1"){
alert("The image file must be smaller than 1MB!");
return false;
}else{
//do flag
menuDoFlg = true;
$("#"+$(".Button_langblue").val()+"_picture").val(response.substring(0,response.indexOf("|")));
$("#"+$(".Button_langblue").val()+"_pictureshow").val(file);
$("#uploadpictureShow").val(file);
$("#deldiv").empty().append(" "+"<input type='button' class='delbotton' id='"+$(".Button_langblue").val()+"_delbutton' name = '"+$(".Button_langblue").val()+"_delbutton' value='Delete'/> ");
$("#"+$(".Button_langblue").val()+"_delbutton").click(function(){
//do flag
menuDoFlg = true;
$("#deldiv").empty();
$("#uploadpictureShow").val("");
$("#"+$(".Button_langblue").val()+"_picture").val("");
$("#"+$(".Button_langblue").val()+"_pictureshow").val("");
});
}
}
});
});
//validate start
$(document).ready(function(){
//validate URL
$.validator.addMethod("url", function(value, element) {
return this.optional(element) || /(\w+):\/\/([^/:]+)(:\d*)?([^# ]*)/.test(value);
}, "url pattern is not correct!");
//validate char
$.validator.addMethod("escapeString", function(value, element) {
return this.optional(element) || !/[/\\:?*"<>|.]+/.test(value);
}, "Ads name can't contain any of following characters: /\:?*\"<>|.");
$.validator.addMethod("twoInteger", function(value, element) {
return this.optional(element) || /^[0-9]{2}$/.test(value);
}, "Please input two and only two digits!");
//validate Display Interval writer: liuyan 2011-08-23
$.validator.addMethod("IntervalValidate", function(value, element) {
var success=true;
var isDigit=true;
// intervalValue=[weekValue,datValue,HourValue,MinValue]
var intervalValue=[$("#displayInternalWeeks").val(),$("#displayInternalDays").val(),$("#displayInternalHours").val(),$("#displayInternalMins").val()];
for(var m in intervalValue){
//the value must be two integer
if(!/^[0-9]{2}$/.test(intervalValue[m])){
isDigit=false;
break;
}
}
if(isDigit){
var interval=[parseInt($("#displayInternalWeeks").val(),10),parseInt($("#displayInternalDays").val(),10),parseInt($("#displayInternalHours").val(),10),parseInt($("#displayInternalMins").val(),10)];
var timeCirle=[7,24,60];
var intervalIndex=-1;
//day 7,hour 24,min 60
for(var i in interval){
if(interval[i]>0){
intervalIndex=i;
break;
}
}
if(intervalIndex!=-1){
//success==true if week is not '00' ,the day <7, hour <24,min <60 and if week and day are not '00' ,the hour<20 ,min <60 and so on.
for(var j=parseInt(intervalIndex,10)+1;j<interval.length;j++ ){
if(interval[j]>=timeCirle[j-1]){
success=false;
break;
}
}
}
if(success){
// remove error class
var intervalID=["displayInternalWeeks","displayInternalDays","displayInternalHours","displayInternalMins"];
for(var k in intervalID){
if(element.id!=intervalID[k]){
$("#"+intervalID[k]).removeClass("error");
//$("#"+intervalID[k]).trigger("focusout");
}
}
$("#displayInternalMins").parent().next().next().children("label").remove();
}
}
return this.optional(element) || (/^[0-9]{2}$/.test(value)&&isDigit&&success);
}, "Please input correct format of time period!");
//validate Display Interval writer: liuyan 2011-08-23
// add by liu yan 2011-09-27 start
function disabledButtons() {
$("#submitBotton").attr("disabled",true);
$("#saveBotton").attr("disabled",true);
$("#previewBotton").attr("disabled",true);
$("#cancelBotton").attr("disabled",true);
}
function enabledButtons() {
$("#submitBotton").attr("disabled",false);
$("#saveBotton").attr("disabled",false);
$("#previewBotton").attr("disabled",false);
$("#cancelBotton").attr("disabled",false);
}
var ignoreEndDateValidate=false;
var ignoreAdsNameValidate=false;
$("#endDatetxt").focusout(function(evt){
//console.log(evt.target.value+"===="+$("#adsNametxt").val());
if($.trim($("#endDatetxt").val())){
$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkDateAction.do",
data : {endDatetxt:$("#endDatetxt").val()},
dataType : "json",
success : function(data) {
if(true==data){
//remove error class
}else{
validator.showErrors({"endDatetxt":"End date must be greater than current date"});
}
}
});
}
});
// add by liu yan 2011-09-27 end
if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
//add by liuyan 2011-09-27 start
$("#adsNametxt").focusout(function(evt){
//console.log(evt.target.value+"===="+$("#adsNametxt").val());
if($.trim($("#adsNametxt").val()).length>0&&!/[/\\:?*"<>|.]+/.test($.trim($("#adsNametxt").val()))){
$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkAdsNameAction.do",
data : {adsNametxt:$("#adsNametxt").val()},
dataType : "json",
success : function(data) {
if(true==data){
//remove error class
}else{
validator.showErrors({"adsNametxt":"This Ads is already in use"});
}
}
});
}
});
//add by liuyan 2011-09-27 end
var validator=$("form").validate({
submitHandler: function(form) {
//validate ads name and end date;
//ignoreEndDateValidate=ture,ignore end date validate;ignoreAdsNameValidate=ture,ignore ads name validate
if(ignoreEndDateValidate&&ignoreAdsNameValidate){
form.submit();
}else if(ignoreEndDateValidate){
$.when(
$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkAdsNameAction.do",
data : {adsNametxt:$("#adsNametxt").val()},
dataType : "json"
})
).done(function(adsName){
if(adsName){
form.submit();
}else{
validator.showErrors({"adsNametxt":"This Ads is already in use"});
enabledButtons();
}
});
}else{
$.when(
$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkAdsNameAction.do",
data : {adsNametxt:$("#adsNametxt").val()},
dataType : "json"
})
,$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkDateAction.do",
data : {endDatetxt:$("#endDatetxt").val()},
dataType : "json"
})
).done(function(adsName,endDate){
if(adsName[0]&&endDate[0]){
form.submit();
}else{
if(!adsName[0]){
validator.showErrors({"adsNametxt":"This Ads is already in use"});
}
if(!endDate[0]){
validator.showErrors({"endDatetxt":"End date must be greater than current date"});
}
if(!adsName[0]){
$("#adsNametxt").addClass(validator.settings.errorClass);
}
enabledButtons();
}
});
}
},
success:function(element){//validate5 start
var submitflag = true;
if($("#titleTxt1").val()==""||$("#titleTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if($("#messageTxt1").val()==""||$("#messageTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if($("#actionTxt1").val()==""||$("#actionTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if(submitflag){
$(".Button_langblue").removeAttr("style").addClass("Button_langblue");
}
},//validate5 end
errorPlacement:function(error, element) {
if(/^displayInternal\w*/i.test(element.attr("name"))){
$("#displayInternalMins").parent().next().next().children("label").remove();
error.appendTo( $("#displayInternalMins").parent().next().next() );
/*if($("input[name='displayInternalMins']").parent().next().next().children("label").length<=0){
error.appendTo( $("input[name='displayInternalMins']").parent().next().next() );
}*/
}else if(element.attr("name")=="targetLineUpCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetModelsCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetCountryCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetLanguageCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="titleTxt1"){
if($("#targetModelsCheckBox").val()!=null&&$("#targetLanguageCheckBox").val()!=null){
$("#targetLanguageCheckBox").parent().next().next().empty();
}
element.parent().next().next().empty();
error.appendTo( element.parent().next().next() );
}else{
element.parent().next().next().empty();
error.appendTo( element.parent().next().next() );
}
}
});
}else{
var validator=$("form").validate({
submitHandler: function(form) {
//validate ads name and end date;
//ignoreEndDateValidate=ture,ignore end date validate;ignoreAdsNameValidate=ture,ignore ads name validate
if(ignoreEndDateValidate){
form.submit();
}else{
$.when(
$.ajax({
type : "post",
url : $("#urlrequest").val()+"/checkDateAction.do",
data : {endDatetxt:$("#endDatetxt").val()},
dataType : "json"
})
).done(function(endDate){
if(endDate){
form.submit();
}else{
validator.showErrors({"endDatetxt":"End date must be greater than current date"});
enabledButtons();
}
});
}
},
success:function(element){//validate5
var submitflag = true;
if($("#titleTxt1").val()==""||$("#titleTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if($("#messageTxt1").val()==""||$("#messageTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if($("#actionTxt1").val()==""||$("#actionTxt1").val()==null){
submitflag = false;
}else{
element.parent().next().next().empty();
}
if(submitflag){
$(".Button_langblue").removeAttr("style").addClass("Button_langblue");
}
},//validate5
errorPlacement:function(error, element) {
if(/^displayInternal\w*/i.test(element.attr("name"))){
$("#displayInternalMins").parent().next().next().children("label").remove();
error.appendTo( $("input[name='displayInternalMins']").parent().next().next() );
}else if(element.attr("name")=="targetLineUpCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetModelsCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetCountryCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="targetLanguageCheckBox"){
$("#targetLanguageCheckBox").parent().next().next().empty();
error.appendTo($("#targetLanguageCheckBox").parent().next().next());
}else if(element.attr("name")=="titleTxt1"){
if($("#targetModelsCheckBox").val()!=null&&$("#targetLanguageCheckBox").val()!=null){
$("#targetLanguageCheckBox").parent().next().next().empty();
}
element.parent().next().next().empty();
error.appendTo( element.parent().next().next() );
}else{
element.parent().next().next().empty();
error.appendTo( element.parent().next().next() );
}
}
});
}
//add date event
var dates = $( "#beginDateTxt, #endDatetxt" ).datepicker({
//defaultDate: "+1w",
showOn: "button",
buttonImage: $("#urlrequest").val()+"/images/calender.png",
buttonImageOnly: true,
buttonText:"",
dateFormat:'dd/mm/yy',
changeMonth: true,
changeYear: true,
onSelect: function( selectedDate ) {
var option = this.id == "beginDateTxt" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
},
onClose: function(dateText, inst) {
$( this ).trigger("focusout");
//do flag
menuDoFlg = true;
}
});
// add datepicker constraints liuyan 2011-08-18 start
var instance,date;
<logic:notEmpty name="editActionForm" property="beginDateTxt">
instance = $( "#beginDateTxt" ).data( "datepicker" ),
date = $.datepicker.parseDate(instance.settings.dateFormat ||$.datepicker._defaults.dateFormat,"${editActionForm.beginDateTxt}", instance.settings );
$( "#endDatetxt" ).datepicker( "option", "minDate", date );
</logic:notEmpty>
<logic:notEmpty name="editActionForm" property="endDatetxt">
instance = $( "#endDatetxt" ).data( "datepicker" ),
date = $.datepicker.parseDate(instance.settings.dateFormat ||$.datepicker._defaults.dateFormat,"${editActionForm.endDatetxt}", instance.settings );
$( "#beginDateTxt" ).datepicker( "option", "maxDate", date );
</logic:notEmpty>
// add datepicker constraints liuyan 2011-08-18 end
// add click event
//preview botton
$("#previewBotton").click(function(){
disabledButtons();
//add ignore
ignoreEndDateValidate=true;
ignoreAdsNameValidate=false;
validator.settings.ignore="#beginDateTxt,#endDatetxt,#displayInternalWeeks,#displayInternalDays,"+
"#displayInternalHours,#displayInternalMins,#targetLineUpCheckBox,#targetModelsCheckBox,#targetCountryCheckBox,"+
"#targetLanguageCheckBox,#titleTxt1,#messageTxt1,#actionTxt1";
validator.hideErrors();
validator.elements().removeClass( validator.settings.errorClass );
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
$("#adverStatus").val("9");
$("#submitForm").attr("action",$("#urlrequest").val()+"/savedShowPreviewAction.do?pageInfo="+$("#pageInfo").val());
/*
if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
validator.previousValue(document.getElementById("adsNametxt")).old=null;
}
$("#submitForm").submit();
*/
if(validator.form()){
$("#submitForm").submit();
}else{
if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
$("#adsNametxt").trigger("focusout");
}
enabledButtons();
}
});
//save botton
$("#saveBotton").click(function(){
disabledButtons();
//add ignore
ignoreEndDateValidate=true;
ignoreAdsNameValidate=false;
//$("#endDatetxt").removeClass("error");
validator.settings.ignore="#beginDateTxt,#endDatetxt,#displayInternalWeeks,#displayInternalDays,"+
"#displayInternalHours,#displayInternalMins,#targetLineUpCheckBox,#targetModelsCheckBox,#targetCountryCheckBox,"+
"#targetLanguageCheckBox,#titleTxt1,#messageTxt1,#actionTxt1";
if(!($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse")){
validator.settings.ignore="#adsNametxt,"+validator.settings.ignore;
}
validator.hideErrors();
validator.elements().removeClass( validator.settings.errorClass );
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
$("#adverStatus").val("1");
$("#submitForm").attr("action",$("#urlrequest").val()+"/editAction.do");
/*if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
validator.previousValue(document.getElementById("adsNametxt")).old=null;
}
$("#submitForm").submit();
*/
if(validator.form()){
$("#submitForm").submit();
}else{
if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
$("#adsNametxt").trigger("focusout");
}
enabledButtons();
}
});
//submit botton
$("#submitBotton").click(function(){
disabledButtons();
ignoreEndDateValidate=false;
ignoreAdsNameValidate=false;
$("#publishertxt").val($("#companyID").find("option:selected").text());
validator.settings.ignore=[];
$("#"+$(".Button_langblue").val()+"_title").val($("#titleTxt1").val());
$("#"+$(".Button_langblue").val()+"_message").val($("#messageTxt1").val());
$("#"+$(".Button_langblue").val()+"_pictureshow").val($("#uploadpictureShow").val());
$("#"+$(".Button_langblue").val()+"_action").val($("#actionTxt1").val());
$("#"+$(".Button_langblue").val()+"_targetOperations").val($("#targetOperationCheckBox").val());
$("#"+$(".Button_langblue").val()+"_targetParameters").val($("#targetParameters").val());
$("#"+$(".Button_langblue").val()+"_targetDirectory").val($("#targetDirectory").val());
$("#"+$(".Button_langblue").val()+"_targetDisplay").val($("#targetDisplayCheckBox").val());
$("#"+$(".Button_langblue").val()+"_regKeyDisplay").val($("#regKeyDisplay").val());
$("#"+$(".Button_langblue").val()+"_regKeyDoNotDisplay").val($("#regKeyDoNotDisplay").val());
$.each($("#languageStr").val().split(","),function(i,item){
var submitflag = true;
if($("#"+item+"_title").val()==""||$("#"+item+"_title").val()==null){
$("#"+item).css({"background-color": "#FF0000"});
submitflag = false;
}
if($("#"+item+"_message").val()==""||$("#"+item+"_message").val()==null){
$("#"+item).css({"background-color": "#FF0000"});
submitflag = false;
}
if($("#"+item+"_action").val()==""||$("#"+item+"_action").val()==null){
$("#"+item).css({"background-color": "#FF0000"});
submitflag = false;
}
if(submitflag){
if($("#"+item).attr('class')=="Button_langblue"){
$("#"+item).removeAttr("style").addClass("Button_langblue");
}else{
$("#"+item).removeAttr("style").addClass("Button_langwhite");
}
}else{
$("#"+item).click();
}
});
$("#targetLineUpCheckBox").addClass("required");
$("#targetModelsCheckBox").addClass("required");
$("#targetCountryCheckBox").addClass("required");
$("#targetLanguageCheckBox").addClass("required");
$("#adverStatus").val("2");
$("#submitForm").attr("action",$("#urlrequest").val()+"/editAction.do");
/*if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
validator.previousValue(document.getElementById("adsNametxt")).old=null;
}
$("#submitForm").submit();
*/
if(validator.form()){
$("#submitForm").submit();
}else{
if($("#neworeditFlag").val()=="new"||$("#neworeditFlag").val()=="reuse"){
$("#adsNametxt").trigger("focusout");
if($.trim($("#endDatetxt").val())){
$("#endDatetxt").trigger("focusout");
}
}else{
$("#endDatetxt").trigger("focusout");
}
enabledButtons();
}
});
//cancel botton
$("#cancelBotton").click(function(){
//add ignore
ignoreEndDateValidate=true;
ignoreAdsNameValidate=true;
validator.settings.ignore="#adsNametxt,#beginDateTxt,#endDatetxt,#displayTxt,#displayInternalWeeks,#displayInternalDays,"+
"#displayInternalHours,#displayInternalMins,#targetLineUpCheckBox,#targetModelsCheckBox,#targetCountryCheckBox,"+
"#targetLanguageCheckBox,#titleTxt1,#messageTxt1,#actionTxt1";
//validator.hideErrors();
//validator.elements().removeClass( validator.settings.errorClass );
if(confirm("You are about to exit this page with unsaved data.\nClick OK to proceed or Cancel to first save your data.")){
$("#submitForm").attr("action",$("#urlrequest").val()+"/initAdvertisementsAction.do?pageInfo="+$("#pageInfo").val()+"&menuchildFlg="+$("#menuchildFlg").val());
$("#submitForm").submit();
}
});
// add by liuyan for send email to request new ads 2011-08-31 start
$("#requestNewBotton").click(function(e){
$.ajax({
type : "post",
url : "<%=request.getContextPath()%>/adminEmailAction.do",
dataType : "json",
timeout:10000,
success : function(data) {
if(data.message=="success"){
// window.location.href='mailto:'+data.adminEmail+'?subject=[OnlineAds]%20Please%20reset%20my%20account&body=I%20fogot%20the%20password!'
var subject="[AvisOnlineAds] Request for new Publisher account";
var body="Hi,%0D%0DCould you please create a new Publisher account: %0D%0DPublisher Name: [Enter Publisher name here]%0D"+
"Icon: [Enclose with this email the .ICO or PNG file]%0D%0DThank you,";
<html:hidden name="editActionForm" property="adverID" />
<html:hidden name="editActionForm" property="baseAdverID" />
<input type="hidden" value="<bean:write name='editActionForm' property='neworeditFlag'/>" name="neworeditFlag" id="neworeditFlag" />
<html:hidden name = "editActionForm" property="adverIDCopy"/>
<input type="hidden" name="accessState" id="accessState" />
<input type="hidden" value="<bean:write name='editActionForm' property='lockMsg'/>" name="lockMsg" />
<html:hidden name = "editActionForm" property="toDo" />
<!-- default -->
<input name="defaultPictureU" id = "defaultPictureU" type="hidden" />
<input name="defaultPictureS" id = "defaultPictureS" type="hidden" />
<input name="defaultAction" id = "defaultAction" type="hidden" />
<input name="defaultFlag" id = "defaultFlag" type="hidden" value="0" />
</html:form>
</div>
</body>
</html:html>