1 Star 0 Fork 0

RFst/odingX

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
select.html 5.85 KB
一键复制 编辑 原始数据 按行查看 历史
RFst 提交于 2022-04-08 14:05 . update
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<title>选择</title>
<!-- <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script> -->
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>
// VConsole 默认会挂载到 `window.VConsole` 上
var vConsole = new window.VConsole();
</script>
<script type="text/javascript">
Storage.prototype.setExpire = (key, value, expire) => {
let obj = {
data: value,
time: Date.now(),
expire: expire
};
//localStorage 设置的值不能为对象,转为json字符串
localStorage.setItem(key, JSON.stringify(obj));
}
Storage.prototype.getExpire = key => {
let val = localStorage.getItem(key);
if (!val) {
return val;
}
val = JSON.parse(val);
if (Date.now() - val.time > val.expire) {
localStorage.removeItem(key);
return null;
}
return val.data;
}
</script>
</head>
<style type="text/css">
.divcss5{
height:300px;
border:0px solid #000;
margin: 0 auto;
overflow-y:auto;
font-weight:bold;
text-align: center;
font-family: 'Microsoft YaHei','宋体',tahoma;
}
</style>
<body style="text-align:center;">
<br/>
<br/>
<input type="radio" id="superLotto" checked="true" name="selectType"/>大乐透
<input type="radio" id="dualColoredBall" name="selectType"/>双色球
<br/>
<br/>
<input type="button" value="开始" onclick="begin()">
<input type="button" value="停止" onclick="stop()">
<!-- <input type="button" value="clear" onclick="qk()"> -->
<br/>
<br/>
<input type="button" value="选一" onclick="selectOne()">
<input type="button" value="添加" onclick="addHistory()">
<br/>
<br/>
<!-- <textarea id="result" cols="30" style="text-align: center;font-size: 14px;" rows="10" readonly="true"></textarea> -->
<div style="height:50px;">
<h4 id="result"></h4>
</div>
<br/>
<hr>
<!-- <textarea id="history" cols="30" style="text-align: center;font-size: 14px;" rows="10" readonly="true"></textarea> -->
<div id="history" class="divcss5">
</div>
</body>
</html>
<script type="text/javascript">
var int;
var resultArr;
var numArr;
// var ccip = returnCitySN["cip"];
var ccip = "88888888";
var resultText = document.getElementById("result");
var historyText = document.getElementById("history");
var selectType = document.getElementsByName("selectType");
function superLotto(){
resultArr = new Array();
numArr = new Array();
var result = createBall(35,5,12,2);
//resultText.value = result + "\n";
setContent(result);
}
function dualColoredBall() {
resultArr = new Array();
numArr = new Array();
var result = createBall(33,6,16,1);
//resultText.value = result + "\n";
setContent(result);
}
function createBall(maxFront,numFront,maxBack,numBack){
for (var i = 0; i < maxFront; i++) {
numArr[i] = (i+1) < 10?"0"+(i+1):(i+1)+"";
}
unorderedArr("前区:",numArr);
select(numFront);
resultArr.push("&nbsp;|&nbsp;");
numArr = new Array();
for (var i = 0; i < maxBack; i++) {
numArr[i] = (i+1) < 10?"0"+(i+1):(i+1)+"";
}
unorderedArr("后区:",numArr);
select(numBack);
var result = resultArr.join("&nbsp;");
return result;
}
function unorderedArr(f,arr){
for (i = arr.length - 1; i > 0; i--){
var rand = randomInt(0,arr.length - 1);
var temp = arr[i];
arr[i] = arr[rand];
arr[rand] = temp;
}
console.log(f + arr.join(","));
}
function setContent(c){
//resultText.value = c.trim() + "\n";
resultText.innerHTML = c;
}
function addHistory(){
// var r = resultText.value;
var r = getInnerText(resultText);
if (r != "" && r != "88888888") {
//historyText.value = historyText.value + resultText.value;
//resultText.value="";
var html = getInnerText(historyText) + "<div>"+r+"&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value =\"删除\" onclick=\"delNum(this.parentNode)\"></div>";
historyText.innerHTML = html;
resultText.innerHTML = "";
setStorage(html);
}
}
function delNum(obj) {
obj.remove();
setStorage(getInnerText(historyText));
}
function getInnerText(element) {
if (typeof element.innerHTML === 'string') {
return element.innerHTML;
} else {
return element.textContent;
}
}
function select (q) {
var arr = new Array();
for (var i = 0; i < q; i++) {
var maxNum = numArr.length-1;
var minNum = 0;
//var index = parseInt(Math.random()*(maxNum-minNum+1)+minNum,10)
var index = randomInt(minNum,maxNum);
//resultArr.push(numArr[index]);
arr.push(numArr[index]);
numArr.splice(index,1);
}
arr.sort();
resultArr = resultArr.concat(arr);
}
function randomInt(minNum,maxNum) {
return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10)
}
function qk() {
resultText.value = "";
}
function callFun(fname) {
//var func = eval(fname);
//new func();
eval(fname);
}
function begin(){
stop();
for(i=0;i<selectType.length;i++) {
if (selectType[i].checked) {
//window.setTimeout(selectType[i].id+"()",10);
int=self.setInterval(selectType[i].id+"()",100);
}
}
}
function stop(){
int=window.clearInterval(int);
}
function selectOne(){
for(i=0;i<selectType.length;i++) {
if (selectType[i].checked) {
window.setTimeout(selectType[i].id+"()",10);
}
}
}
function setStorage(c){
if (typeof(Storage) !== "undefined") {
// localStorage.setExpire(ccip,c,300000);
localStorage.setItem(ccip,c);
}
}
if (typeof(Storage) !== "undefined") {
if (localStorage.getItem(ccip)) {
// historyText.innerHTML=localStorage.getExpire(ccip);
historyText.innerHTML=localStorage.getItem(ccip);
}
}
//alert(returnCitySN["cip"]+','+returnCitySN["cname"]);
</script>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/RiseZero/odingX.git
git@gitee.com:RiseZero/odingX.git
RiseZero
odingX
odingX
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385