Wednesday, September 30, 2015

CCS Selector for iPhone 6s Reservation Submission Form

For the iPhone 6s Reservation Submission Form, the required javascript code for selectors and the flow are analysed below in red.

(1)
URL = iPhone 6s Reservation
(2) javascript for Chrome console (Cmd + Opt + J for Mac)
iphone6s.js    Select all
var isDebug = true; var isSubmit = false; var storeOrder = ["R409","R428","R499","R485"]; // R409=CWB銅鑼灣, R485=FW又一城, R428=IFC, R499=CantonRoad廣東道 var timeslotOrder = ["2:00 PM","11:30 AM","12:00 PM","12:30 PM","1:00 PM","1:30 PM","3:00 PM","4:00 PM"]; //var timeslotOrder = ["下午 2:00","上午 11:30","下午 12:00","下午 12:30","下午 1:00","下午 1:30","下午 3:00"]; var quantity = 2; // maximum 2 for quantity, 購買數量, 最多2部 var firstname = "javacom"; // First Name 名, 必需填寫 var lastname = "NAME"; // Last Name 姓, 必需填寫 var email = "javacom@icloud.com"; // Email Address 電郵, 必需填寫 var phonenumber = "98765432"; // Phone Number 電話, 必需填寫 var govtIdType = 1; /* HK 1="idHongkongCard" 香港永久性居民身份證 Hong Kong ID Card 2="travelPermitTaiwan" 台灣居民來往內地通行證 Mainland Travel Permit for Taiwan residents 3="entryExitPass" 往來港澳通行證 Entry/Exit Permit to Hong Kong and Macau 4="macauIDCard" 澳門永久性居民身份證 Macau ID Card 5="passport" 國際旅遊護照 Passport (International Visitors) */ var govtId = "A123456(7)"; // Government ID No 證件號碼,必需填寫 function autoSelect() { if (isDebug) console.log("autoSelect()"); if (isDebug) console.log($("#main #storeView .select-store select option").eq(0).val()); if ($("#main #storeView .select-store select option").eq(0).val() > "") selectStore(); else if ($(".reservation .select-store select option").eq(0).text() > "") insertContactInfo(); } function selectStore() { if (isDebug) console.log("selectStore()"); var isSelectedStore = false; var storeSelection_length = $("#main #storeView .select-store select option").length; for(i=0;i<storeOrder.length;i++) { if (isDebug) console.log("Checking Store " + storeOrder[i].toString()); for(a=1;a<storeSelection_length;a++) { if (isDebug) console.log("Against " + $("#main #storeView .select-store select option").eq(a).text()); if ($("#main #storeView .select-store select option").eq(a).val() == storeOrder[i].toString()) { if (isDebug) console.log("Selected Store is " + storeOrder[i].toString()); $("#main #storeView .select-store select option").eq(a).select().attr("selected","selected"); console.log($("#main #availabilityView .section-copy .availability-available").text()); isSelectedStore = true; break; } } if(isSelectedStore) break; } if(isSelectedStore) { $(".form-cell button").click(); } else { console.log("Sorry !! unavailable for in-store pickup"); } } function insertContactInfo() { if ($("select[name='selectedQuantity'] option").eq(quantity-1).val() > "") { $("select[name='selectedQuantity'] option").eq(quantity-1).select().attr("selected","selected").change(); } else { $("select[name='selectedQuantity'] option:last").select().attr("selected","selected").change(); } var isSelectedTimeslot = false; var timeSlotSelection_length = $("select[name='selectedTimeSlotId'] option").length; for(i=0;i<timeslotOrder.length;i++) { if (isDebug) console.log("Checking Timeslot " + timeslotOrder[i].toString()); for(a=1;a<timeSlotSelection_length;a++) { if (isDebug) console.log("Against " + $("select[name='selectedTimeSlotId'] option").eq(a).text()); if ($("select[name='selectedTimeSlotId'] option").eq(a).text().indexOf(timeslotOrder[i].toString()) == 0) { $("select[name='selectedTimeSlotId'] option").eq(a).select().attr("selected","selected").change(); console.log($("select[name='selectedTimeSlotId'] option").eq(a).select().text()); isSelectedTimeslot = true; break; } } if(isSelectedTimeslot) break; } if (!isSelectedTimeslot) { $("select[name='selectedTimeSlotId'] option:last").select().attr("selected","selected").change(); console.log($("select[name='selectedTimeSlotId'] option:last").select().text()); } $("input[name='firstName']").val(firstname); $("input[name='lastName']").val(lastname); $("input[name='email']").val(email) $("input[name='phoneNumber']").val(phonenumber) $(".gov-id-info select[name='selectedGovtIdType'] option").eq(govtIdType).select().attr("selected","selected").change(); $("input[name='govtId']").val(govtId); console.log($(".schedule-copy").text()); if (isSubmit) $(".form-cell button").click(); } autoSelect();


No comments: