How to use testDisplayUrl method in Cypress

Best JavaScript code snippet using cypress

testIdea.js

Source:testIdea.js Github

copy

Full Screen

1(function(){2	window.testIdea=function(){3		var c_foot=$G('div:c_foot')4		,	listTestIdeasEach=$G('#listTestIdeasEach')5		,	findDom=$G('#contb4')6		,	add_preview=$G('#add_preview')7		,	testIdeaListData={}8		,	state={9				'1':['有效','green']10			,	'2':['不宜推广','orange']11			,	'3':['暂停','orange']12			,	'4':['审核中','orange']13			,	'5':['审核拒绝','red']14			,	'6':['已删除','red']15			}16		,	model=function(d,isTrue){17				var m={18						path:'SET_CREATIVE'19					,	CREATIVE_ID:''								//创意ID20					,	CAMPAIGN_ID:''21					,	CAMPAIGN_NAME:''							//计划名称22					,	GROUP_ID:''23					,	GROUP_NAME:''								//组名称24					,	CREATIVE_STATUS:''							//1有效 2暂停25					,	CREATIVE_NAME:''							//创意NAME26					,	CREATIVE_DESCRIPTION:''						//描述27					,	CREATIVE_DESTINATION_URL:''					//访问URL28					,	CREATIVE_DISPLAY_URL:''						//显示URL29					,	CREATIVE_APPEND_ID:''						//附加创意ID30					,	MOBILE_DESTINATION_URL:''					//移动访问URL31					,	MOBILE_DISPLAY_URL:''						//移动显示URL32					,	ACCOUNT_ID:window.wm.data['user']['ACCOUNT_ID']  33					}34				,	updateCode='CREATIVE_STATUS,CREATIVE_NAME,CREATIVE_DESCRIPTION,CREATIVE_DESTINATION_URL,CREATIVE_DISPLAY_URL,CREATIVE_APPEND_ID,MOBILE_DESTINATION_URL,MOBILE_DISPLAY_URL'.split(',')35				;36				37				if($G.isNaN(d['CREATIVE_ID'])){38					m['path']='ADD_CREATIVE';39					delete m['CREATIVE_STATUS'];40					delete m['CREATIVE_ID'];41					delete d['CREATIVE_ID'];42					delete m['UPDATE_TYPE'];43				}else if(isTrue){44					var json=testIdeaListData[d['CREATIVE_ID']]45					;46					if(json){47						$G.Each(function(){48							var key=this+'';49							if(key!='CAMPAIGN_ID' && key!='GROUP_ID' && d[key]==json[key]){50								delete d[key];51							}52						},updateCode);53						m['path']='SET_CREATIVE';54						var stepVal=155						,	updateType=''56						;57						$G.Each(function(){58							if(!$G.isNaN(d[this+''])){59								updateType=Number(updateType||0)+Number(stepVal);60							}61							stepVal=stepVal*2;62						},updateCode);63						m.UPDATE_TYPE=updateType;64					}65				}66				67				$G.Each(function(i,k){68					m[k]=this+'';69				},d);70				return m;71			}72			/************************控制咨询、挂号***********************************/73			,	guaHaoIni=function(hgJson,isNone){74					if(!hgJson)hgJson={};75					var headerJson=window.wm.data['user']76					,	webimObj=$G('.webim',this)77					,	guahaoTokenObj=$G('.guahaoToken',this)78					,	ghVal=function(sv){79							var sval=0;80							if($G.isNaN(sv)){81							}else if(sv<2.5){82								sval=20;83							}else if(sv>=2.5 && sv<3.5){84								sval=30;85							}else if(sv>=3.5 && sv<4.5){86								sval=40;87							}else if(sv>=4.5 && sv<5.5){88								sval=50;89							}else if(sv>=5.5 && sv<6.5){90								sval=60;91							}else if(sv>=6.5 && sv<7.5){92								sval=70;93							}else if(sv>=7.5 && sv<8.5){94								sval=80;95							}else if(sv>=8.5 && sv<9.5){96								sval=90;97							}else if(sv>=9.5){98								sval=100;99							}100							return sval;101						}(hgJson.starScore||'')102					;103					104					webimObj.Each(function(){105						if($G.isNaN(headerJson.WEBIM)){106							if(isNone)107								this.style.display='none';108						}else{109							this.style.display='';110						}111					});112					guahaoTokenObj.Each(function(){113						if($G.isNaN(headerJson.guahaoToken)){114							if(isNone)115								this.style.display='none';116						}else{117							this.style.display='';118							var Gobj=$G(this)119							,	keygh=Gobj.getAtt('keygh')120							;121							if($G.hasProp(this,'keygh') && !$G.isNaN(keygh)){122								this.innerHTML=hgJson[keygh];123							}124							this.innerHTML=(this.innerHTML+'').replace(/{starScore}/ig,ghVal);125						}126						127					});128			}129		,	selectAppend={}130		,	appendIdeaListData={}131		,	cyDisplay=function(){}132		,	setAppend=function(selectAppendId,checkedAppend,json,fn){133				var	n=json.length134				,	appendIdeaOKListData={}135				//,	appendIdeaListData={}136				;137				selectAppendId.delallsel();138				selectAppendId.addsel('','');139				for(var i=0;i<n;i++){140					var	v=json[i]141					;142					appendIdeaListData[v.APPEND_ID]=v;143					var vs=window.appendIdea.getState[v.APPEND_STATUS];144					if(vs[0]=='有效'){145						appendIdeaOKListData[v.APPEND_ID]=v;146						selectAppendId.addsel(window.appendIdea.getContent(v.APPEND_CONTENT,"{title}",' '),v.APPEND_ID);147					}148				}149				selectAppend={150					ini:function(data){151						selectAppendId.delallsel();152						selectAppendId.addsel('','');153						$G.Each(function(){154							var v=this;155							selectAppendId.addsel(window.appendIdea.getContent(v.APPEND_CONTENT,"{title}",' '),v.APPEND_ID);156						},data);157						window.selDom.resall();158					}159				,	add:function(){160						this.ini(appendIdeaOKListData);161					}162				,	all:function(){163						this.ini(appendIdeaListData);164					}165				,	set:function(id){166						if(!$G.isNaN(id)&&!appendIdeaOKListData[id]){167							this.ini(appendIdeaListData);168							checkedAppend[0].checked=false;169						}else checkedAppend[0].checked=true;170						selectAppendId.setselvalue(id);171						window.selDom.resall();172					}173				};174				window.selDom.resall();175				fn&&fn(appendIdeaOKListData,appendIdeaListData);176			}177			//创建/修改 计划178		,	ideaAction=function(){179				var idea=$G('#step3_test')180				,	checkedAppend=$G('#CREATIVE_APPEND_TYPE')181				,	selectAppendId=$G('.CREATIVE_APPEND_ID',idea[0]).delallsel()182				,	addNewMobile_list=$G('#addNewMobile_list')183				,	addNewMobile=$G('#addNewMobile')184				,	mobileInput=$G('.MOBILE_DESTINATION_URL .MOBILE_DISPLAY_URL',idea[0])185				,	reset=function(){186						$G('.CREATIVE_NAME .CREATIVE_DESCRIPTION .CREATIVE_DESTINATION_URL .CREATIVE_DISPLAY_URL').Each(function(){187							this.value='';188						});189						var json={};190						json['testTitle']='这里显示您的推广标题';191						json['testDescription1']='这里显示您的创意描述';192						json['testDisplayUrl']='wangmeng.haomeit.com';193						json['appendList']='<i style="font-style:normal;color:#261CDC; text-decoration:underline;">子链预览1</i> | <i style="font-style:normal;color:#261CDC; text-decoration:underline;">子链预览2</i> | <i style="font-style:normal;color:#261CDC; text-decoration:underline;">子链预览3</i> | <i style="font-style:normal;color:#261CDC; text-decoration:underline;">子链预览4</i> | <i style="font-style:normal;color:#261CDC; text-decoration:underline;">子链预览5</i>';194						$G('.testTitle .testDescription1 .testDisplayUrl .appendList',idea[0]).Each(function(){195							var name=$G(this).getAtt('name')196							;197							this.innerHTML=json[name]||'';198						});199						addNewMobile_list.none();200						addNewMobile.setAtt('class','tianjia');201						mobileInput.Each(function(){202							this.value='';203						});204					}205				,	demo=function(){206						/*******************destinationUrl输入长度时时限制**************************/207						var titleValue=''208						,	titleHtml=$G('.testTitle',idea[0])209						;210						$G('.CREATIVE_NAME',idea[0]).bd({on:'keyup',callback:function(){211							var valueLen=$G.len(this.value);212							if(valueLen>49){213								this.value=titleValue;214							}else{215								titleHtml[0].innerHTML=titleHtml[1].innerHTML=titleValue=this.value;216							}217						}});218						/*******************displayUrl输入长度时时限制**************************/219						var description1Value=''220						,	description1Html=$G('.testDescription1',idea[0])221						;222						$G('.CREATIVE_DESCRIPTION',idea[0]).bd({on:'keyup',callback:function(){223							var valueLen=$G.len(this.value);224							if(valueLen>159){225								this.value=description1Value;226							}else{227								description1Html[0].innerHTML=description1Html[1].innerHTML=description1Value=this.value;228							}229						}});230						/*******************destinationUrl输入长度时时限制**************************/231						var destinationUrlValue='';232						$G('.CREATIVE_DESTINATION_URL',idea[0]).bd({on:'keyup',callback:function(){233							var valueLen=$G.len(this.value);234							if(valueLen>1016){235								this.value=destinationUrlValue;236							}else{237								destinationUrlValue=this.value;238							}239						}});240						/*******************displayUrl输入长度时时限制**************************/241						var displayUrlValue=''242						,	displayUrlHtml=$G('.testDisplayUrl',idea[0])243						,	appendListHtml=$G('.appendList',idea[0])244						;245						$G('.CREATIVE_DISPLAY_URL',idea[0]).bd({on:'keyup',callback:function(){246							var valueLen=$G.len(this.value);247							if(valueLen>34){248								this.value=displayUrlValue;249							}else{250								if($G.isNaN(selectAppendId.getselvalue()['CREATIVE_APPEND_ID'])){251									appendListHtml[0].innerHTML='<a style="color:#006600;" target="_blank">'+this.value+'</a>';252								}253								appendDispUrl=displayUrlHtml[0].innerHTML=displayUrlValue=this.value;254							}255						}});256						257						/************文字创意浏览**************/258						var testIdeasDemoPreview=function(){259							var testIdeasDemoPreviewfn=window.alertDiv({260									findObj:'#add_preview'261								,	position:'absolute'262								,	move:$G('div:check_title',add_preview[0])263								})264							,	obj=add_preview265							;266							return {267								obj:obj268							,	show:function(fnB,fnE,fnC){269									testIdeasDemoPreviewfn.show(fnB,fnE,fnC);270								}271							,	none:testIdeasDemoPreviewfn.none272							}273						}();274						275						return testIdeasDemoPreview;276					}()277					//提交验证278				,	subFunction=function(){}279				,	appendId=''280				,	appendDispUrl=''281				,	subIdea=window.subAjax('#step3_test',{282							ckdata:function(data){283								$G('.ckMsg',idea[0]).none();284								var title=$G('.CREATIVE_NAME',idea[0])285								,	description1=$G('.CREATIVE_DESCRIPTION',idea[0])286								,	destinationUrl=$G('.CREATIVE_DESTINATION_URL',idea[0])287								,	displayUrl=$G('.CREATIVE_DISPLAY_URL',idea[0])288								,	titleLen=$G.len(title[0].value)289								,	description1Len=$G.len(description1[0].value)290								,	destinationUrlLen=$G.len(destinationUrl[0].value)291								,	displayUrlLen=$G.len(displayUrl[0].value)292								,	destinationUrlMsgHand_1=$G('#destinationUrlMsgHand_1')293								,	displayUrlMsgHand_1=$G('#displayUrlMsgHand_1')294								,	destinationUrlMsgHand_2=$G('#destinationUrlMsgHand_2')295								,	displayUrlMsgHand_2=$G('#displayUrlMsgHand_2')296								,	mobileDestinationUrl=$G('.MOBILE_DESTINATION_URL',idea[0])297								,	mobileDisplayUrl=$G('.MOBILE_DISPLAY_URL',idea[0])298								,	mobileDestinationUrlLen=$G.len(mobileDestinationUrl[0].value)299								,	mobileDisplayUrlLen=$G.len(mobileDisplayUrl[0].value)300								,	mobileDestinationUrlMsgHand_1=$G('#mobileDestinationUrlMsgHand_1')301								,	mobileDisplayUrlMsgHand_1=$G('#mobileDisplayUrlMsgHand_1')302								,	mobileDestinationUrlMsgHand_2=$G('#mobileDestinationUrlMsgHand_2')303								,	mobileDisplayUrlMsgHand_2=$G('#mobileDisplayUrlMsgHand_2')304								,	companyDoman=window.wm.data['user']['DOMAIN']305								,	domanUrlArray=companyDoman.split(",")306								,	ckDoman=function(value){307										var isRetUrn=false308										,	domanUrlData=$G.findDoman(value)309										;310										for(var m=0,n=domanUrlArray.length;m<n;m++){311											var companySite=$G.findDoman(domanUrlArray[m])312											,	companyUrl=companySite.url313											,	companyType=companySite.type314											;315											if(domanUrlData.url==companyUrl && domanUrlData.type==companyType){316												isRetUrn=true;317												break;318											}319										}320										return isRetUrn;321									}322								,	ckUrl=function(){323										var domanDestinationUrl=ckDoman(destinationUrl[0].value);324										if(!domanDestinationUrl){325											destinationUrlMsgHand_2[0].innerHTML=destinationUrlMsgHand_2[0].innerHTML.replace(/(www)/,companyDoman);326											destinationUrlMsgHand_2[0].style.display='';327											return false;328										}else if(!window.wm.ckType.domanDestinationUrl(destinationUrl[0].value)){329											destinationUrlMsgHand_1[0].style.display='';330											return false;331										}332										var domanDisplayUrl=ckDoman(displayUrl[0].value);333										if(!domanDisplayUrl){334											displayUrlMsgHand_2[0].innerHTML=displayUrlMsgHand_2[0].innerHTML.replace(/(www)/,companyDoman);335											displayUrlMsgHand_2[0].style.display='';336											return false;337										}else if(!window.wm.ckType.displayUrl(displayUrl[0].value)){338											displayUrlMsgHand_1[0].style.display='';339											return false;340										}341										//移动验证342										if(mobileDestinationUrl[0].value){343											var domanMobileDestinationUrl=ckDoman(mobileDestinationUrl[0].value);344											if(!domanMobileDestinationUrl){345												mobileDestinationUrlMsgHand_2[0].innerHTML=mobileDestinationUrlMsgHand_2[0].innerHTML.replace(/(www)/,companyDoman);346												mobileDestinationUrlMsgHand_2[0].style.display='';347												return false;348											}else if(!window.wm.ckType.domanDestinationUrl(destinationUrl[0].value)){349												mobileDestinationUrlMsgHand_1[0].style.display='';350												return false;351											}352										}353										if(mobileDisplayUrl[0].value){354											var domanMobileDisplayUrl=ckDoman(mobileDisplayUrl[0].value);355											if(!domanMobileDisplayUrl){356												mobileDisplayUrlMsgHand_2[0].innerHTML=mobileDisplayUrlMsgHand_2[0].innerHTML.replace(/(www)/,companyDoman);357												mobileDisplayUrlMsgHand_2[0].style.display='';358												return false;359											}else if(!window.wm.ckType.displayUrl(displayUrl[0].value)){360												mobileDisplayUrlMsgHand_1[0].style.display='';361												return false;362											}363										}364										return true;365									}366								;367								if(titleLen>50 || titleLen<8){368									$G('#titleMsgHand')[0].style.display='';369									return false;370								}371								if(description1Len>160 || description1Len<10){372									$G('#description1MsgHand')[0].style.display='';373									return false;374								}375								if(destinationUrlLen>1017){376									alert('访问URL超长');377									return false;378								}379								if(displayUrlLen>35){380									alert('显示URL超长');381									return false;382								}383								if(!$G.isNaN(mobileDestinationUrl[0].value) && !$G.isNaN(mobileDisplayUrl[0].value)){384									if(mobileDestinationUrlLen>1017){385										alert('移动访问URL超长');386										return false;387									}388									if(mobileDisplayUrlLen>35){389										alert('移动显示URL超长');390										return false;391									}392								}393								if(!$G.isNaN(mobileDestinationUrl[0].value) && $G.isNaN(mobileDisplayUrl[0].value)){394									alert('移动显示URL不能为空');395									return false;396								}else if($G.isNaN(mobileDestinationUrl[0].value) && !$G.isNaN(mobileDisplayUrl[0].value)){397									alert('移动访问URL不能为空');398									return false;399								}400								/*if(!ckUrl()){401									return false;402								}*/403								var mod=model(data,true);404								mod['CREATIVE_DESTINATION_URL']='http://'+(mod['CREATIVE_DESTINATION_URL'].replace(/(http:\/\/)/ig,""));405								if($G.isNaN(mod['CREATIVE_APPEND_ID'])) {mod['CREATIVE_APPEND_TYPE']=1; mod["UPDATE_TYPE"] = parseInt(mod["UPDATE_TYPE"] == "" ? 0 : mod["UPDATE_TYPE"]) + 32;}406								else {mod['CREATIVE_APPEND_TYPE']=2; }407								if(!$G.isNaN(mobileDestinationUrl[0].value))408									mod['MOBILE_DESTINATION_URL']='http://'+(mod['MOBILE_DESTINATION_URL'].replace(/(http:\/\/)/ig,""));409								return mod;410							}411						,	sub:'.subIdeaSave .subIdeaSaveGoTo'412						,	callback:function(JSON){413								if(window.wm.msg(JSON.CODE,false)){414									reset();415									subFunction(JSON,this.postdata);416									if(this.subObj.name=='subIdeaSave'){417										ideaAlt.close();418									}419									list.sub();420								}421							}422					})423					//创建/修改 计划 层424				,	ideaAlt=window.alertDiv({425						findObj:'#step3_test'426					,	closeObj:'.close'427					,	position:'absolute'428					,	move:$G('div:scommon_title',idea[0])429					})430				,	appendList=$G('.appendList',idea[0])431				,	domShow=function(type,JSON){432						var test={433								'edit':{434									'altIdeaTitle':'修改创意'435								}436							,	'add':{437									'altIdeaTitle':'新建创意'438								}439							}440						,	html=test[type]441						,	none=type=='add'?'':'none'442						;443						$G('.altIdeaTitle .altIdeaDaoHang',idea[0]).Each(function(){444							var gObj=$G(this)445							,	name=gObj.getAtt('name')446							;447							gObj.html(html[name]);448							if(name=='altIdeaDaoHang')449								gObj[0].style.display=none;450						});451						$G('.CREATIVE_ID .CAMPAIGN_ID .GROUP_ID .CREATIVE_NAME .CREATIVE_DESCRIPTION .CREATIVE_DESTINATION_URL .CREATIVE_DISPLAY_URL .MOBILE_DESTINATION_URL .MOBILE_DISPLAY_URL .IMG_PATH',idea[0]).Each(function(){452							var gObj=$G(this)453							,	name=gObj.getAtt('name')454							;455							this.value=JSON[name]||'';456						});457						$G('.TYPE',plan[0]).Each(function(){458							this.disabled=false;459						});460						$G('.TYPE',idea[0]).Each(function(){461							var obj=this;462							if(this.value==JSON.TYPE)this.checked=true;463						});464						if(type=='add')return;465						$G('.testTitle .testDescription1 .testDisplayUrl',idea[0]).Each(function(){466							var name=$G(this).getAtt('name')467							,	key='CREATIVE_NAME'468							,	jsonK=function(){469									if(name=='testDescription1')key='CREATIVE_DESCRIPTION';470									if(name=='testDisplayUrl')key='CREATIVE_DISPLAY_URL';471								}()472							;473							if(JSON[key])474								this.innerHTML=JSON[key];475						});476						appendDispUrl='<i class="zi_link_address"><a target="_blank">'+JSON.CREATIVE_DISPLAY_URL+'</a></i>';477						appendId=JSON.CREATIVE_APPEND_ID?function(){478							window.appendIdea.getIdeasById(JSON.CREATIVE_APPEND_ID,function(appendJson){479								appendList.html(window.appendIdea.getContent(appendJson.APPEND_CONTENT,'<i style=" font-style:normal;color:#261CDC; text-decoration:underline;" >{title}</i>'));480							});481							return JSON.CREATIVE_APPEND_ID;482						}():function(){483							appendList.html(appendDispUrl);484							return '';485						}();486						if(JSON.MOBILE_DISPLAY_URL || (JSON.MOBILE_DESTINATION_URL+'').replace(/(http:\/\/)/g,"")){487							addNewMobile_list.show();488							addNewMobile.setAtt('class','tianjia_j');489						}else{490							addNewMobile_list.none();491							addNewMobile.setAtt('class','tianjia');492							mobileInput.Each(function(){493								this.value='';494							});495						}496					}	497				;498				cyDisplay=function(value){499					if($G.isNaN(value)){500						if(appendDispUrl)appendList.html(appendDispUrl);501						return;502					}503					var appendJson=appendIdeaListData[value]504					,	setValue=appendJson?window.appendIdea.getContent(appendJson.APPEND_CONTENT,'<i style="font-style:normal;color:#261CDC; text-decoration:underline;">{title}</i>'):''505					;506					appendList.html(setValue);507				}508				checkedAppend.click(function(){509					if(this.checked){510						selectAppend.add();511					}else{512						selectAppend.all();513					}514				});515				$G('#addNewAppend').click(function(){516					window.appendIdea.add(function(appendAlert){517						window.appendIdea.getList.sub(function(JSON){518							if(window.wm.msg(JSON.CODE,false)){519								setAppend(selectAppendId,checkedAppend,JSON.LIST);520							}521							selectAppend.set(appendId);522							appendAlert.close();523						});524					});525				});526				return {527					show:function(json,fn,editfn){528						var startFn=function(){529							var closeMsg='您确定要中止修改创意操作吗?'530							,	subIdeaSaveGoTo=$G('.subIdeaSaveGoTo',idea[0])531							;532							json=json||{};533							json=model(json);534							if(json && $G.isNaN(json.CREATIVE_ID)){535								closeMsg='您确定要中止新建创意操作吗?';536								domShow('add',json);537								$G('.newMap',idea[0]).none();538								checkedAppend[0].checked=true;539								appendId='';540								subIdeaSaveGoTo.show();541								reset();542							}else{543								domShow('edit',json);544								subIdeaSaveGoTo.none();545							}546							if(fn)subFunction=fn;547							editfn&&editfn(idea[0]);548							ideaAlt.show(549							''550							,	function(){551									window.gconfirm({552										msg:closeMsg553									,	fn:function(isTrue){554											if(isTrue){555												ideaAlt.close();556											}557										}558									});559								}560							,	''561							,	true562							);563						}()564						;565						window.appendIdea.getList.sub(function(JSON){566							var str=''567							,	postdata=this.postdata568							;569							JSON.INFO=JSON.INFO||{570												PAGE_INDEX:1571											,	CAMPAIGN_COUNT:0572											};573							JSON.LIST=JSON.LIST||{};574							if(window.wm.msg(JSON.CODE,false)){575								setAppend(selectAppendId,checkedAppend,JSON.LIST);576							}577							selectAppend.set(appendId);578							cyDisplay(selectAppendId.getselvalue()['CREATIVE_APPEND_ID']);579						});580						581					}582				,	close:ideaAlt.close583				,	reset:reset584				,	demo:demo585				};586				587			}()588		,	add=function(uid,fn,endfn){589				ideaAction.show({GROUP_ID:uid},fn,endfn);590			}591		,	edit=function(json,fn){592				json=json||{};593				if($G.isNaN(json.CREATIVE_ID))return;594				ideaAction.show(json,fn);595			}596			//启用/暂停 计划597		,	pause=function(id,t,v,fn){598				var m={599					'ID_TYPE':3600				,	'ID':id601				,	'BATCH_TYPE':t602				,	'STATUS':v603				};604				window.pause(m,function(){605					list.sub();606					fn&&fn();607				});608			}609			/*********************计暂停/启用 效果***********************************/610		,	ideaPause=function(JSON){611				var obj=this612				,	css=$G(obj).getAtt('class')613				,	isPause=function(){614						return css=='start_img';615					}()616				,	msg=isPause?'您确定暂停创意{ideasName}吗!':'您确定启动创意{ideasName}吗!'617				;618				619				window.gconfirm({620					msg:msg.replace(/{ideasName}/,'【'+JSON.CREATIVE_NAME+'】')621				,	fn:function(isTrue){622						if(isTrue){623							pause(JSON.CREATIVE_ID,1,(isPause?2:1));624						}625					}626				});627			}628			//删除计划629		,	remove=function(ids){630				pause(ids,2,'');631			}632		;633		634		/***********************获取创意列表************************************/635		var page=window.page()636		,	pageIni=page.getPage()637		,	pageArray=page.getPage()638		,	listTestIdeasHtmlTitle=$G('#listTestIdeasHtmlTitle')639		,	listTestIdeasHtmlList=$G('#listTestIdeasHtmlList')640		,	listTestIdeasHtmlEnd=$G('#listTestIdeasHtmlEnd')641		,	list=window.subAjax('#contb4',{642					path:'GET_CREATIVE'643				,	sub:'.subIdeasList .subListGl'644				,	findDom:findDom[0]645				,	obj:listTestIdeasEach[0]646				,	ckdata:function(data){647						var d=window.wm.setDataList(data,'CREATIVE_NAME','请输入创意标题',findDom[0],pageArray);648						return d;649					}650				,	callback:function(JSON){651						if(c_foot.length>0)c_foot[0].style.display='';652						var str=''653						,	postdata=this.postdata654						;655						JSON.INFO=JSON.INFO||{656											PAGE_INDEX:1657										,	CAMPAIGN_COUNT:0658										};659						JSON.LIST=JSON.LIST||{};660						if(!window.wm.msg(JSON.CODE,false))661							return;662						try{663							var	n=JSON.LIST.length664							;665							if(n<1){666								var html='<table width="100%"><tr><td colspan="12"><div class="warn">当前创意列表为空,推广组无法正常投放,请<a>添加创意</a></div></td></tr></table>';667								if(!$G.isNaN(postdata['query.adgroupId'])){668									listTestIdeasEach[0].innerHTML=html;669									$G('a',listTestIdeasEach[0])[0].onclick=function(){670										var data=window.leftTree.listUnitByPlan[postdata['query.adgroupId']];671										news.call(data,postdata['query.adgroupId']);672									}673								}else{674									html='<table width="100%"><tr><td colspan="12"><div class="warn">没有符合条件的数据</div></td></tr></table>';675									listTestIdeasEach[0].innerHTML=html;676								}677								return false;678							}679							for(var i=0;i<n;i++){680								var	v=JSON.LIST[i]681								,	hStr=listTestIdeasHtmlList[0].innerHTML682								;683								v.CREATIVE_DESTINATION_URL=v.CREATIVE_DESTINATION_URL.replace(/(http:\/\/)/g,"");684								v.MOBILE_DESTINATION_URL=v.MOBILE_DESTINATION_URL.replace(/(http:\/\/)/g,"");685								testIdeaListData[v.CREATIVE_ID]=v;686								$G.Each(function(i,val,json){687									var value=this;688									if(val=='CREATIVE_STATUS'){689										var vs=state[value];690										value=vs[0];691										if(value=='不宜推广'){692											value+='<i><img src="/static/ads_c_2.0/web/images/bulb_dim.png" width="16" height="16" msgWidth="300" msgTitle="'+value+':" title="目前创意处于离线中,因为您提交的URL地址无法访问,请检查创意的URL地址,在确认能打开后重新提交" /></i>';693										}else if(value=='审核拒绝'){694											value+='<i><img src="/static/ads_c_2.0/web/images/bulb_dim.png" width="16" height="16" msgWidth="300" msgTitle="'+value+':" title="'+json.CREATIVE_REFUSE_REASON+'" /></i>';695										}696										hStr=window.wm.setVal(hStr,val,value);697										hStr=window.wm.setVal(hStr,'creativeStateCss',vs[1]);698										if(value=='暂停'){699											value='stop_img';700										}else{701											value='start_img';702										}703										val='stateCss';704									}705									hStr=window.wm.setVal(hStr,val,value);706								},v);707								str+=hStr;708							}709							page.setup(JSON.INFO.CREATIVE_COUNT,n,pageArray);710							var endStr=listTestIdeasHtmlEnd[0].innerHTML;711							$G.Each(function(){712								var countValue=JSON.INFO[this+'']||0;713								endStr=window.wm.setVal(endStr,this+'',countValue);714							},'CREATIVE_COUNT CREATIVE_ENABLED CREATIVE_IMPRESSION CREATIVE_CLICK CREATIVE_CTR CREATIVE_CPC CREATIVE_COST CREATIVE_CPM'.split(" "));715							var html='<table width="100%">'+(listTestIdeasHtmlTitle[0].innerHTML).toString()+str+endStr.toString()+'</table>';716							listTestIdeasEach[0].innerHTML=html;717						}catch(e){alert('testIdea:'+e);}718						719						/****************************左则树联动***********************************/720						var ideasleftTreeList=$G('#leftTreeList');721						$G('.treePlanClick',listTestIdeasEach[0]).click(function(){722							var tpv=$G(this).getAtt('value')723							,	ideaObjJson=testIdeaListData[tpv]724							,	treePlanObj=$G('span:treePlan:'+ideaObjJson.CAMPAIGN_ID,ideasleftTreeList[0])725							;726							window.leftTree.planOnClick((ideaObjJson.CAMPAIGN_ID||''),treePlanObj[0]);727						});728						729						$G('.treeUnitClick',listTestIdeasEach[0]).click(function(){730							var tuv=$G(this).getAtt('value')731							,	ideaObjJson=testIdeaListData[tuv]732							,	treeUnitObj=$G('li:treeUnit:'+ideaObjJson.GROUP_ID,ideasleftTreeList[0])733							;734							window.leftTree.unitOnClick(treeUnitObj[0],(ideaObjJson.CAMPAIGN_ID||''));735						});736						/****************************列表浏览层***********************************/737						$G('.ideaDemo',listTestIdeasEach[0]).click(function(){738							var jsonIdea=testIdeaListData[$G(this).getAtt('value')];739							var appendList=$G('.appendList',add_preview[0]);740							ideaAction.demo.show(function(){741								$G('.testTitle .testDescription1 .testDisplayUrl',add_preview[0]).Each(function(){742									var name=$G(this).getAtt('name')743									,	key='CREATIVE_NAME'744									;745									if(name=='testDescription1')key='CREATIVE_DESCRIPTION';746									if(name=='testDisplayUrl')key='CREATIVE_DISPLAY_URL';747									this.innerHTML=jsonIdea[key]||'';748								});749								window.getGuaHao(function(d){750									guaHaoIni.call(add_preview[0],d,true);751								});752								if($G.isNaN(jsonIdea.CREATIVE_APPEND_ID)){753									appendList.html('<i style="clear:both;font-style:normal; float:left;font-size:13px;line-height:18px;width:480px;overflow: hidden; word-break: break-all; word-wrap: break-word; margin-right:10px;" name="testDisplayUrl"><a style="text-decoration:none;color: #006600;cursor:default;" target="_blank">'+jsonIdea.CREATIVE_DISPLAY_URL+'</a></i>');754								}else{755									window.appendIdea.getIdeasById(jsonIdea.CREATIVE_APPEND_ID,function(appendJson){756										appendList.html(window.appendIdea.getContent(appendJson.APPEND_CONTENT,'<i style=" font-style:normal;color:#261CDC; text-decoration:underline;" >{title}</i>'));757									});758									759								}760							});761						});762						/****************************编辑创意***********************************/763						$G('.edit',listTestIdeasEach[0]).click(function(){764							edit.call(this,testIdeaListData[$G(this).getAtt('value')]);765						});766						/****************************启用/暂停***********************************/767						$G('.pause',listTestIdeasEach[0]).click(function(){768							ideaPause.call(this,testIdeaListData[$G(this).getAtt('value')]);769						});770						771						$G('.listTestIdeaTd',listTestIdeasEach[0]).bd({on:'mousemove',callback:function(){772							$G('.listTestIdeaTr',listTestIdeasEach[0]).Each(function(){773								$G(this).setAtt('class','');774							});775							$G(this.parentNode).setAtt('class','key_ch');776						}}).bd({on:'mouseout',callback:function(arg,et){777							var tdObj=this;778							setTimeout(function(){779								if(et===tdObj){780									$G(tdObj.parentNode).setAtt('class','');781								}782							},0);783						}});784						785						$G('.listTestIdeasTool',listTestIdeasEach[0]).Each(function(i){786							var obj=$G(this)787							,	css=(obj.getAtt('class')+'').replace(/ thbg_curr/,'')788							,	id=obj.getAtt('value')789							;790							if(pageArray['orderSetId']==id){791								var aObj=$G('span',this)792								,	cssName=pageArray['orderSetCssName']793								;794								if(cssName=='bottom_curr'||!cssName){795									pageArray['sorts']='asc';796									aObj.setAtt('class','top_curr');797								}else{798									pageArray['sorts']='desc';799									aObj.setAtt('class','bottom_curr');800								}801								css+=' thbg_curr';802							}803							obj.setAtt('class',css);804						});805					}806				});807		;808		809		var orderBy=function(type){810			var setObj=$G(this)811			,	setId=setObj.getAtt('value')812			,	cObj=$G('span',this)813			,	cssName=cObj.getAtt('class')814			;815			pageArray['SORT_TYPE']=2;816			pageArray['SORT_COLUMN']=(Number(setId)+1);817			if(cssName=='bottom_curr'||!cssName){818				pageArray['SORT_TYPE']=1;819			}820			pageArray['orderSetId']=setId;821			pageArray['orderSetCssName']=cssName;822			823			list.sub();824		};825		var selectAll=function(){826				var c=this.checked;827				$G('.listTestIdeasCheckId',listTestIdeasEach[0]).Each(function(){828					this.checked=c;829				});830			}831		,	selectId=function(id){832				var c=this.checked833				,	list=$G('.listTestIdeasCheckId',listTestIdeasEach[0])834				,	n=list.length835				,	cn=list.checked(true).length836				;837				if(n==cn)$G('.listTestIdeasCheckAll',listTestIdeasEach[0])[0].checked=true;838				else $G('.listTestIdeasCheckAll',listTestIdeasEach[0])[0].checked=false;839			}840		;841		var findSelId=function(){842			var selObjList=$G('.listTestIdeasCheckId',listTestIdeasEach[0])843			,	cv=selObjList.checked(true)844			,	cn=cv.length845			;846			return {847				objlist:selObjList848			,	vlist:cv849			,	n:cn850			};851		};852		$G('#testIdeasToolsDelAll').click(function(){853			var s=findSelId();854			if(s.n<1){855				window.altBox.show({856					title:'提示信息'857				,	msg:'请在列表中选中创意后再进行删除操作'858				});859			}else{860				window.gconfirm({861					msg:'您确定要删除选中的创意吗?'862				,	fn:function(isTrue){863						if(isTrue){864							remove(s.vlist.join(','));865						}866					}867				});868			}869		});870		$G('#testIdeasToolsSotpAll').click(function(){871			var s=findSelId();872			if(s.n<1){873				window.altBox.show({874					title:'提示信息'875				,	msg:'请在列表中选中创意后再进行暂停操作'876				});877			}else{878				window.gconfirm({879					msg:'您确定要暂停选中的创意吗?'880				,	fn:function(isTrue){881						if(isTrue){882							pause(s.vlist.join(','),1,2);883						}884					}885				});886			}887		});888		$G('#testIdeasToolsStartAll').click(function(){889			var s=findSelId();890			if(s.n<1){891				window.altBox.show({892					title:'提示信息'893				,	msg:'请在列表中选中创意后再进行启动操作'894				});895			}else{896				window.gconfirm({897					msg:'您确定要启用选中的创意吗?'898				,	fn:function(isTrue){899						if(isTrue){900							pause(s.vlist.join(','),1,1);901						}902					}903				});904			}905		});906		907		var addNewMobile_list=$G('#addNewMobile_list');908		$G('#addNewMobile').click(function(){909			var obj=$G(this)910			,	c=obj.getAtt('class')911			;912			if(c=='tianjia'){913				obj.setAtt('class','tianjia_j');914				addNewMobile_list.show();915			}else{916				obj.setAtt('class','tianjia');917				addNewMobile_list.none();918			}919		});920		/******************数据报告日期范围提交****************************/921		$G('.DATE_TYPE',findDom[0])[0].onchange=function(){922			list.sub();923		};924		/******************查询名称效果************************************/925		$G('.FIND_NAME',findDom[0]).click(function(){926			if(this.value=='请输入创意标题'){927				this.value='';928			}929		}).change(function(){930			if(this.value==''){931				this.value='请输入创意标题';932			}933		});934		var findWhere=function(){935			var FIND_STATUS=$G('.FIND_STATUS',findDom[0])936			,	FIND_NAME=$G('.FIND_NAME',findDom[0])937			,	FIND_TYPE=$G('.FIND_TYPE',findDom[0])938			,	DATE_TYPE=$G('.DATE_TYPE',findDom[0])939			;940			pageArray['PAGE_INDEX']=1;941			pageArray['CAMPAIGN_ID']='';942			pageArray['GROUP_ID']='';943			pageArray['click']=function(pageObj){944				pageArray=pageObj;945				list.sub();946			};947			pageArray['SORT_TYPE']=2;948			pageArray['SORT_COLUMN']=6;949			return {950				clear:function(){951					FIND_STATUS.setseltext('全部状态');952					FIND_NAME.val('请输入创意标题');953					FIND_TYPE[0].checked=false;954					DATE_TYPE.setselvalue(1);955					window.selDom&&window.selDom.resall();956				}957			};958		}();959		960		961		return {962			list:function(obj){963				obj=obj||{};964				findWhere.clear();965				pageArray['PAGE_INDEX']=obj.p||pageIni.PAGE_INDEX;966				pageArray['CAMPAIGN_ID']=obj.planId||'';967				pageArray['GROUP_ID']=obj.unitId||'';968				list.sub();969			}970		,	add:add971		,	orderBy:orderBy972		,	selectAll:selectAll973		,	selectId:selectId974		,	cyDisplay:cyDisplay975		,	findSelId:findSelId976		};977	}();978	
...

Full Screen

Full Screen

checkWord.js

Source:checkWord.js Github

copy

Full Screen

1(function(){2	window.checkWord=function(){3		var findDom=$G('div:main')4		,	listCheckWordTitle=$G('#listCheckWordTitle')5		,	listCheckWordList=$G('#listCheckWordList')6		,	listCheckWordErr=$G('#listCheckWordErr')7		,	checkWordList=$G('#checkWordList')8		,	dataList={}9		,	state={10				'1':['审核通过','green']11			,	'2':['不宜推广','red']12			,	'3':['暂停','orange']13			,	'4':['待审核','']14			,	'5':['审核拒绝','red']15			}16		,	getAccount=function(id){17				window.userDemo.show(id);18			}19			//审核20		,	setCreativeState=function(creativeIds,creativeState,refuseReason,fn){21				var data={22					CREATIVE_TYPE:123				,	CREATIVE_STATUS:creativeState24				,	CREATIVE_ID_ARRAY:creativeIds25				,	CREATIVE_REFUSE_REASON:refuseReason||''26				};27				window.checkPass(data,fn);28			}29			//重新验证30		,	resetCheckFn=function(creativeId,CREATIVE_DESTINATION_URL,fn){31				var data={32					CREATIVE_TYPE:133				,	CREATIVE_ID:creativeId34				};35				window.checkReset(data,fn);36			}37		,	viewRefuse=function(){38				var	view_refuse=$G('#view_refuse')39				,	adiv=window.alertDiv({40						findObj:'#view_refuse'41					,	position:'absolute'42					,	move:$G('div:title',view_refuse[0])43					})44				;45				return {46					show:function(fn){47						fn&&fn.call(view_refuse[0],adiv);48						adiv.show();49					}50				,	none:adiv.close51				}52			}()53		,	checkRefuse=function(){54				var	view_refuse2=$G('#view_refuse2')55				,	adiv=window.alertDiv({56						findObj:'#view_refuse2'57					,	position:'absolute'58					,	move:$G('div:title',view_refuse2[0])59					})60				;61				return {62					show:function(fn){63						$G('textarea',view_refuse2[0])[0].value='';64						fn&&fn.call(view_refuse2[0],adiv);65						adiv.show();66					}67				,	none:adiv.close68				}69			}()70		,	viewAddress=function(){71				var	view_address=$G('#view_address')72				,	adiv=window.alertDiv({73						findObj:'#view_address'74					,	position:'absolute'75					,	move:$G('div:check_title_box',view_address[0])76					})77				;78				return {79					show:function(fn){80						fn&&fn.call(view_address[0],adiv);81						adiv.show();82					}83				,	none:adiv.close84				}85			}()86		,	wordPreview=function(){87				var	word_preview=$G('#word_preview')88				,	adiv=window.alertDiv({89						findObj:'#word_preview'90					,	position:'absolute'91					,	move:$G('div:check_title_box',word_preview[0])92					})93				;94				95				return {96					show:function(jsonIdea,k,fn){97						var check_title=$G('b',$G('div:check_title',word_preview[0])[0])98						,	wordBtn=$G('.wordBtn',word_preview[0])99						;100						wordBtn.Each(function(i){101							if(k==i)102								this.style.display='';103							else104								this.style.display='none';105						});106						check_title.html(this.innerHTML);107						$G('.testTitle .testDescription1 .testDisplayUrl',word_preview[0]).Each(function(){108							var name=$G(this).getAtt('name')109							,	key='CREATIVE_NAME'110							;111							if(name=='testDescription1')key='CREATIVE_DESCRIPTION';112							if(name=='testDisplayUrl')key='CREATIVE_DISPLAY_URL';113							this.innerHTML=jsonIdea[key]||'';114						});115						var appendList=$G(".appendList",word_preview[0]);116						if(jsonIdea.CREATIVE_APPEND_TYPE==1){117							appendList.html('<i class="zi_link_address"><a>'+jsonIdea.CREATIVE_DISPLAY_URL+'</a></i>');118						}else{119							window.appendIdea.getIdeasById(jsonIdea.CREATIVE_APPEND_ID,function(appendJson){120								appendList.html(window.appendIdea.getContent(appendJson.CREATIVE_CONTENT,'<i style=" font-style:normal;color:#261CDC; text-decoration:underline;" >{title}</i>'));121							});122						}123						124						fn&&fn.call(word_preview[0],adiv,wordBtn);125						adiv.show();126					}127				,	none:adiv.close128				}129			}()130		,	selectAll=function(){131				var c=this.checked;132				$G('.listCheckWordCheckbox',checkWordList[0]).Each(function(){133					this.checked=c;134				});135			}136		,	selectId=function(k){137				var obj='';138				if(k==1){139					obj=$G('#pic_'+this.value,checkWordList[0]);140					141				}else{142					obj=$G('#pic_'+this.value+'_tmp',checkWordList[0]);143					144				}145				if(obj){146					var checkboxObj=$G('input',obj[0])147					;148					checkboxObj[0].checked=this.checked;149				}150				var c=this.checked151				,	list=$G('.listCheckWordCheckbox',checkWordList[0])152				,	n=list.length153				,	cn=list.checked(true).length154				;155				if(n==cn)$G('.listCheckWordCheckboxAll',checkWordList[0])[0].checked=true;156				else $G('.listCheckWordCheckboxAll',checkWordList[0])[0].checked=false;157			}158		,	findSelId=function(){159				var selObjList=$G('.listCheckWordCheckbox',checkWordList[0])160				,	cv=selObjList.checked(true)161				,	cn=cv.length162				;163				return {164					objlist:selObjList165				,	vlist:cv166				,	n:cn167				};168			}169		;170		$G('.tools',findDom[0]).click(function(){171			var obj=this172			,	name=obj.name173			,	ids=findSelId()174			;175			if(obj.innerHTML=='批量通过'){176				if(ids.n<1){177					window.altBox.show({178						title:'确认提示信息'179					,	msg:'请在列表中选中创意后再进行批量通过操作'180					});181				}else{182					window.gconfirm({183						msg:'您确定要将选中创意批量通过吗?'184					,	title:'确认提示信息'185					,	fn:function(isTrue){186							if(isTrue){187								setCreativeState(ids.vlist.join(','),1,'',function(){188									list.sub();189								});190							}191						}192					});193				}194			}else if(obj.innerHTML=='批量拒绝'){195				if(ids.n<1){196					window.altBox.show({197						title:'确认提示信息'198					,	msg:'请在列表中选中创意后再进行批量拒绝操作'199					});200				}else{201					window.gconfirm({202						msg:'您确定要将选中创意批量拒绝吗?'203					,	title:'确认提示信息'204					,	fn:function(isTrue){205							if(isTrue){206								checkRefuse.show(function(checkRefuseAlert){207									var aSub=$G('a',this)208									,	checkRefuseObj=this209									;210									aSub[0].onclick=function(){211										var textareaValue=$G('textarea',checkRefuseObj).val()||'';212										textareaValue=textareaValue[0];213										if($G.isNaN(textareaValue)){214											window.altBox.show({215												title:'提示信息'216											,	msg:'请输入审核拒绝原因!'217											});218											return;219										}220										setCreativeState(ids.vlist.join(','),2,textareaValue,function(checkRefuseJson){221											if(checkRefuseJson.code=='1212'){222												window.altBox.show({223													title:'提示信息'224												,	msg:'请输入审核拒绝原因!'225												});226												return;227											}else{228												list.sub();229												checkRefuseAlert.none();230											}231										});232									};233								});234							}235						}236					});237				}238			}239		});240		/***********************获取创意列表************************************/241		var page=window.page()242		,	pageIni=page.getPage()243		,	pageArray=page.getPage()244		,	list=window.subAjax('div:conditions',{245					path:'GET_TEXT_CREATIVE'246				,	sub:'#subList'247				,	findDom:findDom[0]248				,	obj:checkWordList[0]249				,	ckdata:function(data){250						if($G.isNaN(this.id))data['FIND_TYPE']='';251						var d=window.wm.setDataListManager(data,findDom[0],pageArray);252						return d;253					}254				,	callback:function(JSON){255						var str=''256						,	postdata=this.postdata257						;258						JSON.INFO=JSON.INFO||{259											PAGE_INDEX:1260										,	CAMPAIGN_COUNT:0261										};262						JSON.LIST=JSON.LIST||{};263						if(!window.wm.msg(JSON.CODE,false))264							return;265						try{266							var	n=JSON.LIST.length267							;268							if(n<1){269								checkWordList[0].innerHTML=listCheckWordErr.html();270								return false;271							}272							for(var i=0;i<n;i++){273								var	v=JSON.LIST[i]274								,	hStr=listCheckWordList[0].innerHTML275								;276								dataList[v.CREATIVE_ID]=v;277								$G.Each(function(i,val,json){278									var value=this;279									if(val=='CREATIVE_STATE'){280										var vs=state[value]281										,	toolTest='查看创意'282										;283										hStr=window.wm.setVal(hStr,'creativeStateCss',vs[1]);284										if(value==4){285											toolTest='审核创意';286										}else if(value==5){287											toolTest='查看原因';288										}289										value=vs[0];290										hStr=window.wm.setVal(hStr,'toolTest',toolTest);291									}292									hStr=window.wm.setVal(hStr,val,value);293								},v);294								str+=hStr;295							}296							page.setup(JSON.INFO.CREATIVE_COUNT,n,pageArray);297							var html='<table width="100%">'+(listCheckWordTitle[0].innerHTML).toString()+str+'</table>';298							checkWordList[0].innerHTML=html;299						}catch(e){alert('checkWord:'+e);}300						301						$G('a',checkWordList[0]).click(function(){302							var obj=$G(this)303							,	value=obj.getAtt('value')304							,	name=obj.getAtt('name')305							,	viewErr=function(errAlert,json){306									var li=$G('li',this)307									,	a=$G('a',this)308									;309									if(json.auditorId=="0" && name=='auditorName'){310										json.auditorName='系统自动审核';311									}312									li.Each(function(){313										var obj=$G(this)314										,	name=obj.getAtt('name')315										;316										if($G.isNaN(name))return;317										this.innerHTML=json[name];318									});319									a[0].onclick=function(){320										errAlert.none();321										wordPreview.show.call(this,json,1,function(alertDom){322											viewPicFn.call(this,alertDom,json);323										});324									};325								}326							,	viewPicFn=function(alertDom,json){327									var alertObj=this328									;329									$G('a',this).Each(function(){330										var obj=$G(this)331										,	name=obj.getAtt('name')332										;333										this.onclick=function(){334											if(name=='lookCheck'){335												viewAddress.show(function(){336													var imgObj=$G('a',this)337													;338													imgObj.html(json.CREATIVE_DESTINATION_URL);339													imgObj[0].href=json.CREATIVE_DESTINATION_URL;340												});341											}else if(name=='resetCheck'){342												resetCheckFn(json.CREATIVE_ID,json.CREATIVE_DESTINATION_URL,function(resJson){343													if(resJson.code=='1230'){344														window.altBox.show({345															title:'提示信息'346														,	msg:'访问URL不宜推广!'347														});348													}else{349														list.sub();350														window.altBox.show({351															title:'提示信息'352														,	msg:'验证成功!'353														});354													}355												});356											}else if(name=='checkPass'){357												setCreativeState(json.CREATIVE_ID,1,'',function(){358													list.sub();359													alertDom.none();360												});361											}else if(name=='refusePass'){362												alertDom.none();363												checkRefuse.show(function(checkRefuseAlert){364													var aSub=$G('a',this)365													,	checkRefuseObj=this366													;367													aSub[0].onclick=function(){368														var textareaValue=$G('textarea',checkRefuseObj).val()||'';369														textareaValue=textareaValue[0];370														if($G.isNaN(textareaValue)){371															window.altBox.show({372																title:'提示信息'373															,	msg:'请输入审核拒绝原因!'374															});375															return;376														}377														setCreativeState(json.CREATIVE_ID,2,textareaValue,function(checkRefuseJson){378															if(checkRefuseJson.code=='1212'){379																window.altBox.show({380																	title:'提示信息'381																,	msg:'请输入审核拒绝原因!'382																});383																return;384															}else{385																list.sub();386																checkRefuseAlert.none();387															}388														});389													};390												});391											}392										};393									});394								}395							;396							if(name=='viewWord'){397								wordPreview.show.call(this,dataList[value],5);398							}else if(name=='tools'){399								var json=dataList[value]400								;401								if(json.CREATIVE_STATE==4){402									wordPreview.show.call(this,json,0,function(alertDom){403										viewPicFn.call(this,alertDom,json);404									});405								}else if(json.CREATIVE_STATE==2){406									wordPreview.show.call(this,json,2,function(alertDom){407										viewPicFn.call(this,alertDom,json);408									});409								}else if(json.CREATIVE_STATE==5){410									viewRefuse.show(function(alertDom){411										viewErr.call(this,alertDom,json);412									});413								}else{414									wordPreview.show.call(this,json,3,function(alertDom){415										viewPicFn.call(this,alertDom,json);416									});417								}						418							}else if(name=='loginName'){419								getAccount(value);420							}421						});422						423						$G('.listWordTd',checkWordList[0]).bd({on:'mousemove',callback:function(){424							$G('.listWordTr',checkWordList[0]).Each(function(){425								$G(this).setAtt('class','');426							});427							$G(this.parentNode).setAtt('class','key_ch');428						}}).bd({on:'mouseout',callback:function(arg,et){429							var tdObj=this;430							setTimeout(function(){431								if(et===tdObj){432									$G(tdObj.parentNode).setAtt('class','');433								}434							},0);435						}});436						437					}438				});439		;440		pageArray['click']=function(pageObj){441			pageArray=pageObj;442			list.sub();443		};444		list.sub();445		return {446			list:function(p){447				pageArray['PAGE_INDEX']=obj.p||pageIni.PAGE_INDEX;448				list.sub();449			}450		,	selectAll:selectAll451		,	selectId:selectId452		};453	}();454	
...

Full Screen

Full Screen

urlFieldValueEditor.unit.spec.js

Source:urlFieldValueEditor.unit.spec.js Github

copy

Full Screen

1import React from 'react';2import ReactDOM from 'react-dom';3import TestUtils, {Simulate} from 'react-addons-test-utils';4import UrlFieldValueEditor from '../../src/components/fields/urlFieldValueEditor';5describe('UrlFieldValueEditor', () => {6    let component;7    let placeholderText = 'www.example.com'; // Specified in https://quickbase.atlassian.net/wiki/display/qbasepd/Error+messages8    let testUrl = 'www.google.com';9    let testUrlWithProtocol = 'http://www.google.com';10    let testDisplayUrl = "Don't edit me";11    let MockParent = React.createClass({12        getInitialState() {13            return {14                url: null,15                displayUrl: testDisplayUrl16            };17        },18        onChange(newValue) {19            this.setState({url: newValue});20        },21        onBlur(updatedValueObject) {22            this.setState(updatedValueObject);23        },24        render() {25            return (26                <UrlFieldValueEditor value={this.state.value}27                                     display={this.state.display}28                                     onChange={this.onChange}29                                     onBlur={this.onBlur}30                                     fieldDef={{datatypeAttributes: {displayProtocol: false}}}/>31            );32        }33    });34    it('allows a user to edit the raw value of a url', () => {35        component = TestUtils.renderIntoDocument(<MockParent />);36        const input = TestUtils.findRenderedDOMComponentWithTag(component, 'input');37        Simulate.change(input, {38            target: {value: testUrl}39        });40        expect(component.state.url).toEqual(testUrl);41        expect(component.state.displayUrl).toEqual(testDisplayUrl);42    });43    it('has placeholder text', () => {44        component = TestUtils.renderIntoDocument(<MockParent />);45        const input = TestUtils.findRenderedDOMComponentWithTag(component, 'input');46        expect(input.placeholder).toEqual(placeholderText);47    });48    it('formats the url for display onBlur', () => {49        component = TestUtils.renderIntoDocument(<MockParent />);50        component.setState({value: testUrl, display: ''});51        const input = TestUtils.findRenderedDOMComponentWithTag(component, 'input');52        Simulate.blur(input, {53            value: testUrlWithProtocol54        });55        expect(component.state.display).toEqual(testUrl);56    });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2  it('Visits the Kitchen Sink', function() {3  })4})5describe('My First Test', function() {6  it('Visits the Kitchen Sink', function() {7  })8})9Cypress.Commands.add('testDisplayUrl', (url) => {10  cy.url().should('eq', url)11})12describe('My First Test', function() {13  it('Visits the Kitchen Sink', function() {14  })15})16describe('My First Test', function() {17  it('Visits the Kitchen Sink', function() {18  })19})20Cypress.Commands.add('testDisplayUrl', (url) => {21  cy.url().should('eq', url)22})23describe('My First Test', function() {24  it('Visits the Kitchen Sink', function() {25  })26})27describe('My First Test',

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2  it('Does not do much!', function() {3    cy.testDisplayUrl()4  })5})6Cypress.Commands.add('testDisplayUrl', () => {7  cy.get('a').each(($el, index, $list) => {8    const href = $el.prop('href')9    cy.request(href).then((resp) => {10      expect(resp.status).to.eq(200)11    })12  })13})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2  it('test', () => {3  })4})5Cypress.Commands.add('testDisplayUrl', (url) => {6  cy.url().should('eq', url)7})8import './commands'9{10  "compilerOptions": {11  }12}

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.testDisplayUrl()2Cypress.Commands.add('testDisplayUrl', () => {3  cy.url().then((url) => {4    cy.log(url)5  })6})7import './commands'8describe('My First Test', () => {9  it('Does not do much!', () => {10    cy.testDisplayUrl()11  })12})13describe('My First Test', () => {14  it('Does not do much!', () => {15    cy.testDisplayUrl()16    cy.log('test')17  })18})19describe('My First Test', () => {20  it('Does not do much!', () => {21    cy.testDisplayUrl()22    cy.log('test')23    cy.get('.home-list > :nth-child(1) > .home-list-item').click()24  })25})26describe('My First Test', () => {27  it('Does not do much!', () => {28    cy.testDisplayUrl()29    cy.log('test')30    cy.get('.home-list > :nth-child(1) > .home-list-item').click()31    cy.testDisplayUrl()32  })33})34describe('My First Test', () => {35  it('Does not do much!', () => {36    cy.testDisplayUrl()37    cy.log('test')38    cy.get('.home

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2  before(() => {3  })4  it('test', () => {5    cy.get('button').click()6  })7})8Cypress.Commands.add('testDisplayUrl', (url) => {9  cy.url().should('eq', url)10})11import './commands'12{13}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Cypress', () => {2    it('test', () => {3    })4})5Cypress.Commands.add('testDisplayUrl', (url) => {6    cy.url().should('include', url)7})8{9}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Cypress', function() {2    it('test display url', function() {3        cy.testDisplayUrl();4    });5});6Cypress.Commands.add('testDisplayUrl', () => {7    cy.log('Test display url');8});9{10}

Full Screen

Using AI Code Generation

copy

Full Screen

1it('test display url', function() {2    cy.testDisplayUrl();3});4import 'cypress-display-url';5it('test display url', function() {6    cy.testDisplayUrl();7});8MIT © [Saurabh Kumar](

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful