How to use addAttr method in Playwright Internal

Best JavaScript code snippet using playwright-internal

databind.js

Source:databind.js Github

copy

Full Screen

1$(function(){2 $(".gridly").children("div").each(function(){3 var t=$(this).attr("i");4 switch($(this).attr("name")){5 case "DaoHang":6 dhAttrBind(t);7 break;8 case "SouSuo":9 ssAttrBind(t);10 break;11 case "WenBen":12 wbAttrBind(t);13 break;14 case "GunDong":15 gdAttrBind(t);16 break;17 case "TuPian":18 tpAttrBind(t);19 break;20 case "HuanDeng":21 hdpAttrBind(t);22 break;23 case "ShangPin":24 break;25 case "LieBiao":26 splbAttrBind(t);27 break;28 case "KongBai":29 kbAttrBind(t)30 break;31 case "DianZhao":32 break;33 case "ShiPin":34 break;35 }36 $(this).click(function () {37 integrate(this,t);38 });39 });40 choseColor();41})42//rgb(10进制)转#fff(16进制)的方法43function RGBToHex(rgb) {44if(rgb==null || rgb=="" || rgb==undefined)rgb="#ffffff";45 var regexp = /^rgb\(([0-9]{0,3})\,\s([0-9]{0,3})\,\s([0-9]{0,3})\)/g;46 var re = rgb.replace(regexp, "$1 $2 $3").split(" ");//利用正则表达式去掉多余的部分47 var hexColor = "#";48 var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];49 for (var i = 0; i < 3; i++) {50 var r = null;51 var c = re[i];52 var hexAr = [];53 while (c > 16) {54 r = c % 16;55 c = (c / 16) >> 0;56 hexAr.push(hex[r]);57 }58 hexAr.push(hex[c]);59 hexColor += hexAr.reverse().join('');60 }61 return hexColor;62}63//导航数据绑定64function dhAttrBind(t) {65 n = 1;66 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +67 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>"+68 "<tr><td align='right'>显示方式:</td><td><input type='radio' name='way" + t + "' value='two' />一行两列</td><td><input type='radio' name='way" + t + "' value='three' />一行三列</td><td><input type='radio' name='way" + t + "' value='four' />一行四列</td></tr>" +69 "<tr><td align='right'>显示设置:</td><td><input type='radio' name='displaySet" + t + "' value='1' />图片</td><td><input type='radio' name='displaySet" + t + "' value='2' />文字</td><td><input type='radio' name='displaySet" + t + "' value='3' />图文</td></tr>" +70 "<tr><td align='right'>是否换行:</td><td><input type='radio' name='newLine" + i + "' value='true'/>是</td><td colspan='2'><input type='radio' name='newLine" + i + "' value='false' />否(当前无法显示滑动效果,真机上可滑动)</td></tr>" +71 "<tr><td align='right'>高度:</td><td colspan='2'><div class='sliding'></div></td><td><span class='amount'></span>px</td></tr>" +72 "</table><p class='increase' onclick='addDH(this)'>增加</p></div>";73 $(divhtml).appendTo(".attribute_frame");74 if ($("#module" + t).find("ul").is(".dh_style4")) {75 $("#addAttr" + t + " input[value='four']").attr("checked", "checked");76 } else if ($("#module" + t).find("ul").is(".dh_style3")) {77 $("#addAttr" + t + " input[value='three']").attr("checked", "checked");78 } else {79 $("#addAttr" + t + " input[value='two']").attr("checked", "checked");80 }81 if ($("#module" + t).find("ul li a img").first().css("display") == "block" && $("#module" + t).find("ul li a span").first().css("display")=="none") {82 $("#addAttr" + t + " input[value='1']").attr("checked", "checked");83 } else if ($("#module" + t).find("ul li a img").first().css("display") == "none" && $("#module" + t).find("ul li a span").first().css("display") == "block") {84 $("#addAttr" + t + " input[value='2']").attr("checked", "checked");85 } else {86 $("#addAttr" + t + " input[value='3']").attr("checked", "checked");87 }88 if ($("#module" + t).find("ul").attr("class").indexOf("newLine") >= 0) {89 $("#addAttr" + t + " input[value='false']").attr("checked", "checked");90 } else {91 $("#addAttr" + t + " input[value='true']").attr("checked", "checked");92 }93 var htmldiv = "";94 $("#module" + t).find("ul li").each(function () {95 var p = $(this).attr("n");96 var fontColor = $(this).find("a span").css("color");97 var bgColor = $(this).find("a span").css("background");98 var imgSrc = $(this).find("a img").attr("src");99 var hrefval = $(this).find("a").attr("href");100 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +101 "<tr><td>导航图片:</td><td><button type='button' onclick='chooseImg(this,\"DaoHang\")'>选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +102 "<tr><td></td><td><img src='" + imgSrc + "'></td></tr>" +103 "<tr><td></td><td style='color:#828282'>建议尺寸:150px × 150px</td></tr>" +104 "<tr><td>导航名称:</td><td colspan='2'><input type='text' value='" + $(this).find("span").text() + "' class='name_shop' /><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +105 "<tr><td>背景颜色:</td><td><input type='text' id='demo-hue' class='form-control demo' data-control='hue' value='" + RGBToHex(bgColor) + "'></td></tr>" +106 "<tr><td>导航链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /></td><td><select onchange='selectchg(this)'>" +107 "<option value ='/Vshop/index.aspx'>首页</option>" +108 "<option value ='/Vshop/ProductSearch.aspx'>分类页面</option>" +109 "<option value ='/Vshop/ShoppingCart.aspx'>购物车</option>" +110 "<option value ='/Vshop/ProductList.aspx'>商品列表</option>" +111 "<option value ='/Vshop/ArticleCategory.aspx'>新闻列表</option>" +112 "<option value ='/Vshop/MemberCenter.aspx'>用户中心</option>" +113 "<option value ='/Vshop/groupbuylist.aspx'>团购活动</option>" +114 "<option value ='/Vshop/CountDownproductlist.aspx'>限时限购</option>" +115 "<option value ='/Vshop/cutdownlist.aspx '>砍价活动</option>" +116 "<option value ='/Vshop/myvantages.aspx'>积分兑换</option>" +117 "<option value ='/Vshop/myredpager.aspx'>我的优惠券</option>" +118 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +119 "<option value =''>自定义链接</option>" +120 "</select></td></tr>" +121 "</table>";122 });123 $("#addAttr" + t + " p").before(htmldiv);124 $("#addAttr" + t + " .name_shop").each(function () {125 $(this).change(function () {126 var p = $(this).parents("table").attr("n");127 $("#module" + t + " #nav_li" + p + " span").html($(this).val());128 });129 });130 $("#addAttr" + t + " #hue-demo").each(function () {131 $(this).change(function () {132 var p = $(this).parents("table").attr("n");133 $("#module" + t + " #nav_li" + p + " span").css("color", $(this).val());134 });135 });136 $("#addAttr" + t + " .href_shop").each(function () {137 $(this).change(function () {138 var p = $(this).parents("table").attr("n");139 $("#module" + t + " #nav_li" + p + " a").attr("href", $(this).val());140 });141 });142 $("#addAttr" + t + " #demo-hue").each(function () {143 $(this).change(function () {144 var p = $(this).parents("table").attr("n");145 $("#module" + t + " #nav_li" + p + " .wb_txt").css("background-color", $(this).val());146 });147 });148 hrefset(t);149}150function hrefset(t) {151 $("#module" + t + " ul li").each(function () {152 var p = $(this).attr("n");153 switch ($(this).find("a").attr("href")) {154 case "/Vshop/index.aspx":155 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/index.aspx']").attr("selected", "selected");156 break;157 case "/Vshop/ProductSearch.aspx":158 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ProductSearch.aspx']").attr("selected", "selected");159 break;160 case "/Vshop/ShoppingCart.aspx":161 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ShoppingCart.aspx']").attr("selected", "selected");162 break;163 case "/Vshop/ProductList.aspx":164 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ProductList.aspx']").attr("selected", "selected");165 break;166 case "/Vshop/ArticleCategory.aspx":167 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ArticleCategory.aspx']").attr("selected", "selected");168 break;169 case "/Vshop/MemberCenter.aspx":170 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/MemberCenter.aspx']").attr("selected", "selected");171 break;172 case "/Vshop/groupbuylist.aspx":173 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/groupbuylist.aspx']").attr("selected", "selected");174 break;175 case "/Vshop/CountDownproductlist.aspx":176 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/CountDownproductlist.aspx']").attr("selected", "selected");177 break;178 case "/Vshop/cutdownlist.aspx":179 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/cutdownlist.aspx']").attr("selected", "selected");180 break;181 case "/Vshop/myvantages.aspx":182 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/myvantages.aspx']").attr("selected", "selected");183 break;184 case "/Vshop/myredpager.aspx":185 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/myredpager.aspx']").attr("selected", "selected");186 break;187 case "/Vshop/SaleService.aspx":188 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/SaleService.aspx']").attr("selected", "selected");189 break;190 default:191 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='']").attr("selected", "selected");192 }193 });194}195//文本数据绑定196function wbAttrBind(t) {197 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +198 "<table class='nav_li_attr' cellpadding='0' cellspacing='0' border='0'>" +199 "<tr><td><script id='editor" + t + "' type='text/plain' style='width:500px;min-height:200px;'>" + $('#module'+t+' .wb_txt').html() + "</script></td></tr>" +200 "</table>" +201 "</div>";202 $(divhtml).appendTo(".attribute_frame");203 EditorU(t);204}205//搜索数据绑定206function ssAttrBind(t) {207 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +208 "<p>可随意插入任何页面和位置,方便会员快速搜索商品。</p>" +209 "</div>";210 $(divhtml).appendTo(".attribute_frame");211}212//滚动公告数据绑定213function gdAttrBind(t) {214 var fontColor = $("#module" + t + " .wb_txt a").css("color");215 var aHref = $("#module" + t + " .wb_txt a").attr("href");216 var atxt = $("#module" + t + " .wb_txt #scroll_begin").text().trim();217 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +218 "<table class='nav_li_attr' cellpadding='0' cellspacing='0' border='0'>" +219 "<tr><td>文本内容:</td><td><textarea rows='3' cols='50' >" + atxt + "</textarea></td></tr>" +220 "<tr><td>文本链接:</td><td><input type='text' class='href_wb' value='"+aHref+"'></td></tr>" +221 "<tr><td>文本颜色:</td><td><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +222 "</table>" +223 "</div>";224 $(divhtml).appendTo(".attribute_frame");225 ScrollImgLeft();226}227//图片数据绑定228function tpAttrBind(t) {229 n = 1;230 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +231 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +232 "<tr><td align='right'>显示方式:</td><td><input type='radio' name='mode" + t + "' value='two' />一行一张</td><td><input type='radio' name='mode" + t + "' value='three' />一行两张</td><td><input type='radio' name='mode" + t + "' value='four' />一行三张</td></tr>" +233 "<tr><td align='right'>显示文字:</td><td><input type='radio' name='txt" + t + "' value='yes' />是</td><td><input type='radio' name='txt" + t + "' value='no' />否</td><td></td></tr>" +234 "</table>" +235 "<p class='increase' onclick='addTP(this)'>增加</p>" +236 "</div>";237 $(divhtml).appendTo(".attribute_frame");238 if ($("#module" + t).find("ul").is(".tp_style1")) {239 $("#addAttr" + t + " input[value='two']").attr("checked", "checked");240 } else if ($("#module" + t).find("ul").is(".tp_style2")) {241 $("#addAttr" + t + " input[value='three']").attr("checked", "checked");242 } else {243 $("#addAttr" + t + " input[value='four']").attr("checked", "checked");244 }245 if ($("#module" + t).find("ul li span").first().css("display") == "block") {246 $("#addAttr" + t + " input[value='yes']").attr("checked", "checked");247 } else {248 $("#addAttr" + t + " input[value='no']").attr("checked", "checked");249 }250 var htmldiv = "";251 $("#module" + t).find("ul li").each(function () {252 var p = $(this).attr("n");253 var atxt = $(this).find("span").text();254 var fontColor = $(this).find("span").css("color");255 var imgSrc = $(this).find("img").attr("src");256 var aHref = $("#module" + t + " .wb_txt a").attr("href");257 var hrefval = $(this).find("a").attr("href");258 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +259 "<tr><td>图片:</td><td width='238px'><button onclick='chooseImg(this,\"TuPian\")' type='button' >选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +260 "<tr><td></td><td><img src='" + imgSrc + "'/></td></tr>" +261 "<tr><td>文字说明:</td><td><input type='text' value='" + atxt + "' class='name_shop' /></td></tr>" +262 "<tr><td></td><td><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +263 "<tr><td>图片链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /><td><select onchange='selectchg(this)'>" +264 "<option value ='/Vshop/index.aspx'>首页</option>" +265 "<option value ='/Vshop/ProductSearch.aspx'>分类页面</option>" +266 "<option value ='/Vshop/ShoppingCart.aspx'>购物车</option>" +267 "<option value ='/Vshop/ProductList.aspx'>商品列表</option>" +268 "<option value ='/Vshop/ArticleCategory.aspx'>新闻列表</option>" +269 "<option value ='/Vshop/MemberCenter.aspx'>用户中心</option>" +270 "<option value ='/Vshop/groupbuylist.aspx'>团购活动</option>" +271 "<option value ='/Vshop/CountDownproductlist.aspx'>限时限购</option>" +272 "<option value ='/Vshop/cutdownlist.aspx '>砍价活动</option>" +273 "<option value ='/Vshop/myvantages.aspx'>积分兑换</option>" +274 "<option value ='/Vshop/myredpager.aspx'>我的优惠券</option>" +275 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +276 "<option value =''>自定义链接</option>" +277 "</td></select></td></tr>" +278 "</table>";279 });280 $("#addAttr" + t + " p").before(htmldiv);281 $("#addAttr" + t + " .name_shop").each(function () {282 $(this).change(function () {283 var p = $(this).parents("table").attr("n");284 alert(t);285 alert(p);286 $("#module" + t + " #nav_li" + p + " span").html($(this).val());287 });288 });289 $("#addAttr" + t + " #hue-demo").each(function () {290 $(this).change(function () {291 var p = $(this).parents("table").attr("n");292 $("#module" + t + " #nav_li" + p + " span").css("color", $(this).val());293 });294 });295 $("#addAttr" + t + " .href_shop").each(function () {296 $(this).change(function () {297 var k = $(this).parents("table").attr("n");298 $("#module" + t + " #nav_li" + k + " a").attr("href", $(this).val());299 });300 });301 hrefset(t);302}303//幻灯片数据绑定304function hdpAttrBind(t) {305 n = 1;306 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +307 "<p class='increase' onclick='addHDP(this)'>增加</p></div>";308 $(divhtml).appendTo(".attribute_frame");309 var htmldiv = "";310 $("#module" + t).find("ul li").each(function () {311 var p = $(this).attr("n");312 var imgSrc = $(this).find("img").attr("src");313 var aHref = $(this).find("a").attr("href");314 var hrefval = $(this).find("a").attr("href");315 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +316 "<tr><td>幻灯片图片:</td><td><button onclick='chooseImg(this,\"HuanDeng\")' type='button' >选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +317 "<tr><td></td><td><img src='" + imgSrc + "' /></td></tr>" +318 "<tr><td></td><td style='color:#828282'>建议尺寸:750px × 400px</td></tr>" +319 "<tr><td>幻灯片链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /></td><td><select onchange='selectchg(this)'>" +320 "<option value ='/Vshop/index.aspx'>首页</option>" +321 "<option value ='/Vshop/ProductSearch.aspx'>分类页面</option>" +322 "<option value ='/Vshop/ShoppingCart.aspx'>购物车</option>" +323 "<option value ='/Vshop/ProductList.aspx'>商品列表</option>" +324 "<option value ='/Vshop/ArticleCategory.aspx'>新闻列表</option>" +325 "<option value ='/Vshop/MemberCenter.aspx'>用户中心</option>" +326 "<option value ='/Vshop/groupbuylist.aspx'>团购活动</option>" +327 "<option value ='/Vshop/CountDownproductlist.aspx'>限时限购</option>" +328 "<option value ='/Vshop/cutdownlist.aspx '>砍价活动</option>" +329 "<option value ='/Vshop/myvantages.aspx'>积分兑换</option>" +330 "<option value ='/Vshop/myredpager.aspx'>我的优惠券</option>" +331 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +332 "<option value =''>自定义链接</option>" +333 "</select></td></tr>" +334 "</table>";335 });336 $("#addAttr" + t + " p").before(htmldiv);337 $("#addAttr" + t + " .href_shop").each(function () {338 $(this).change(function () {339 var k = $(this).parents("table").attr("n");340 $("#module" + t + " #nav_li" + k + " a").attr("href", $(this).val());341 });342 });343 hrefset(t);344}345//商品列表数据绑定346function splbAttrBind(t) {347 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +348 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +349 "<tr><td align='right'>显示方式:</td><td><input type='radio' name='composition" + t + "' value='manner1' checked='checked' />小图</td><td><input type='radio' name='composition" + t + "' value='manner2' />大图</td><td><input type='radio' name='composition" + t + "' value='manner3'/>列表</td><td><input type='radio' name='composition" + t + "' value='manner4' />一大两小</td></tr>" +350 "<tr><td align='right'>显示数量:</td><td><input type='radio' name='bit" + t + "' value='6' checked='checked' />6个</td><td><input type='radio' name='bit" + t + "' value='12' />12个</td><td><input type='radio' name='bit" + t + "' value='18' />18个</td></tr>" +351 "<tr><td align='right'>字体颜色:</td><td colspan='4'><input type='text' class='form-control demo list-color' data-control='hue' value='#000'></td></tr>" +352 "<tr><td align='right'>背景颜色:</td><td colspan='4'><input type='text' id='demo-hue' class='form-control demo list-bgcolor' data-control='hue' value='#fff'></td></tr>" +353 "<tr><td align='right'>第一优先级:</td><td colspan='4'><select id='show1' name='firstPriority'>" +354 "<option value='1'>序号越大越靠前</option>" +355 "<option value='2'>最热的排在前面</option>" +356 "<option value='3'>创建时间越晚越靠前</option>" +357 "<option value='4'>创建时间越早越靠前</option>" +358 "<option value='5' selected='selected'>销量越高越靠前</option>" +359 "<option value='6'>销量越低越靠前</option>" +360 "</select></td></tr>" +361 "<tr><td align='right'>第二优先级:</td><td colspan='4'><select id='show2' name='firstPriority'>" +362 "<option value='1'>序号越大越靠前</option>" +363 "<option value='2'>最热的排在前面</option>" +364 "<option value='3' selected='selected'>创建时间越晚越靠前</option>" +365 "<option value='4'>创建时间越早越靠前</option>" +366 "<option value='5'>销量越高越靠前</option>" +367 "<option value='6'>销量越低越靠前</option>" +368 "</select></td></tr>" +369 "<tr><td align='right'>第三优先级:</td><td colspan='4'><select id='show3' name='firstPriority'>" +370 "<option value='1'>序号越大越靠前</option>" +371 "<option value='2' selected='selected'>最热的排在前面</option>" +372 "<option value='3'>创建时间越晚越靠前</option>" +373 "<option value='4'>创建时间越早越靠前</option>" +374 "<option value='5'>销量越高越靠前</option>" +375 "<option value='6'>销量越低越靠前</option>" +376 "</select></td></tr>" +377 "</table>" +378 "</div>";379 $(divhtml).appendTo(".attribute_frame");380 $("#addAttr" + t + " .list-bgcolor").val(RGBToHex($("#module" + t + " ul").eq(0).css("background-color")));381 $("#addAttr" + t + " .list-color").val(RGBToHex($("#module" + t + " ul li p").css("color")));382 $("#addAttr" + t + " .list-bgcolor").change(function () {383 var m = $(this).parents("table").parent().attr("i");384 $("#module" + m + " ul").css("background", $(this).val());385 });386 $("#addAttr" + t + " .list-color").change(function () {387 var m = $(this).parents("table").parent().attr("i");388 $("#module" + m + " ul p").css("color", $(this).val());389 });390 if ($("#module" + t).find("ul").is(".manner1")) {391 $("#addAttr" + t + " input[value='manner1']").attr("checked", "checked");392 } else if ($("#module" + t).find("ul").is(".manner2")) {393 $("#addAttr" + t + " input[value='manner2']").attr("checked", "checked");394 } else if ($("#module" + t).find("ul").is(".manner3")) {395 $("#addAttr" + t + " input[value='manner3']").attr("checked", "checked");396 } else {397 $("#addAttr" + t + " input[value='manner4']").attr("checked", "checked");398 }399 if ($("#module" + t + " ul li").length == 6) {400 $("#addAttr" + t + " input[value='6']").attr("checked", "checked");401 } else if ($("#module" + t + " ul li").length == 12) {402 $("#addAttr" + t + " input[value='12']").attr("checked", "checked");403 } else {404 $("#addAttr" + t + " input[value='18']").attr("checked", "checked");405 }406 var sorts = $("#module" + t).attr("sort").split('♦');407 $("#show1 option[value=" + sorts[0] + "]").attr("selected", "selected");408 $("#show2 option[value=" + sorts[1] + "]").attr("selected", "selected");409 $("#show3 option[value=" + sorts[2] + "]").attr("selected", "selected");410}411//空白数据绑定412function kbAttrBind(t) {413 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +414 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +415 "<tr><td align='right'>高度:</td><td><div class='sliding'></div></td><td width='30px'><span class='amount'></span>px</td></tr>" +416 "</table>" +417 "</div>";418 $(divhtml).appendTo(".attribute_frame");...

Full Screen

Full Screen

V_databind.js

Source:V_databind.js Github

copy

Full Screen

1$(function(){2 $(".gridly").children("div").each(function(){3 var t=$(this).attr("i");4 switch($(this).attr("name")){5 case "VDaoHang":6 dhAttrBind(t);7 break;8 case "VWenBen":9 wbAttrBind(t);10 break;11 case "VGunDong":12 gdAttrBind(t);13 break;14 case "VTuPian":15 tpAttrBind(t);16 break;17 case "VHuanDeng":18 hdpAttrBind(t);19 break;20 case "VBeiJing":21 bgAttrBind(t);22 break;23 }24 $(this).click(function () {25 integrate(this,t);26 });27 //高度28 if ($("#module" + t).attr("name") == "VGunDong") {29 var dhheight = $("#module" + t + " .wb_txt").height();30 $("#addAttr" + t + " .sliding").slider({31 range: "max",32 min: 0,33 max: 100,34 value: dhheight,35 slide: function (event, ui) {36 $("#addAttr" + t + " .amount_height").text(ui.value);37 $("#module" + j).css("height", ui.value);38 $("#module" + t + " .wb_txt").css("height", ui.value);39 $("#module" + t + " .wb_txt").css("line-height", ui.value + "px");40 }41 });42 $("#addAttr" + t + " .amount_height").text($("#addAttr" + t + " .sliding").slider("value"));43 $("#module" + t + " .wb_txt").css("height", $("#addAttr" + t + " .sliding").slider("value"));44 $("#module" + t + " .wb_txt").css("line-height", $("#addAttr" + t + " .sliding").slider("value") + "px");45 } else {46 $("#module" + t + " ul").height("100%");47 var dhheight = $("#module" + t).height() / ($("#module" + t).parent().height()) * 100;48 $("#addAttr" + t + " .sliding").slider({49 range: "max",50 min: 0,51 max: 300,52 value: dhheight,53 slide: function (event, ui) {54 $("#addAttr" + t + " .amount_height").text(ui.value);55 $("#module" + t).css("height", ui.value + "%");56 $("#module" + t).css("line-height", ui.value + "%");57 percentage(t);58 }59 });60 $("#addAttr" + t + " .amount_height").text($("#addAttr" + t + " .sliding").slider("value"));61 $("#module" + t).css("height", $("#addAttr" + t + " .sliding").slider("value") + "%");62 $("#module" + t).css("line-height", $("#addAttr" + t + " .sliding").slider("value") + "%");63 }64 //宽度65 var dhwidth = $("#module" + t).width() / ($("#module" + t).parent().width()) * 100;66 $("#addAttr" + t + " .widthing").slider({67 range: "max",68 min: 20,69 max: 100,70 value: dhwidth,71 slide: function (event, ui) {72 $("#addAttr" + t + " .amount_width").text(ui.value);73 $("#module" + t).css("width", ui.value + "%");74 }75 });76 $("#addAttr" + t + " .amount_width").text($("#addAttr" + t + " .widthing").slider("value"));77 $("#module" + t).css("width", $("#addAttr" + t + " .widthing").slider("value") + "%");78 percentage(t);79 });80 choseColor();81})82//rgb(10进制)转#fff(16进制)的方法83function RGBToHex(rgb) {84 var regexp = /^rgb\(([0-9]{0,3})\,\s([0-9]{0,3})\,\s([0-9]{0,3})\)/g;85 var re = rgb.replace(regexp, "$1 $2 $3").split(" ");//利用正则表达式去掉多余的部分86 var hexColor = "#";87 var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];88 for (var i = 0; i < 3; i++) {89 var r = null;90 var c = re[i];91 var hexAr = [];92 while (c > 16) {93 r = c % 16;94 c = (c / 16) >> 0;95 hexAr.push(hex[r]);96 }97 hexAr.push(hex[c]);98 hexColor += hexAr.reverse().join('');99 }100 return hexColor;101}102//导航数据绑定103function dhAttrBind(t) {104 n = 1;105 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +106 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>"+107 "<tr><td align='right'>显示方式:</td><td><input type='radio' name='way' value='one' />一行一列</td><td><input type='radio' name='way' value='two' />一行两列</td><td><input type='radio' name='way' value='three' />一行三列</td><td><input type='radio' name='way' value='four' />一行四列</td></tr>" +108 "<tr><td align='right'>显示设置:</td><td><input type='radio' name='displaySet' value='1' />图片</td><td><input type='radio' name='displaySet' value='2' />文字</td></tr>" +109 "<tr><td align='right'>高度设置:</td><td colspan='3'><div class='sliding'></div></td><td><span class='amount_height'></span>%</td></tr>" +110 "<tr><td align='right'>宽度设置:</td><td colspan='3'><div class='widthing'></div></td><td><span class='amount_width'></span>%</td></tr>" +111 "</table><p class='increase' onclick='addDH(this)'>增加</p></div>";112 $(divhtml).appendTo(".attribute_frame");113 if ($("#module" + t).find("ul").is(".dh_style4")) {114 $("#addAttr" + t + " input[value='four']").attr("checked", "checked");115 } else if ($("#module" + t).find("ul").is(".dh_style3")) {116 $("#addAttr" + t + " input[value='three']").attr("checked", "checked");117 } else if ($("#module" + t).find("ul").is(".dh_style2")) {118 $("#addAttr" + t + " input[value='two']").attr("checked", "checked");119 }else{120 $("#addAttr" + t + " input[value='one']").attr("checked", "checked");121 }122 if ($("#module" + t).find("ul li a img").first().css("display") == "block" && $("#module" + t).find("ul li a span").first().css("display")=="none") {123 $("#addAttr" + t + " input[value='1']").attr("checked", "checked");124 } else if ($("#module" + t).find("ul li a img").first().css("display") == "none" && $("#module" + t).find("ul li a span").first().css("display") == "block") {125 $("#addAttr" + t + " input[value='2']").attr("checked", "checked");126 } else {127 $("#addAttr" + t + " input[value='3']").attr("checked", "checked");128 }129 var htmldiv = "";130 $("#module" + t).find("ul li").each(function () {131 var p = $(this).attr("n");132 var fontColor = $(this).find("a span").css("color");133 var bgColor = $(this).find("a").css("background-color");134 var imgSrc = $(this).find("a img").attr("src");135 var hrefval = $(this).find("a").attr("href");136 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +137 "<tr><td>导航图片:</td><td><button type='button' onclick='chooseImg(this,\"VDaoHang\")'>选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +138 "<tr><td></td><td><img src='" + imgSrc + "'></td></tr>" +139 "<tr><td></td><td style='color:#828282'>建议尺寸:150px × 150px</td></tr>" +140 "<tr><td>导航名称:</td><td colspan='2'><input type='text' value='" + $(this).find("span").text() + "' class='name_shop' /><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +141 "<tr><td>背景颜色:</td><td><input type='text' id='demo-hue' class='form-control demo' data-control='hue' value='" + RGBToHex(bgColor) + "'></td></tr>" +142 "<tr><td>导航链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /></td><td><select onchange='selectchg(this)'>" +143 "<option value ='/Vshop/WgwArticleCategory.aspx'>分类列表</option>" +144 "<option value ='2'>文章列表</option>" +145 "<option value ='1'>文章详情</option>" +146 "<option value ='3'>二级页链接</option>" +147 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +148 "<option value =''>自定义链接</option>" +149 "</select></td></tr>" +150 "</table>";151 });152 $("#addAttr" + t + " p").before(htmldiv);153 $("#addAttr" + t + " .name_shop").each(function () {154 $(this).change(function () {155 var p = $(this).parents("table").attr("n");156 $("#module" + t + " #nav_li" + p + " span").html($(this).val());157 });158 });159 $("#addAttr" + t + " #hue-demo").each(function () {160 $(this).change(function () {161 var p = $(this).parents("table").attr("n");162 $("#module" + t + " #nav_li" + p + " span").css("color", $(this).val());163 });164 });165 $("#addAttr" + t + " .href_shop").each(function () {166 $(this).change(function () {167 var p = $(this).parents("table").attr("n");168 $("#module" + t + " #nav_li" + p + " a").attr("href", $(this).val());169 });170 });171 $("#addAttr" + t + " #demo-hue").each(function () {172 $(this).change(function () {173 var p = $(this).parents("table").attr("n");174 $("#module" + t + " #nav_li" + p + " a").css("background-color", $(this).val());175 });176 });177 hrefset(t);178}179function hrefset(t) {180 $("#module" + t + " ul li").each(function () {181 var p = $(this).attr("n");182 if($(this).find("a").attr("href") == "/Vshop/WgwArticleCategory.aspx"){183 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/WgwArticleCategory.aspx']").attr("selected", "selected");184 } else if ($(this).find("a").attr("href").indexOf("WgwArticles") > 0) {185 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='2']").attr("selected", "selected");186 } else if ($(this).find("a").attr("href").indexOf("WgwArticleDetails") > 0) {187 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='1']").attr("selected", "selected");188 } else if ($(this).find("a").attr("href").indexOf("SecondPage") > 0) {189 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='3']").attr("selected", "selected");190 } else if ($(this).find("a").attr("href") == "/Vshop/SaleService.aspx") {191 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/SaleService.aspx']").attr("selected", "selected");192 } else {193 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='']").attr("selected", "selected");194 }195 });196}197//文本数据绑定198function wbAttrBind(t) {199 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +200 "<table class='nav_li_attr' cellpadding='0' cellspacing='0' border='0'>" +201 "<tr><td><script id='editor" + t + "' type='text/plain' style='width:500px;min-height:200px;'>" + $('#module' + t + ' .wb_txt').html() + "</script></td></tr>" +202 "</table>" +203 "</div>";204 $(divhtml).appendTo(".attribute_frame");205 EditorU(t);206}207//搜索数据绑定208function ssAttrBind(t) {209 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +210 "<p>可随意插入任何页面和位置,方便会员快速搜索商品。</p>" +211 "</div>";212 $(divhtml).appendTo(".attribute_frame");213}214//滚动公告数据绑定215function gdAttrBind(t) {216 var fontColor = $("#module" + t + " .wb_txt a").css("color");217 var aHref = $("#module" + t + " .wb_txt a").attr("href");218 var atxt = $("#module" + t + " .wb_txt #scroll_begin").text().trim();219 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +220 "<table class='nav_li_attr' cellpadding='0' cellspacing='0' border='0'>" +221 "<tr><td>文本内容:</td><td><textarea rows='3' cols='50' >" + atxt + "</textarea></td></tr>" +222 "<tr><td>文本链接:</td><td><input type='text' class='href_wb' value='"+aHref+"'></td></tr>" +223 "<tr><td>文本颜色:</td><td><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +224 "</table>" +225 "</div>";226 $(divhtml).appendTo(".attribute_frame");227 ScrollImgLeft(t);228}229//图片数据绑定230function tpAttrBind(t) {231 n = 1;232 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +233 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +234 "<tr><td align='right'>显示方式:</td><td><input type='radio' name='mode' value='two' />一行一张</td><td><input type='radio' name='mode' value='three' />一行两张</td><td><input type='radio' name='mode' value='four' />一行三张</td></tr>" +235 "<tr><td align='right'>显示文字:</td><td><input type='radio' name='txt' value='yes' />是</td><td><input type='radio' name='txt' value='no' />否</td><td></td></tr>" +236 "</table>" +237 "<p class='increase' onclick='addTP(this)'>增加</p>" +238 "</div>";239 $(divhtml).appendTo(".attribute_frame");240 if ($("#module" + t).find("ul").is(".tp_style1")) {241 $("#addAttr" + t + " input[value='two']").attr("checked", "checked");242 } else if ($("#module" + t).find("ul").is(".tp_style2")) {243 $("#addAttr" + t + " input[value='three']").attr("checked", "checked");244 } else {245 $("#addAttr" + t + " input[value='four']").attr("checked", "checked");246 }247 if ($("#module" + t).find("ul li span").first().css("display") == "block") {248 $("#addAttr" + t + " input[value='yes']").attr("checked", "checked");249 } else {250 $("#addAttr" + t + " input[value='no']").attr("checked", "checked");251 }252 var htmldiv = "";253 $("#module" + t).find("ul li").each(function () {254 var p = $(this).attr("n");255 var atxt = $(this).find("span").text();256 var fontColor = $(this).find("span").css("color");257 var imgSrc = $(this).find("img").attr("src");258 var aHref = $("#module" + t + " .wb_txt a").attr("href");259 var hrefval = $(this).find("a").attr("href");260 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +261 "<tr><td>图片:</td><td width='238px'><button onclick='chooseImg(this,\"TuPian\")' type='button' >选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +262 "<tr><td></td><td><img src='" + imgSrc + "'/></td></tr>" +263 "<tr><td>文字说明:</td><td><input type='text' value='" + atxt + "' class='name_shop' /></td></tr>" +264 "<tr><td>字体颜色:</td><td><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +265 "<tr><td>图片链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /><td><select onchange='selectchg(this)'>" +266 "<option value ='/Vshop/WgwArticleCategory.aspx'>分类列表</option>" +267 "<option value ='2'>文章列表</option>" +268 "<option value ='1'>文章详情</option>" +269 "<option value ='3'>二级页链接</option>" +270 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +271 "<option value =''>自定义链接</option>" +272 "</td></select></td></tr>" +273 "</table>";274 });275 $("#addAttr" + t + " p").before(htmldiv);276 $("#addAttr" + t + " .name_shop").each(function () {277 $(this).change(function () {278 var p = $(this).parents("table").attr("n");279 $("#module" + t + " #nav_li" + p + " span").html($(this).val());280 });281 });282 $("#addAttr" + t + " #hue-demo").each(function () {283 $(this).change(function () {284 var p = $(this).parents("table").attr("n");285 $("#module" + t + " #nav_li" + p + " span").css("color", $(this).val());286 });287 });288 $("#addAttr" + t + " .href_shop").each(function () {289 $(this).change(function () {290 var p = $(this).parents("table").attr("n");291 $("#module" + t + " #nav_li" + p + " a").attr("href", $(this).val());292 });293 });294 hrefset(t);295}296//幻灯片数据绑定297function hdpAttrBind(t) {298 n = 1;299 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +300 "<p class='increase' onclick='addHDP(this)'>增加</p></div>";301 $(divhtml).appendTo(".attribute_frame");302 var htmldiv = "";303 $("#module" + t).find("ul li").each(function () {304 var p = $(this).attr("n");305 var imgSrc = $(this).find("img").attr("src");306 var aHref = $(this).find("a").attr("href");307 var hrefval = $(this).find("a").attr("href");308 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +309 "<tr><td>幻灯片图片:</td><td><button onclick='chooseImg(this,\"HuanDeng\")' type='button' >选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +310 "<tr><td></td><td><img src='" + imgSrc + "' /></td></tr>" +311 "<tr><td></td><td style='color:#828282'>建议尺寸:750px × 400px</td></tr>" +312 "<tr><td>幻灯片链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /></td><td><select onchange='selectchg(this)'>" +313 "<option value ='/Vshop/WgwArticleCategory.aspx'>分类列表</option>" +314 "<option value ='2'>文章列表</option>" +315 "<option value ='1'>文章详情</option>" +316 "<option value ='3'>二级页链接</option>" +317 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +318 "<option value =''>自定义链接</option>" +319 "</select></td></tr>" +320 "</table>";321 });322 $("#addAttr" + t + " p").before(htmldiv);323 $("#addAttr" + t + " .href_shop").each(function () {324 $(this).change(function () {325 var k = $(this).parents("table").attr("n");326 $("#module" + t + " #nav_li" + k + " a").attr("href", $(this).val());327 });328 });329 hrefset(t);330}331//空白数据绑定332function kbAttrBind(t) {333 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +334 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +335 "<tr><td align='right'>高度:</td><td><div class='sliding'></div></td><td width='30px'><span class='amount_height'></span>px</td></tr>" +336 "</table>" +337 "</div>";338 $(divhtml).appendTo(".attribute_frame");339}340//背景数据绑定341function bgAttrBind(t) {342 var htmldiv = "";343 $("#module" + t).find("img").each(function () {344 var imgSrc = $(this).attr("src");345 htmldiv += "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +346 "<table class='nav_li_attr' cellpadding='0' cellspacing='0' border='0'>" +347 "<tr><td>幻灯片图片:</td><td><button onclick='chooseImg(this,\"BeiJing\")' type='button' >选择图片</button></td></tr>" +348 "<tr><td></td><td><img src='" + imgSrc + "' /></td></tr>" +349 "<tr><td></td><td style='color:#828282'>建议尺寸:750px × 400px</td></tr>" +350 "<tr><td>幻灯片链接:</td><td><input type='text' value='幻灯片链接' class='href_shop' /></td></tr>" +351 "</table>" +352 "</div>";353 });354 $(htmldiv).appendTo(".attribute_frame");...

Full Screen

Full Screen

Vote-databind.js

Source:Vote-databind.js Github

copy

Full Screen

1$(function(){2 $(".gridly").children("div").each(function(){3 var t=$(this).attr("i");4 switch($(this).attr("name")){5 case "ShuRuKuang":6 wzAttrBind(t);7 break;8 case "ShiJian":9 rqAttrBind(t);10 break;11 case "XuanXiang":12 wbtpAttrBind(t);13 break;14 case "WenBen":15 wbAttrBind(t);16 break;17 case "TuPian":18 tpAttrBind(t);19 break;20 }21 $(this).click(function () {22 integrate(this,t);23 });24 });25 choseColor();26})27//rgb(10进制)转#fff(16进制)的方法28function RGBToHex(rgb) {29 var regexp = /^rgb\(([0-9]{0,3})\,\s([0-9]{0,3})\,\s([0-9]{0,3})\)/g;30 var re = rgb.replace(regexp, "$1 $2 $3").split(" ");//利用正则表达式去掉多余的部分31 var hexColor = "#";32 var hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];33 for (var i = 0; i < 3; i++) {34 var r = null;35 var c = re[i];36 var hexAr = [];37 while (c > 16) {38 r = c % 16;39 c = (c / 16) >> 0;40 hexAr.push(hex[r]);41 }42 hexAr.push(hex[c]);43 hexColor += hexAr.reverse().join('');44 }45 return hexColor;46}47//文字数据绑定48function wzAttrBind(t) {49 n = 1;50 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +51 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +52 "<tr><td colspan='2' align='center'><h4>文字控件</h4><td></tr>" +53 "<tr><td align='right'>标题:</td><td><input type='text' name='title' value='" + $("#module" + t + " h3").html() + "' maxlength='100'></td></tr>" +54 "<tr><td align='right'>副标题:</td><td><input type='text' name='subtitle' value='" + $("#module" + t + " h4").html() + "' maxlength='100'></td></tr>" +55 "<tr><td align='right'>文本框高度:</td><td><label><input type='radio' name='input_type" + t + "' value='0'>单行</label><label><input type='radio' name='input_type" + t + "' value='1'>多行</label></td></tr>" +56 "<tr><td align='right'>是否必填:</td><td><label><input name='required" + t + "' type='checkbox'>必须填写</label></td></tr>" +57 "</table>" +58 "</div>";59 $(divhtml).appendTo(".attribute_frame");60 if ($("#module" + t + " input").attr("type") == "text") {61 $("#addAttr" + t + " input[value='0']").attr("checked", "checked");62 }else{63 $("#addAttr" + t + " input[value='1']").attr("checked", "checked");64 }65 if ($("#module" + t).attr("bt") == "true") {66 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", true);67 $("#module" + t + " h3").after("<span class='must'>(必填)</span>");68 } else {69 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", false);70 $("#module" + t + " .must").remove();71 }72}73//日期数据绑定74function rqAttrBind(t) {75 n = 1;76 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +77 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +78 "<tr><td colspan='2' align='center'><h4>日期控件</h4><td></tr>" +79 "<tr><td align='right'>标题:</td><td><input type='text' name='title' value='" + $("#module" + t + " h3").html() + "' maxlength='100'></td></tr>" +80 "<tr><td align='right'>副标题:</td><td><input type='text' name='subtitle' value='" + $("#module" + t + " h4").html() + "' maxlength='100'></td></tr>" +81 "<tr><td align='right'>是否必填:</td><td><label><input name='required" + t + "' type='checkbox' value='0'>必须填写</label></td></tr>" +82 "</table>" +83 "</div>";84 $(divhtml).appendTo(".attribute_frame");85 if ($("#module" + t).attr("bt") == "true") {86 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", true);87 $("#module" + t + " h3").after("<span class='must'>(必填)</span>");88 } else {89 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", false);90 $("#module" + t + " .must").remove();91 }92}93//投票模块数据绑定94function wbtpAttrBind(t) {95 n = 1;96 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +97 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +98 "<tr><td colspan='2' align='center'><h4>文本投票</h4><td></tr>" +99 "<tr><td align='right'>标题:</td><td><input type='text' name='title' value='" + $("#module" + t + " h3").html() + "' maxlength='100'></td></tr>" +100 "<tr><td align='right'>副标题:</td><td><input type='text' name='subtitle' value='" + $("#module" + t + " h4").html() + "' maxlength='100'></td></tr>" +101 "<tr><td align='right'>单选/多选:</td><td><label><input type='radio' name='input_choice" + t + "' value='0'>单选</label><label><input type='radio' name='input_choice" + t + "' value='1'>多选</label></td></tr>" +102 "<tr><td align='right'>是否必填:</td><td><label><input name='required" + t + "' type='checkbox' value=''>必须填写</label></td></tr>" +103 "<tr><td colspan='3' align='center' class='line-bg'><span>选项</span></td></tr>" +104 "</table>" +105 "<p class='increase' onclick='addWBTP(this)'>增加</p>" +106 "</div>";107 $(divhtml).appendTo(".attribute_frame");108 if ($("#module" + t).attr("bt") == "true") {109 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", true);110 $("#module" + t + " h3").after("<span class='must'>(必填)</span>");111 } else {112 $("#addAttr" + t + " input[name='required" + t + "']").attr("checked", false);113 $("#module" + t + " .must").remove();114 }115 if ($("#module" + t + " ul li input").attr("type") == "radio") {116 $("#addAttr" + t + " input[value='0']").attr("checked", true);117 $("#module" + t + " ul li").css("background-position-y", "10px");118 } else {119 $("#addAttr" + t + " input[value='1']").attr("checked", true);120 $("#module" + t + " ul li").css("background-position-y", "-29px");121 }122 var htmldiv = "";123 $("#module" + t + " ul li").each(function () {124 var p = $(this).attr("n");125 htmldiv += "<tr id='nav_li_attr" + p + "' n='" + p + "'><td align='right'>选项名称:</td><td><input type='text' name='options' value='" + $(this).find("span").html() + "' maxlength='100'></td><td><div class='changeBtn' style='width: 80px'><span onclick='voteDel(this)'>删除</span></div></td></tr>";126 });127 $(htmldiv).appendTo("#addAttr" + t + " table");128}129//图片数据绑定130function tpAttrBind(t) {131 n = 1;132 var divhtml = "<div id='addAttr" + t + "' class='addAttr' i='" + t + "'>" +133 "<table class='nature' cellpadding='0' cellspacing='0' border='0'>" +134 "<tr><td align='right'>显示文字:</td><td><input type='radio' name='txt' value='yes' />是</td><td><input type='radio' name='txt' value='no' />否</td><td></td></tr>" +135 "</table>" +136 "<p class='increase' onclick='addTP(this)'>增加</p>" +137 "</div>";138 $(divhtml).appendTo(".attribute_frame");139 if ($("#module" + t).find("ul li span").first().css("display") == "block") {140 $("#addAttr" + t + " input[value='yes']").attr("checked", "checked");141 } else {142 $("#addAttr" + t + " input[value='no']").attr("checked", "checked");143 }144 var htmldiv = "";145 $("#module" + t).find("ul li").each(function () {146 var p = $(this).attr("n");147 var atxt = $(this).find("span").text();148 var fontColor = $(this).find("span").css("color");149 var imgSrc = $(this).find("img").attr("src");150 var aHref = $("#module" + t + " .wb_txt a").attr("href");151 var hrefval = $(this).find("a").attr("href");152 htmldiv += "<table id='nav_li_attr" + p + "' class='nav_li_attr' n='" + p + "' cellpadding='0' cellspacing='0' border='0'>" +153 "<tr><td>图片:</td><td width='238px'><button onclick='chooseImg(this,\"TuPian\")' type='button' >选择图片</button></td><td><div class='changeBtn'><span onclick='moveUp(this)'>上移</span><span onclick='moveDwon(this)'>下移</span><span onclick='moveDel(this)'>删除</span></div></td></tr>" +154 "<tr><td></td><td><img src='" + imgSrc + "'/></td></tr>" +155 "<tr><td>文字说明:</td><td><input type='text' value='" + atxt + "' class='name_shop' /></td></tr>" +156 "<tr><td></td><td><input type='text' id='hue-demo' class='form-control demo' data-control='hue' value='" + RGBToHex(fontColor) + "'></td></tr>" +157 "<tr><td>图片链接:</td><td><input type='text' value='" + hrefval + "' class='href_shop' /><td><select onchange='selectchg(this)'>" +158 "<option value ='/Vshop/index.aspx'>首页</option>" +159 "<option value ='/Vshop/ProductSearch.aspx'>分类页面</option>" +160 "<option value ='/Vshop/ShoppingCart.aspx'>购物车</option>" +161 "<option value ='/Vshop/ProductList.aspx'>商品列表</option>" +162 "<option value ='/Vshop/ArticleCategory.aspx'>新闻列表</option>" +163 "<option value ='/Vshop/MemberCenter.aspx'>用户中心</option>" +164 "<option value ='/Vshop/groupbuylist.aspx'>团购活动</option>" +165 "<option value ='/Vshop/CountDownproductlist.aspx'>限时限购</option>" +166 "<option value ='/Vshop/cutdownlist.aspx '>砍价活动</option>" +167 "<option value ='/Vshop/myvantages.aspx'>积分兑换</option>" +168 "<option value ='/Vshop/myredpager.aspx'>我的优惠券</option>" +169 "<option value ='/Vshop/SaleService.aspx'>售后服务</option>" +170 "<option value =''>自定义链接</option>" +171 "</td></select></td></tr>" +172 "</table>";173 });174 $("#addAttr" + t + " p").before(htmldiv);175 $("#addAttr" + t + " .name_shop").each(function () {176 $(this).change(function () {177 var p = $(this).parents("table").attr("n");178 alert(t);179 alert(p);180 $("#module" + t + " #nav_li" + p + " span").html($(this).val());181 });182 });183 $("#addAttr" + t + " #hue-demo").each(function () {184 $(this).change(function () {185 var p = $(this).parents("table").attr("n");186 $("#module" + t + " #nav_li" + p + " span").css("color", $(this).val());187 });188 });189 $("#addAttr" + t + " .href_shop").each(function () {190 $(this).change(function () {191 var k = $(this).parents("table").attr("n");192 $("#module" + t + " #nav_li" + k + " a").attr("href", $(this).val());193 });194 });195 hrefset(t);196}197function hrefset(t) {198 $("#module" + t + " ul li").each(function () {199 var p = $(this).attr("n");200 switch ($(this).find("a").attr("href")) {201 case "/Vshop/index.aspx":202 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/index.aspx']").attr("selected", "selected");203 break;204 case "/Vshop/ProductSearch.aspx":205 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ProductSearch.aspx']").attr("selected", "selected");206 break;207 case "/Vshop/ShoppingCart.aspx":208 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ShoppingCart.aspx']").attr("selected", "selected");209 break;210 case "/Vshop/ProductList.aspx":211 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ProductList.aspx']").attr("selected", "selected");212 break;213 case "/Vshop/ArticleCategory.aspx":214 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/ArticleCategory.aspx']").attr("selected", "selected");215 break;216 case "/Vshop/MemberCenter.aspx":217 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/MemberCenter.aspx']").attr("selected", "selected");218 break;219 case "/Vshop/groupbuylist.aspx":220 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/groupbuylist.aspx']").attr("selected", "selected");221 break;222 case "/Vshop/CountDownproductlist.aspx":223 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/CountDownproductlist.aspx']").attr("selected", "selected");224 break;225 case "/Vshop/cutdownlist.aspx":226 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/cutdownlist.aspx']").attr("selected", "selected");227 break;228 case "/Vshop/myvantages.aspx":229 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/myvantages.aspx']").attr("selected", "selected");230 break;231 case "/Vshop/myredpager.aspx":232 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/myredpager.aspx']").attr("selected", "selected");233 break;234 case "/Vshop/SaleService.aspx":235 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='/Vshop/SaleService.aspx']").attr("selected", "selected");236 break;237 default:238 $("#addAttr" + t + " #nav_li_attr" + p + " select option[value ='']").attr("selected", "selected");239 }240 });...

Full Screen

Full Screen

cart.js

Source:cart.js Github

copy

Full Screen

1$(function(){2 /*---------判断分类cat_id是否传入并获取-----------*/3 if(getCookie("goCartCat_id") !== undefined) {4 var cat_Id = getCookie("goCartCat_id");5 /*----------获取cookie中的商品id及对应的商品数量------判断商品种类及数量不为空的情况下,请求数据--------*/6 if(getCookie("goCart") !="{}"){7 $.ajax({8 type:"get",9 url:"http://h6.duchengjiu.top/shop/api_goods.php",10 data:{cat_id:cat_Id,pagesize:120},11 async:true,12 success:function(data){13 var obj = JSON.parse(getCookie("goCart"));14 var data = data.data;15 var str = "";16 var titStr="";17 var oAll=0;18 /*----遍历数据并且与cookie中的商品id比对,相等的话加载出该条数据----*/19 for(var i =0;i<data.length;i++){20 for (var attr in obj ) {21 if(attr==data[i].goods_id){22 oAll+= obj[attr]*data[i].price;23 str+="<li><div class='single'><input type='checkbox'></div><div class='cartImg'><img src='"+data[i].goods_thumb+"'/></div><div class='cartInfo'><a href='#'>"+data[i].goods_name+"</a><p>"+data[i].goods_desc+"</p></div><div class='cartPrice'>"+data[i].price+"</div><div class='cartCount'><span><span class='decAttr' data-id='"+data[i].goods_id+"'>-</span><strong>"+obj[attr]+"</strong><span class='addAttr' data-id='"+data[i].goods_id+"'>+</span></span></div><div data-price='"+data[i].price+"' class='allPrice'>"+data[i].price*obj[attr]+".00</div><div class='cartDelete'><a data-id='"+data[i].goods_id+"' class='delBtn'>删除</a><a>移入我的收藏</a></div></li>";24 titStr = "<div class='titPrice'><div><label for=''><input type='checkbox' id='checkOther'>反选</label></div><div class='tot'>总计:¥:<i class='totP'>"+oAll+"</i></div><div class='pay'>结算</div></div>";25 }26 }27 }28 $("#myCart ul")[0].innerHTML+=str; 29 $("#myCart")[0].innerHTML+=titStr; 30 for(var i =0;i<$(".decAttr").length;i++){31 32 $(".allPrice")[i].index =i;33 var $decAttr = $(".decAttr");34 $decAttr[i].index=i;35 //-----------------------点击商品数量-1----------最小为136 $decAttr[i].onclick=function(){37 $decAttr[this.index].parentNode.parentNode.nextSibling.innerHTML="";38 var price= $($decAttr[this.index].parentNode.parentNode.nextSibling).attr("data-price");39 var decId =$($decAttr[this.index]).attr("data-id") ;40 obj[decId]--;41 if(obj[decId]<=1){42 obj[decId]=1;43 $decAttr[this.index].parentNode.children[1].innerHTML=obj[decId];44 $decAttr[this.index].parentNode.parentNode.nextSibling.innerHTML=Number(obj[decId])*Number(price)+".00";45 }46 $decAttr[this.index].parentNode.children[1].innerHTML=obj[decId];47 $decAttr[this.index].parentNode.parentNode.nextSibling.innerHTML=Number(obj[decId])*Number(price)+".00";48 console.log(obj[decId])49 50 objToStr = JSON.stringify(obj);51 setCookie("goCart",objToStr,7)52 var tot = 0;53 for(var i=0;i<$(".allPrice").length;i++){54 var tot=tot+Number($(".allPrice")[i].innerHTML);55 }56 $(".totP")[0].innerHTML=tot;57 }58 var $addAttr = $(".addAttr");59 $addAttr[i].index=i;60 //-----------------------点击商品数量+1------------最大为2061 $addAttr[i].onclick=function(){62 var price= $($addAttr[this.index].parentNode.parentNode.nextSibling).attr("data-price");63 $addAttr[this.index].parentNode.parentNode.nextSibling.innerHTML="";64 var addId =$($addAttr[this.index]).attr("data-id") ;65 obj[addId]++;66 $addAttr[this.index].parentNode.parentNode.nextSibling.innerHTML=obj[addId]*price+".00";67 $addAttr[this.index].parentNode.children[1].innerHTML=obj[addId];68 if(obj[addId]>20){69 obj[addId]=20;70 }71 objToStr = JSON.stringify(obj);72 setCookie("goCart",objToStr,7);73 var tot = 0;74 for(var i=0;i<$(".allPrice").length;i++){75 var tot=tot+Number($(".allPrice")[i].innerHTML);76 }77 $(".totP")[0].innerHTML=tot;78 }79 }80 81 82 83 /*--------删除商品-------------*/84 var $delBtn = $(".delBtn");85 var obj = JSON.parse(getCookie("goCart"));86 for(var j =0;j<$delBtn.length;j++){87 $delBtn[j].index = j;88 $delBtn[j].onclick=function(){89 var obj = JSON.parse(getCookie("goCart"));90// window.location.reload();91 var delProId = $($delBtn[this.index]).attr("data-id");92 $delBtn[this.index].parentNode.parentNode.remove();93 console.log(attr)94 for(var delattr in obj){95 96 if(delProId==delattr){97// console.log(delattr+"=delattr"+"--------"+delProId+"==delProId")98 delete obj[delattr];99 }100 }101 console.log(obj)102 var objStr = JSON.stringify(obj);103 setCookie("goCart",objStr,7);104 //--------判断购物车商品为0重新加载页面--------------105 getCookie("goCart");106 if(getCookie("goCart")=="{}"){107 window.location.reload();108 }109 }110 }111 112 function checked(){113 $("#checkAll").click(function(){114 $("ul input").prop("checked",$(this).prop("checked"));115 })116 $("ul input").click(function(){117 if($("ul input:checked").length == $("ul input").length){118 $("#checkAll").prop("checked",true);119 }else{120 $("#checkAll").prop("checked",false);121 }122 123 })124 $("#checkOther").click(function(){125 $("ul input").each(function(){126 $(this).prop("checked",!$(this).prop("checked"));127 })128 })129 }130 checked();131 }132 });133 }else{134 135 $("#myCart")[0].innerHTML="<h2 class='empty'>购物车空空如也~赶快去 <span>&gt;</span><a href='../htmls/productList.html'>购物</a>吧</h2>";136 }137 }...

Full Screen

Full Screen

xml.js

Source:xml.js Github

copy

Full Screen

...20export function addMetatypeAttr(metatype, id, desc) {21 const metadata = findChild(metatype, 'metatype:MetaData');22 const ocd = findChild(metadata, 'OCD');23 const ad = addChild(ocd, 'AD');24 addAttr(ad, 'id', id);25 addAttr(ad, 'type', TYPES[desc.type]);26 addAttr(ad, 'name', desc.name || id);27 if (desc.description !== undefined) {28 addAttr(ad, 'description', desc.description);29 }30 addAttr(ad, 'cardinality', desc.repeatable ? -32767 : 0);31 if (desc.required !== undefined) {32 addAttr(ad, 'required', desc.required);33 }34 if (desc.default !== undefined) {35 addAttr(ad, 'default', desc.default);36 }37 if (desc.options) {38 Object.entries(desc.options).forEach(([value, label]) => {39 const option = addChild(ad, 'Option');40 addAttr(option, 'label', label);41 addAttr(option, 'value', value);42 });43 }44}45/**46 *47 * @param {object} xml48 * @param {string} localization49 */50export function addMetatypeLocalization(xml, localization) {51 const metadata = findChild(xml, 'metatype:MetaData');52 addAttr(metadata, 'localization', localization);53}54/**55 * @param {string} id id of configuration56 * @param {string} name human readable name of configuration57 * @return {object}58 */59export function createMetatype(id, name) {60 return xml2js(`<?xml version="1.0" encoding="UTF-8"?>61<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.1.0">62 <OCD name="${name}" id="${id}"/>63 <Designate pid="${id}">64 <Object ocdref="${id}"/>65 </Designate>66</metatype:MetaData>`);67}68/**69 * Format an XML object and return it as a string.70 * @param {object} xml71 * @return {string}72 */73export function format(xml) {74 return js2xml(xml, {spaces: 2});75}76/**77 * Add an attribute to an XML node.78 * @param {object} node79 * @param {string} name80 * @param {string} value81 */82function addAttr(node, name, value) {83 node.attributes = node.attributes || {};84 node.attributes[name] = value;85}86/**87 * Add a child node to an existing node.88 * @param {object} parentNode89 * @param {string} childName90 * @return {object} the child node91 */92function addChild(parentNode, childName) {93 const childNode = {94 type: 'element',95 name: childName,96 attributes: {},...

Full Screen

Full Screen

seiya.mobilepage-0.1.js

Source:seiya.mobilepage-0.1.js Github

copy

Full Screen

...36 {37 var pageDiv, headerDiv, contentDiv, footerDiv;3839 headerDiv = new DivTag(m_headerHtml);40 headerDiv.addAttr('data-role', 'header');41 headerDiv.addAttr('data-position', 'fixed');4243 contentDiv = new DivTag(m_contentHtml);44 contentDiv.addAttr('data-role', 'content');4546 footerDiv = new DivTag(m_footerHtml);47 footerDiv.addAttr('data-role', 'footer');48 footerDiv.addAttr('data-id', 'footer');49 footerDiv.addAttr('data-position', 'fixed');5051 pageDiv = new DivTag(headerDiv.toHtml() + contentDiv.toHtml() + footerDiv.toHtml());52 pageDiv.addAttr('id', m_id);53 pageDiv.addAttr('data-role', 'page');54 pageDiv.addAttr('data-theme', 'z');5556 if (m_hasBackBtn)57 {58 pageDiv.addAttr('data-add-back-btn', 'true');59 }6061 return(pageDiv.toHtml());62 };6364 // Public members65 66 return(67 {68 init: _init,69 setHeaderHtml: _setHeaderHtml,70 setContentHtml: _setContentHtml,71 setFooterHtml: _setFooterHtml,72 toHtml: _toHtml ...

Full Screen

Full Screen

attribute.js

Source:attribute.js Github

copy

Full Screen

1// 保存属性及事件2import {decodeUnicode} from './transcoding'3function SaveAttr() {4 this.addAttr={}; 5}6//增加7SaveAttr.prototype.add=function(id,attrName,data){8 if(this.addAttr[id]){9 this.addAttr[id][attrName]=data;10 }else{11 let obj={};12 obj[attrName]=data;13 this.addAttr[id]=obj;14 }15 // console.log(this.addAttr[id])16}17// 删除18SaveAttr.prototype.del=function(id,attrName){19 if(this.addAttr[id]){20 return this.addAttr[id][attrName]={}21 }22}23// 获取24SaveAttr.prototype.obtain=function(id,attrName){25 if(this.addAttr[id]){26 if(this.addAttr[id][attrName]==undefined){27 return {};28 }29 this.addAttr[id][attrName].attrTitle=decodeUnicode(this.addAttr[id][attrName].attrTitle)30 return this.addAttr[id][attrName];31 }32 return {};33}34// 获取过滤后的属性及事件名称35SaveAttr.prototype.getAttr=function(id){36 var obj=this.addAttr[id];37 if(obj){38 let arr=[];39 for(var k in obj){40 if(JSON.stringify(obj[k])!='{}'){41 let o={};42 o.attrTitle=decodeUnicode(obj[k].attrTitle);43 o.name=obj[k].name;44 arr.push(o)45 }46 }47 return arr;48 }else{49 return []50 }51 52}53// id改变时复制数据54SaveAttr.prototype.idChange=function(oldId,newId){55 var oldVal=JSON.stringify(this.addAttr[oldId]);56 this.addAttr[newId]=JSON.parse(oldVal);57 delete this.addAttr[oldId];58}...

Full Screen

Full Screen

component-root.js

Source:component-root.js Github

copy

Full Screen

...3// mark component root nodes as4export function postTransformComponentRoot (el: ASTElement) {5 if (!el.parent) {6 // component root7 addAttr(el, '@isComponentRoot', 'true')8 addAttr(el, '@templateId', '_uid')9 addAttr(el, '@componentProps', '$props || {}')10 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('@playwright/test/lib/utils');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await addAttr(page, 'css=button', 'data-testid', 'my-button');5 await page.click('data-testid=my-button');6});7{8 "scripts": {9 },10 "devDependencies": {11 }12}13const { addAttr } = require('@playwright/test/lib/utils');14const { test } = require('@playwright/test');15test('test', async ({ page }) => {16 await addAttr(page, 'css=button', 'data-testid', 'my-button');17 await page.click('data-testid=my-button');18});19{20 "scripts": {21 },22 "devDependencies": {23 }24}25const { addAttr } = require('@playwright/test/lib/utils');26const { test } = require('@playwright/test');27test('test', async ({ page }) => {28 await addAttr(page, 'css=button', 'data-testid', 'my-button');29 await addAttr(page, 'css=button', 'data-test', 'my-button');30 await page.click('data-testid=my-button');31});32{33 "scripts": {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('@playwright/test/lib/autotools');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 await page.click('text=Get started');5 await addAttr(page, 'css=button', 'data-testid', 'btn');6});7const { test } = require('@playwright/test');8test('test', async ({ page }) => {9 await page.click('text=Get started');10 await page.click('data-testid=btn');11});12const { addAttr } = require('@playwright/test/lib/autotools');13const { test } = require('@playwright/test');14test('test', async ({ page }) => {15 await page.click('text=Get started');16 await addAttr(page, 'css=button', 'data-testid', 'btn');17});18const { test } = require('@playwright/test');19test.use({20 contextOptions: {21 },22});23test('test', async ({ page }) => {24 await page.click('text=Get started');25 await page.click('data-testid=btn');26});

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2const {addAttributes} = require('playwright/lib/server/supplements/recorder/recorderSupplement');3(async () => {4 const browser = await chromium.launch({5 });6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.click('input[type="text"]');9 await page.fill('input[type="text"]', 'playwright');10 await page.click('input[type="submit"]');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('@playwright/test');2addAttr('test', 'test');3const { addTestAttribute } = require('@playwright/test');4addTestAttribute('test', 'test');5const { test } = require('@playwright/test');6test('test attribute', async ({ page }) => {7 const title = page.locator('text="Playwright"');8 await title.setAttribute('test', 'test');9});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('playwright/lib/server/dom');2const { Page } = require('playwright/lib/server/page');3const { ElementHandle } = require('playwright/lib/server/dom');4const page = new Page();5const elementHandle = new ElementHandle(page, 'div', 'div');6addAttr(elementHandle, 'data-test', 'test');7console.log(elementHandle.getAttribute('data-test'));

Full Screen

Using AI Code Generation

copy

Full Screen

1const { webkit } = require('playwright');2const { addAttr } = require('playwright/lib/server/dom.js');3(async () => {4 const browser = await webkit.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.waitForSelector('input');8 const input = await page.$('input');9 await addAttr(input, 'data-test', 'test');10 await page.screenshot({ path: `todo-${Date.now()}.png` });11 await browser.close();12})();13const { webkit } = require('playwright');14const { addAttr } = require('playwright/lib/server/dom.js');15(async () => {16 const browser = await webkit.launch();17 const context = await browser.newContext();18 const page = await context.newPage();19 await page.waitForSelector('input');20 const input = await page.$('input');21 await addAttr(input, 'data-test', 'test');22 await page.screenshot({ path: `todo-${Date.now()}.png` });23 await browser.close();24})();25const { webkit } = require('playwright');26const { addAttr } = require('playwright/lib/server/dom.js');27(async () => {28 const browser = await webkit.launch();29 const context = await browser.newContext();30 const page = await context.newPage();31 await page.waitForSelector('input');32 const input = await page.$('input');33 await addAttr(input, 'data-test', 'test');34 await page.screenshot({ path: `todo-${Date.now()}.png` });35 await browser.close();36})();37const { webkit } = require('playwright');38const { addAttr } = require('playwright/lib

Full Screen

Using AI Code Generation

copy

Full Screen

1const {addAttr} = require('@playwright/test/lib/internal/selectorEngine');2const {test} = require('@playwright/test');3test.use({storageState: 'storage.json'});4test('test', async ({page}) => {5 await addAttr(page, 'input[name="q"]', 'data-qa', 'search-bar');6});7const {test, expect} = require('@playwright/test');8test('test', async ({page}) => {9 const searchbar = await page.waitForSelector('input[data-qa="search-bar"]');10 expect(searchbar).toBeTruthy();11});12Version 89.0.4389.114 (Official Build) (64-bit)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('@playwright/test');2addAttr('data-automation-id', 'automation-id');3test('test', async ({ page }) => {4 const element = page.locator('data-automation-id=automation-id');5 await element.click();6});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');2addAttr('data-test-id', (element, value) => {3 return element.getAttribute('data-test-id') === value;4});5const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');6addAttr('data-test-id', (element, value) => {7 return element.getAttribute('data-test-id') === value;8});9const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');10addAttr('data-test-id', (element, value) => {11 return element.getAttribute('data-test-id') === value;12});13const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');14addAttr('data-test-id', (element, value) => {15 return element.getAttribute('data-test-id') === value;16});17const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');18addAttr('data-test-id', (element, value) => {19 return element.getAttribute('data-test-id') === value;20});21const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');22addAttr('data-test-id', (element, value) => {23 return element.getAttribute('data-test-id') === value;24});25const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');26addAttr('data-test-id', (element, value) => {27 return element.getAttribute('data-test-id') === value;28});29const { addAttr } = require('@playwright/test/lib/internal/selectorEngine');30addAttr('data-test-id', (element, value) => {31 return element.getAttribute('data-test-id') === value;32});

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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