Skip to content

Commit

Permalink
form validate and css beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
gongjunhao@sina.com authored and gongjunhao@sina.com committed Nov 22, 2017
1 parent 868f55b commit e3a7cc9
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 33 deletions.
56 changes: 46 additions & 10 deletions src/css/form.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.secKillTarget {
border: red 1px solid !important;
text-shadow: 0 -1px 1px red !important;
box-shadow: 0 -1px 1px red !important;
text-shadow: 2px 2px 2px rgba(255, 173, 10, 1) !important;
box-shadow: 2px 2px 2px rgba(255, 173, 10, 1) !important;
cursor: copy !important;
}
#secKillForm {
position: fixed;
Expand All @@ -20,7 +20,43 @@
box-sizing:unset;
}

#secKillForm .logo {
#secKillForm .secKill-input-text {
display:block;
width: 180px;
height: 17px;
padding: 0px;
background: rgba(255,255,255,1);
border: none;
outline: none;
color: black;
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
box-shadow: inset 0 -1px 2px rgba(100,100,100,0.2), 0 1px 1px rgba(255,255,255,0.2);
text-indent: 4px;
transition: all .3s ease-in-out;
position: relative;
font-size: 12px;
}

#secKillForm .secKill-input-number {
display:block;
width: 80px;
height: 17px;
padding: 0px;
background: rgba(255,255,255,1);
border: none;
outline: none;
color: black;
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
box-shadow: inset 0 -2px 2px rgba(100,100,100,0.2), 0 1px 1px rgba(255,255,255,0.2);
text-indent: 4px;
transition: all .3s ease-in-out;
position: relative;
font-size: 12px;
}

#secKillForm .secKill-logo {
font-size: 14px;
color: #ff803b;
word-break: break-all;
Expand All @@ -33,25 +69,25 @@
float: left;
}

#secKillForm .filed {
#secKillForm .secKill-filed {
color: #fff;
float: left;
padding: 3px 10px;
}

#secKillForm .name {
#secKillForm .secKill-name {
color: black;
font-weight: bolder;
}

#secKillForm .button {
#secKillForm .secKill-button {
margin: 10px 5px;
font-size: 14px;
color: #27ff09;
text-align: center;
word-break: break-all;
width: 50px;
padding: 3px 10px;
width: 45px;
padding: 3px 8px;
height: 50%;
cursor: pointer;
font-weight: bolder;
Expand All @@ -61,6 +97,6 @@
float: left;
}

#secKillForm .result {
#secKillForm .secKill-result {
color: red;
}
54 changes: 31 additions & 23 deletions src/js/newTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@
//页面注入任务表单
var newElement = document.createElement('div');
var html = "<div id=\"secKillForm\">\n" +
" <div class=\"logo\">\n" +
" <div class=\"secKill-logo\">\n" +
" 新增秒杀\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">秒杀商品:</span><br/>\n" +
" <input type=\"text\" name=\"taskName\" value=\"\" id=\"taskName\" placeholder=\"请输入商品名称\" />\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">秒杀商品:</span><br/>\n" +
" <input type=\"text\" name=\"taskName\" class=\"secKill-input-text\" value=\"\" id=\"taskName\" placeholder=\"请输入商品名称\" />\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">选择器:</span><br/>\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">选择器:</span><br/>\n" +
" <input type=\"radio\" name=\"selector\" id=\"rb1\" value=\"jQuery\" checked=\"checked\"/>\n" +
" <label for=\"rb1\">jQuery</label>\n" +
" <input type=\"radio\" name=\"selector\" id=\"rb2\" value=\"xPath\"/>\n" +
" <label for=\"rb2\">xPath</label>\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">选取结果:</span><br/>\n" +
" <input type=\"text\" name=\"location\" id=\"location\" value=\"\" placeholder=\"#secKill-btn\"/>\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">选取结果:</span><br/>\n" +
" <input type=\"text\" name=\"location\" class=\"secKill-input-text\" id=\"location\" value=\"\" placeholder=\"#secKill-btn\"/>\n" +
" </div>\n" +
" <div class=\"button\" id=\"search\">\n" +
" 定位(<span class=\"result\" id=\"result\">0</span>)\n" +
" <div class=\"secKill-button\" style=\"width: 50px;\" id=\"search\">\n" +
" 定位(<span class=\"secKill-result\" id=\"result\">0</span>)\n" +
" </div>\n" +
" <div class=\"button\" id=\"reset\">\n" +
" <div class=\"secKill-button\" id=\"reset\">\n" +
" 重选\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">秒杀时间:</span><br/>\n" +
" <input type=datetime-local value=\""+formatDateTime(new Date().getTime())+"T12:00:00\" step=\"1\" id=\"killTime\" name=\"killTime\">\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">秒杀时间:</span><br/>\n" +
" <input type=\"datetime-local\" class=\"secKill-input-text\" value=\""+formatDateTime(new Date().getTime())+"T12:00:00\" step=\"1\" id=\"killTime\" name=\"killTime\">\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">秒杀频率(ms):</span><br/>\n" +
" <input type=\"number\" name=\"frequency\" id=\"frequency\"value=\"500\" min=\"400\" placeholder=\"单位:毫秒(ms)\"/>\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">秒杀频率(ms):</span><br/>\n" +
" <input type=\"number\" name=\"frequency\" class=\"secKill-input-number\" id=\"frequency\"value=\"500\" min=\"100\" placeholder=\"单位:毫秒(ms)\"/>\n" +
" </div>\n" +
" <div class=\"filed\">\n" +
" <span class=\"name\">秒杀次数:</span><br/>\n" +
" <input type=\"number\" name=\"count\" id=\"count\" value=\"10\" placeholder=\"尝试次数\"/>\n" +
" <div class=\"secKill-filed\">\n" +
" <span class=\"secKill-name\">秒杀次数:</span><br/>\n" +
" <input type=\"number\" name=\"count\" class=\"secKill-input-number\" id=\"count\" value=\"10\" placeholder=\"尝试次数\"/>\n" +
" </div>\n" +
" <div class=\"button\" id=\"add\"> 新增 </div>\n" +
" <div class=\"button\" id=\"close\"> 关闭 </div>\n" +
" <div class=\"secKill-button\" id=\"add\"> 新增 </div>\n" +
" <div class=\"secKill-button\" id=\"close\"> 关闭 </div>\n" +
"</div>";
newElement.innerHTML = html;
if($("#secKillForm").length === 0) {
Expand Down Expand Up @@ -123,7 +123,15 @@
killTask.location = location;
killTask.killTime = $("#secKillForm #killTime").val();
killTask.frequency = $("#secKillForm #frequency").val();
if($("#secKillForm #frequency").val() < 100) {
alert("秒杀频率最小值:100");
return false;
}
killTask.count = $("#secKillForm #count").val();
if($("#secKillForm #count").val() < 1){
alert("秒杀次数最小值:1");
return false;
}
killTask.status = 0;
chrome.storage.local.get({"tasks": new Array()}, function(value){
var tasks = value.tasks;
Expand Down

0 comments on commit e3a7cc9

Please sign in to comment.