console
var setInfo = {
setting: {
intervalMin: 99,
intervalMax:66,
times: 8,
time: 22,
delay: 888
},
urls: [
'https://tieba.baidu.com/p/6874483990',
'https://tieba.baidu.com/p/6874058290',
'https://tieba.baidu.com/p/6874394678',
'https://tieba.baidu.com/p/6874019026'
],
replies: [
'sssdfdd',
'你好',
'啦啦啦'
]
};
window.onload = () => {
Object.keys(setInfo.setting).map(v => {
document.getElementById(v).value = setInfo.setting[v]
})
}
document.getElementById('save').onclick = () => {
let setInfo = {};
setInfo['setting'] = {};
['intervalMin','intervalMax','times', 'time', 'delay'].map(v => {
let value = document.getElementById(v).value.trim();
if (!value) {
Toast(v + '不能为空');
return;
}
setInfo.setting[v] = value;
});
['urls', 'replies'].map(v => {
let value = document.getElementById(v).value.trim();
if (!value) {
Toast(v + '不能为空');
return;
}
setInfo[v] = value.split('\n').map(v => v.trim())
})
console.log(setInfo)
}
document.getElementById('start').onclick = () => {
}
document.getElementById('intervalMax').onblur=(e)=>{
if( parseInt(document.getElementById('intervalMin').value)>parseInt(e.target.value))
Toast('最大值不能小于最小值');
}
function Toast(msg, duration = 3000) {
var m = document.createElement('div');
m.innerHTML = msg;
m.style.cssText = "max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.7);font-size: 16px;";
document.body.appendChild(m);
setTimeout(() => {
var d = 0.5;
m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
m.style.opacity = '0';
setTimeout(() => { document.body.removeChild(m) }, d * 1000);
}, duration);
}
<div id="container">
<div id="content">
<div id="setting">
<h3>设置</h3>
<div>
</br>
</h2>循环设置</h2>
</br></br>
<label>最低间隔:
<input type="number" id="intervalMin" placeholder="单位秒">
</label>
</br></br>
<label>最高间隔:
<input type="number" id="intervalMax" placeholder="单位秒">
</label>
</br></br>
<label>循环次数:
<input type="number" id="times" >
</label>
</br></br></br></br>
</h2>定时延迟</h2>
</br></br>
<label >每日整点:
<input type="number" id="time" placeholder="如:22">
</label>
</br></br>
<label >延迟秒数:
<input type="number" id="delay">
</label>
</br></br>
</div>
</div>
<div>
<h3>帖子地址</h3>
<textarea id="urls"> </textarea>
</div>
<div>
<h3>回复内容</h3>
<textarea id="replies"> </textarea>
</div>
</div>
<div>
<button id='save'>保存</button>
<button id='stop'>停止</button>
<button id='start'>开始</button>
</div>
</div>
html,body{
width: 100%;
height: 100%;
background:lightgrey;
}
#container{
margin: 8px auto;
width: 90%;
height:calc(100% - 60px);
text-align: center;
}
#container>div>button{
width: 30%;
height: 30px;
margin: 8px 10px;
}
#content {
display: flex;
width: 100%;
height: 100%;
}
#content>div {
height: 100%;
flex: 1;
display: flex;
flex-direction:column;
}
#content>div>div {
width: 97%;
height: 100%;
background:lightblue;
}
#content>div>h3 {
width: 100%;
flex:0;
margin: 3px auto;
text-align: center;
}
#content>div>textarea {
width: 97%;
flex:1000;
}
#setting>div>label,input{
padding-left: 3px;
height: 25px;
}