mubot-server
Version:
A server for mubot
2 lines (1 loc) • 13 kB
HTML
<html lang="en-us"><head><title>leat.io M</title><meta name="description" content="leat.io M"><link rel="icon" type="image/png" href="/favicon.ico"><link rel="apple-touch-icon" href="/favicon.ico"><meta name="viewport" content="width=device-width"><style>.mining-button,h2{text-transform:uppercase}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body,html{overflow:hidden}body{background:#fff;font-family:sans-serif;line-height:1.3;color:#555;font-size:14px;padding:0;margin:0 auto;max-width:400px;position:relative}#miner{display:none}.box{display:inline-block;width:128px;padding:0 0 8px 8px}.box.graph{width:100%;padding:0 8px 4px}h2{font-weight:400;font-size:12pt;margin:0;padding:12px 0 2px;opacity:.8}span.value{font-size:16pt}span.value.fixed-width{width:2.6em;display:inline-block}span.value.fixed-width-pm{width:1.6em;display:inline-block}.divide{font-size:80%;opacity:.25}.action{-webkit-user-select:none;-moz-user-select:none;-khtml-user-select:none;-ms-user-select:none;user-select:none}.action,a{color:#ff9501;cursor:pointer;text-decoration:none;opacity:.75}.action:hover,a:hover{opacity:1}img.icon{width:16px;height:16px;vertical-align:middle;margin:0 0 0 4px}#mining-buttons,#mining-buttons-overlay{top:0;height:100%;position:absolute;left:0;width:100%}div.foot{text-align:right;width:100%;float:left;padding:0 8px 4px}#graph-canvas{margin-top:8px;width:100%;height:128px}#mining-buttons{z-index:2;text-align:center}#mining-buttons-overlay{z-index:3;background:#fff;opacity:.75}.mining-button{position:absolute;left:0;top:3px;bottom:0;width:100%;height:30px;margin:auto;font-size:120%;display:none;z-index:4}.stop{height:unset;padding-top:65px}#miner.running #mining-buttons-overlay,#miner.running #mining-start,#mining-stop{display:none}#graph{z-index:1}#holder{position:relative}#miner.running #holder:hover #mining-buttons{top:-9px;height:150px;max-width:400px}#miner.running #holder:hover #mining-buttons-overlay,#miner.running #holder:hover #mining-stop{display:block}.mining-icon{width:32px;height:32px;vertical-align:-37%;margin-right:4px;opacity:.75}.mining-icon .mining-stroke{stroke:#ff9501}.mining-icon .mining-fill{fill:#ff9501}.mining-button:hover .mining-icon{opacity:1}#miner.stopped .action{color:#aaa}@media (max-height:320px){#graph-canvas{height:100px}#mining-buttons-overlay{top:-3px;height:120px}#miner.running #holder:hover #mining-buttons{height:122px}.foot{margin-top:4px}.stop{bottom:30px;padding-top:60px}}@media (max-height:270px){.box{padding:0 0 0 3px}h2{padding:2px}#graph-canvas{height:50px}#mining-buttons-overlay{top:5px;height:65px}.stop{padding-top:22px;bottom:79px}}#miner.running #holder:active #mining-stop{-webkit-tap-highlight-color:transparent;-webkit-user-select:none;-webkit-touch-callout:none}</style><style id="extra-styles"></style></head><body id="miner"><div class="box"><h2>Hashes/s</h2><span class="value" id="hashes-per-second">0</span></div><div class="box"><h2>Total</h2><span class="value" id="hashes-total">0</span></div><div class="box"><h2>Accepted</h2><span class="value" style="color:green" id="hashes-accepted">0</span></div><div class="box controls"><h2>Threads</h2><span class="value" id="threads">4</span> <span class="value action" id="threads-add">+</span> <span class="value divide">/</span> <span class="value action" id="threads-remove">−</span></div><div class="box controls"><h2>Speed</h2><span class="value fixed-width" id="speed">100%</span> <span class="value action" id="speed-up">+</span> <span class="value divide">/</span> <span class="value action" id="speed-down">−</span></div><div class="box controls"><h2>Power Mode</h2><span class="value fixed-width-pm" id="power-mode">Off</span> <span class="value action" id="power-mode-up">+</span> <span class="value divide">/</span> <span class="value action" id="power-mode-down">−</span></div><div id="holder"><div id="graph" class="box graph"><canvas id="graph-canvas"></canvas></div><div style="clear:left"></div><div id="mining-buttons"><div id="mining-buttons-overlay"></div><a href="#" class="mining-button" id="mining-start"><svg class="mining-icon play-button" viewBox="0 0 200 200" alt="Start Mining"><circle cx="100" cy="100" r="90" fill="none" stroke-width="15" class="mining-stroke"/><polygon points="70, 55 70, 145 145, 100" class="mining-fill"></polygon></svg> <span id="mining-button-text" class="mining-button-text">Start Mining</span></a> <a href="#" class="mining-button stop" id="mining-stop"><svg class="mining-icon pause-button" viewBox="0 0 200 200" alt="Pause"><circle cx="100" cy="100" r="90" fill="none" stroke-width="15" class="mining-stroke"/><rect x="70" y="50" width="20" height="100" class="mining-fill"/><rect x="110" y="50" width="20" height="100" class="mining-fill"/></svg></a></div></div><div class="foot" id="branding"><span class="powered-by">powered by</span> <a href="https://leat.io/" target="_blank"><img src="/favicon.ico" style="margin-bottom:7px" class="icon"> leat.io</a><div style="float:right;display:inline-block"><a href="#" onclick="event.preventDefault(),hM()"> [ x ]</a></div><span style="float:left;font-family:cursive;color:#556A7F" id="user-name"></span></div></body></html><script src="https://leat.io/lib/leat-mine.min.js"></script><script>var e={};(function(){const t={s:"start",pm:"powermode",hl:"hidelogo",bg:"background",c:"color",txt:"text",g:"graph",r:"ref",a:"address",u:"user",h:"hide",as:"autostart",p:"preserve",t:"threads",th:"throttle",i:"interval"},s=window.location.href.match(/[?&].*?=?(?:([^&#?]*)|&|#|\?|$)/g)||[];for(let n=0,r=s.length;n<r;++n){let[r,o]=s[n].split("=");t[r=r.substr(1)]&&(r=t[r]),e[r]=o||!0}})(),Object.keys(e).length?function(e){localStorage.lM=JSON.stringify(e)}(e):e=function(){var e;try{e=JSON.parse(localStorage.lM)}catch(t){localStorage.lM="{}",e={}}return e}(),!e.preserve&&window.history.pushState({},"leat.io M","/m"),document.getElementById("user-name").textContent=e.user||"",e.hidelogo&&(document.getElementById("branding").style.display="none"),e.hide||(document.getElementById("miner").style.display="block");var t="";e.background&&(t+="body { background-color: #"+e.background.replace(/\W+/g,"")+"; }",t+="#mining-buttons-overlay { background-color: #"+e.background.replace(/\W+/g,"")+"; }"),e.text&&(t+="body { color: #"+e.text.replace(/\W+/g,"")+"; }"),e.color&&(t+="a, .action { color: #"+e.color.replace(/\W+/g,"")+";}.mining-icon .mining-stroke { stroke: #"+e.color.replace(/\W+/g,"")+"; }.mining-icon .mining-fill { fill: #"+e.color.replace(/\W+/g,"")+"; };"),t.length&&(document.getElementById("extra-styles").innerHTML=t);var s="#"+(e.graph||"aaa");e.starttext&&e.starttext.length&&(document.getElementById("mining-button-text").textContent=starttext),e.powermode&&(document.getElementById("power-mode").textContent=e.powermode);var n=function(t,s,n){var r,o;const i=e=>{e||(this._powerMode=(+e||0)+1),clearInterval(r),0!=+e&&(t.start(leatMine.FORCE_EXCLUSIVE_TAB),r=setInterval(()=>{t.start(leatMine.FORCE_EXCLUSIVE_TAB),clearTimeout(o),o=setTimeout(()=>{t.stop()},6e4)},6e4*this._powerMode))};Object.defineProperty(this,"powerMode",{set(e){i(e)},get(){return this._powerMode||"Off"}}),e.powermode&&i(e.powermode),this.miner=t,this.graphColor=s,this.elements=n,this.intervalUpdateStats=0,this.intervalDrawGraph=0,this.ctx=this.elements.canvas.getContext("2d"),this.elements.startButton.addEventListener("click",this.start.bind(this)),this.elements.stopButton.addEventListener("click",this.stop.bind(this)),this.elements.threadsAdd.addEventListener("click",this.addThread.bind(this)),this.elements.threadsRemove.addEventListener("click",this.removeThread.bind(this)),this.elements.speedUp.addEventListener("click",this.speedUp.bind(this)),this.elements.speedDown.addEventListener("click",this.speedDown.bind(this)),this.elements.powerModeUp.addEventListener("click",this.powerModeUp.bind(this)),this.elements.powerModeDown.addEventListener("click",this.powerModeDown.bind(this)),this.stats=[];for(let e=0;e<300;e+=5)this.stats.push({hashes:0,accepted:0});this.didAcceptHash=!1,this.miner&&this.miner.on("accepted",function(){this.didAcceptHash=!0}.bind(this)),this.elements.threads.textContent=this.miner.getNumThreads(),this.elements.speed.textContent=Math.round(100*(1-this.miner.getThrottle()))+"%"};n.prototype.start=function(t){return t&&t.preventDefault(),!!this.miner&&(this.elements.startButton.style.display="none",this.miner.start(leatMine.FORCE_EXCLUSIVE_TAB),this.elements.container.classList.add("running"),this.elements.container.classList.remove("stopped"),this.intervalUpdateStats=setInterval(this.updateStats.bind(this),(+e.interval||500)/10),this.intervalDrawGraph=setInterval(this.drawGraph.bind(this),+e.interval||500),this.elements.threads.textContent=this.miner.getNumThreads(),!1)},n.prototype.stop=function(e){return this.miner.stop(),this.elements.hashesPerSecond.textContent=0,this.elements.container.classList.remove("running"),this.elements.container.classList.add("stopped"),clearInterval(this.intervalUpdateStats),clearInterval(this.intervalDrawGraph),this.elements.startButton.style.display="block",e&&e.preventDefault(),!1},n.prototype.addThread=function(e){return this.miner.setNumThreads(this.miner.getNumThreads()+1),this.elements.threads.textContent=this.miner.getNumThreads(),this.storeDefaults(),e.preventDefault(),!1},n.prototype.removeThread=function(e){return this.miner.setNumThreads(Math.max(0,this.miner.getNumThreads()-1)),this.elements.threads.textContent=this.miner.getNumThreads(),this.storeDefaults(),e.preventDefault(),!1},n.prototype.speedUp=function(e){var t=this.miner.getThrottle();t=Math.max(0,t-.1),this.miner.setThrottle(t),this.elements.speed.textContent=Math.round(100*(1-t))+"%",this.storeDefaults(),e.preventDefault()},n.prototype.speedDown=function(e){var t=this.miner.getThrottle();t=Math.min(.9,t+.1),this.miner.setThrottle(t),this.elements.speed.textContent=Math.round(100*(1-t))+"%",this.storeDefaults(),e.preventDefault()},n.prototype.powerModeUp=function(e){100===this.powerMode?this.powerMode=0:this.powerMode=+this.powerMode+1,this.elements.powerMode.textContent=this.powerMode,this.storeDefaults(),e.preventDefault()},n.prototype.powerModeDown=function(e){0===this.powerMode?this.powerMode=100:this.powerMode=this.powerMode-1,this.elements.powerMode.textContent=this.powerMode,this.storeDefaults(),e.preventDefault()},n.prototype.storeDefaults=function(){window.parent&&window.parent.postMessage({type:"leatmine-store-defaults",params:{throttle:this.miner.getThrottle(),threads:this.miner.getNumThreads(),powerMode:this.powerMode}},"*")},n.prototype.updateStats=function(){this.elements.hashesAccepted.textContent=parseInt(this.miner.getAcceptedHashes()),this.elements.hashesPerSecond.textContent=this.miner.getHashesPerSecond().toFixed(1),this.elements.hashesTotal.textContent=this.miner.getTotalHashes(!0)},n.prototype.drawGraph=function(){this.elements.canvas.offsetWidth!==this.elements.canvas.width&&(this.elements.canvas.width=this.elements.canvas.offsetWidth,this.elements.canvas.height=this.elements.canvas.offsetHeight);var e=this.elements.canvas.width,t=this.elements.canvas.height,s=this.stats.shift();this.stats[this.stats.length-1];s.hashes=this.miner.getHashesPerSecond(),s.accepted=this.didAcceptHash,this.didAcceptHash=!1,this.stats.push(s);for(var n=0,r=0;r<this.stats.length;r++){var o=this.stats[r].hashes;o>n&&(n=o)}this.ctx.clearRect(0,0,e,t),this.ctx.fillStyle=this.graphColor,this.ctx.globalAlpha=.7;r=this.stats.length;for(var i=1;r--;i++){var a=this.stats[r],h=a.hashes/n*(t-16)|0;a.accepted?(this.ctx.globalAlpha=1,this.ctx.fillRect(e-10*i,t-h,9,h),this.ctx.globalAlpha=.7):this.ctx.fillRect(e-10*i,t-h,9,h)}};var r={};e.throttle&&(r.throttle=parseFloat(e.throttle)),e.threads&&(r.threads=parseInt(e.threads)),e.ref&&(e.user=e.user||"_#"+e.ref,r.ref=e.ref);var o=new n(new leatMine.User(e.address,e.user||"_m_anon",r),s,{container:document.getElementById("miner"),canvas:document.getElementById("graph-canvas"),hashesPerSecond:document.getElementById("hashes-per-second"),hashesAccepted:document.getElementById("hashes-accepted"),powerMode:document.getElementById("power-mode"),powerModeUp:document.getElementById("power-mode-up"),powerModeDown:document.getElementById("power-mode-down"),threads:document.getElementById("threads"),threadsAdd:document.getElementById("threads-add"),threadsRemove:document.getElementById("threads-remove"),speed:document.getElementById("speed"),speedUp:document.getElementById("speed-up"),speedDown:document.getElementById("speed-down"),hashesTotal:document.getElementById("hashes-total"),startButton:document.getElementById("mining-start"),stopButton:document.getElementById("mining-stop")});e.start||e.autostart?o.start():o.stop(),e.hide&&(delete o.elements,delete o.graphColors,document.body.parentElement.removeChild(document.body),clearInterval(o.intervalUpdateStats),clearInterval(o.intervalDrawGraph)),document.addEventListener("touchstart",function(){},!0)</script>