-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
1 lines (1 loc) · 4.75 KB
/
index.html
1
<!doctype html><html><head><meta name="viewport" id="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/><meta charset="UTF-8"/><title>24 Game Solver</title><style>body{align-items:stretch;bottom:0;display:flex;flex-direction:column;flex-wrap:nowrap;font-family:微软雅黑,sans;left:0;margin:0;padding:50px 0 0;position:absolute;right:0;top:0;user-select:none}body,h1{text-align:center}h1{margin:0 0 10px}#form_24game_solver,h1{flex:none}#form_24game_solver input,#form_24game_solver select{box-sizing:border-box;height:30px;line-height:30px;outline:none;padding:0 4px;position:relative;z-index:1000}#form_24game_solver select{display:inline-block;margin:0 2px 4px;vertical-align:top}#form_24game_solver .rowGoal{margin:4px 0}#form_24game_solver button,#form_24game_solver input[type=button]{height:30px;position:relative;z-index:1000}.resultContainer{align-items:center;display:flex;flex:auto;flex-direction:column;flex-wrap:nowrap;margin-top:30px;overflow:auto;padding:0 10px 10px;text-align:center}.resultContainer #calc24_result{max-width:800px;text-align:left}.resultContainer #calc24_result>span{display:inline-block;margin:0 4px;min-width:150px;text-align:center;vertical-align:top}ribbon{user-drag:none;background-color:#a00;box-shadow:0 0 5px 2px #888;position:fixed;right:0;top:0;user-select:none}ribbon,ribbon a{display:block;overflow:hidden}ribbon a{border-bottom:1px solid #fff;border-top:1px solid #fff;color:#fff;font-size:12px;font-weight:700;line-height:30px;margin:2px 0;text-align:center;text-decoration:none;width:260px}@media only screen and (min-width:600px){body{padding-top:20px}ribbon{transform:translate(83px) rotate(45deg);transform-origin:50px 50%}}</style><script src="dist/24game-solver.js"></script></head><body><ribbon><a href="https://github.com/frank-deng/24game-solver/">Fork me on GitHub</a></ribbon><h1>24 Game Solver</h1><form id="form_24game_solver"><select name="num[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option></select><select name="num[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option></select><select name="num[]"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option></select><select name="num[]"><option value="0">⊘</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option></select><select name="num[]"><option value="0">⊘</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option></select><div class="rowGoal">Goal: <input name="goal" size="2" maxlength="2" value="24"/> <button>Calculate</button></div></form><div class="resultContainer"><div id="calc24_result"> </div></div></body><script>!function(){const e=document.getElementById("calc24_result"),n=document.getElementsByName("goal")[0],t=document.getElementsByName("num[]");document.getElementById("form_24game_solver").onsubmit=function(l){let r=[];for(let e=0;e<t.length;e++){let n=Number(t[e].value);n&&r.push(n)}let o=n.value;if(e.innerHTML="",isNaN(o)||o<0||o>99||!o)return n.value=24,e.innerHTML="",window.alert("Goal must between 0 and 99."),!1;o=Number(o);try{var a=solve24game(r,o);if(0==a.length)e.innerHTML="No Answer.";else for(let n of a)e.innerHTML+=`<span>${n}</span>`}catch(l){console.error(l),e.innerHTML="",alert(l.message)}return!1}}();</script></html>