Best JavaScript code snippet using playwright-internal
databind.js
Source:databind.js
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");...
V_databind.js
Source:V_databind.js
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");...
Vote-databind.js
Source:Vote-databind.js
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 });...
cart.js
Source:cart.js
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>></span><a href='../htmls/productList.html'>è´ç©</a>å§</h2>";136 }137 }...
xml.js
Source:xml.js
...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: {},...
seiya.mobilepage-0.1.js
Source:seiya.mobilepage-0.1.js
...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
...
attribute.js
Source:attribute.js
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}...
component-root.js
Source:component-root.js
...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 }...
Using AI Code Generation
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": {
Using AI Code Generation
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});
Using AI Code Generation
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"]');
Using AI Code Generation
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});
Using AI Code Generation
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'));
Using AI Code Generation
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
Using AI Code Generation
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)
Using AI Code Generation
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});
Using AI Code Generation
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});
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.
Get 100 minutes of automation test minutes FREE!!