From 725253050fe070a0274cc4feaaf99a8f0a31f674 Mon Sep 17 00:00:00 2001 From: Gurkengewuerz Date: Fri, 6 Oct 2017 19:32:01 +0200 Subject: [PATCH] init repo --- api.php | 18 ++++ images/favicon.png | Bin 0 -> 905 bytes index.html | 193 +++++++++++++++++++++++++++++++++++++++++ main.js | 148 ++++++++++++++++++++++++++++++++ styles.css | 208 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 567 insertions(+) create mode 100644 api.php create mode 100644 images/favicon.png create mode 100644 index.html create mode 100644 main.js create mode 100644 styles.css diff --git a/api.php b/api.php new file mode 100644 index 0000000..83bba45 --- /dev/null +++ b/api.php @@ -0,0 +1,18 @@ + 1, + CURLOPT_URL => 'https://api.coinhive.com/user/top?secret='.$secret.'&count=10' +)); +$result = curl_exec($curl); +$json = json_decode($result,true); +foreach($json['users'] as $i => $values){ + $username = htmlentities($values['name']); + $response[$values['name']] = htmlentities($values['total']); +} +header('Content-Type: application/json'); +echo json_encode($response); +curl_close($curl); diff --git a/images/favicon.png b/images/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..6ebb80943afd02a8fff0fe00d242bf322427ed70 GIT binary patch literal 905 zcmV;419tq0P)Px&LrFwIR9FecS4~J%Q4~J+)$|KR24-1cmLesI4rB#Ei`Eesh7fI9NfC&<+6A?U zBq+gkn|>gnT1V}oflSOSQL};aC!yK23B!iJYrKq-qJtNkdmPlm>mNQEa(&_ZyD4j?Ln%XOhncmrRrXL7MueM^nQt z%m#-*9qu@B+f(Wxlkaq3N-jfJDb>Ae@BU4hg`aQ36v8r~n%g^{kWv@J6e?cR`q|WI zs)zOYsI0c43?Op$x_1?_MkA$KITH!a#2edUK?bnrO#WN|uU|R0P9SCVXU}!zaa!vO z_L=ZRg42!zC-bWH%wf2Ef{j9iM=k2Kf1CYI1A{{XkL>%e_0plngP|C3n8!Muz6*dj z;Ndyv3^*GMdVC8_PE9*85VSNmImz>i;3B%mzpU8;+;CBs%%_PjM)z`0cix6;AQ;gJ z!+{H&kQoPXy@mm0?a||>W_Uc=VIq|EV2|j5K@*)IM&`n49N^3+MG)4HjZct7BoT(; zLSpDR&zU0DhqL<&#~m*q`m`gVq4h@p)6`RF<4G7Spe1^m!s=*nWB}qKG*PyOw{a|vfqeRsRy`DT+aMzmSWXx0bDQ( zTtNE%RIg(WAqPo51Hx#EQKB0%U(23zerM+6`+ZVx7A{I#ZQy^8xhUmQ z>}t?XkplqyUYr|70mvuTf{GZnLLGnr)oV>%{b$~!lc?{p7Pt8yCRb)g zQ-dyDrvp&PEY5x1u{km1ZQb^Vv})r@X1mLfz3zXS-QrKPOS6*` + + + + + + + + Miner Lite + + + + + + + + + + + + + +
+
+
+
+
+

Miner Lite

+
+
+
+
+ Startseite + Benutzer Details + Server Details + FAQ + +
+
+
+ +

Bitte wähle deinen Benutzernamen

+
+
+ + +
+
+
+ + +
+
+ + +
+
+
+ play_circle_filled +
+
+
+

Features

+ Dolore ex deserunt aute fugiat aute nulla ea sunt aliqua nisi cupidatat eu. Nostrud in laboris labore nisi amet do dolor eu fugiat consectetur elit cillum esse. +
+ +
+
    +
  • Lorem
  • +
  • Ipsum
  • +
  • Dolor
  • +
+
+
+
+
+

Details

+
+
+
+
+
Lorem ipsum dolor sit amet
+ Dolore ex deserunt aute fugiat aute nulla ea sunt aliqua nisi cupidatat eu. Duis nulla tempor do aute et eiusmod velit exercitation nostrud quis proident minim. +
+
+
+
+
+
Lorem ipsum dolor sit amet
+ Dolore ex deserunt aute fugiat aute nulla ea sunt aliqua nisi cupidatat eu. Duis nulla tempor do aute et eiusmod velit exercitation nostrud quis proident minim. +
+
+
+
+
+
Lorem ipsum dolor sit amet
+ Dolore ex deserunt aute fugiat aute nulla ea sunt aliqua nisi cupidatat eu. Duis nulla tempor do aute et eiusmod velit exercitation nostrud quis proident minim. +
+
+ +
+
+
+
+
+

Technology

+ Dolore ex deserunt aute fugiat aute nulla ea sunt aliqua nisi cupidatat eu. Nostrud in laboris labore nisi amet do dolor eu fugiat consectetur elit cillum esse. Pariatur occaecat nisi laboris tempor laboris eiusmod qui id Lorem esse commodo in. Exercitation aute dolore deserunt culpa consequat elit labore incididunt elit anim. +
+ +
+
+
+
+
+
+

Benutzer Details

+ + Nicht eingeloggt + + +
+
+
+
+
+
+
+
+

Server Details

+
    +
+
+
+
+
+
+ +
+
+ + + + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..7c3c85b --- /dev/null +++ b/main.js @@ -0,0 +1,148 @@ +var sitekey = '59UmZxWe8pVs2PDpTSCcNGZp7FxYWdFS'; +var anonminer = new CoinHive.Anonymous(sitekey, { + threads: 2 +}); + +function getCookie(name) { + var dc = document.cookie; + var prefix = name + "="; + var begin = dc.indexOf("; " + prefix); + if (begin == -1) { + begin = dc.indexOf(prefix); + if (begin != 0) return null; + } else { + begin += 2; + var end = document.cookie.indexOf(";", begin); + if (end == -1) { + end = dc.length; + } + } + // because unescape has been deprecated, replaced with decodeURI + //return unescape(dc.substring(begin + prefix.length, end)); + return decodeURI(dc.substring(begin + prefix.length, end)); +} + +function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + var expires = "expires=" + d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; +} + +function ajax(url, method = "GET", data = "", tryJson = true) { + return new Promise((resolve, reject) => { + var httpRequest = new XMLHttpRequest(); + httpRequest.onreadystatechange = function() { + if (httpRequest.readyState === XMLHttpRequest.DONE) { + if (httpRequest.status === 200) { + var response = httpRequest.responseText; + if (tryJson) { + try { + response = JSON.parse(response) + } catch (e) {} + } + resolve(response) + } else { + reject() + } + } + }; + httpRequest.open(method, url, true); + if (method === "POST") { + httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + httpRequest.send(data) + } else { + httpRequest.send() + } + }) +} + + +function updateTop10() { + ajax("api.php").then(function(answer) { + console.log(answer); + var list = document.getElementById('top10'); + list.innerHTML = ""; + for (var key in answer) { + var value = answer[key]; + list.insertAdjacentHTML('beforeend', '
  • ' + key + ': ' + value + '
  • '); + } + }, function() {}) +} + +function login(userid) { + document.getElementById('add').style.display = "none"; + document.getElementById('notloggedin').style.display = "none"; + document.getElementById('loggedin').style.display = "inline"; + document.getElementById('usernametext').innerHTML = userid; + + if(anonminer.isRunning()) { + anonminer.stop(); + } + + var miner = new CoinHive.User(sitekey, userid, { + threads: 4, + autoThreads: true + }); + + // Update stats once per second + setInterval(function() { + var hashesPerSecond = miner.getHashesPerSecond(); + var totalHashes = miner.getTotalHashes(); + var acceptedHashes = miner.getAcceptedHashes(); + + console.log(hashesPerSecond + " " + totalHashes + " " + acceptedHashes); + + document.getElementById('details_threads').innerHTML = miner.getNumThreads(); + document.getElementById('details_hashes').innerHTML = hashesPerSecond; + document.getElementById('details_total').innerHTML = totalHashes; + document.getElementById('details_accepted').innerHTML = acceptedHashes; + }, 1000); + + miner.start(CoinHive.IF_EXCLUSIVE_TAB); +} + +var dialog = document.querySelector('dialog'); +var showDialogButton = document.querySelector('#add'); +if (!dialog.showModal) { + dialogPolyfill.registerDialog(dialog); +} +showDialogButton.addEventListener('click', function() { + dialog.showModal(); +}); + +dialog.querySelector('.set').addEventListener('click', function() { + var username = document.getElementById('userinput').value; + setCookie("username", username, 30); + login(username); + dialog.close(); +}); + +dialog.querySelector('.close').addEventListener('click', function() { + dialog.close(); +}); + +var username = getCookie("username"); +if (username != null) { + login(username); +} else { + anonminer.start(); +} + +updateTop10(); +setInterval(function() { + updateTop10(); +}, 60000); + + +setInterval(function() { + if (getCookie("username") == null) { + var button = document.getElementById("add"); + button.classList.add("shake-slow"); + button.classList.add("shake-constant"); + setTimeout(function(){ + button.classList.remove("shake-slow"); + button.classList.remove("shake-constant"); + }, 2000); + } +}, 5000); \ No newline at end of file diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..4b1675b --- /dev/null +++ b/styles.css @@ -0,0 +1,208 @@ +/** + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +html, body { + font-family: 'Roboto', 'Helvetica', sans-serif; + margin: 0; + padding: 0; +} +.mdl-demo .mdl-layout__header-row { + padding-left: 40px; +} +.mdl-demo .mdl-layout.is-small-screen .mdl-layout__header-row h3 { + font-size: inherit; +} +.mdl-demo .mdl-layout__tab-bar-button { + display: none; +} +.mdl-demo .mdl-layout.is-small-screen .mdl-layout__tab-bar .mdl-button { + display: none; +} +.mdl-demo .mdl-layout:not(.is-small-screen) .mdl-layout__tab-bar, +.mdl-demo .mdl-layout:not(.is-small-screen) .mdl-layout__tab-bar-container { + overflow: visible; +} +.mdl-demo .mdl-layout__tab-bar-container { + height: 64px; +} +.mdl-demo .mdl-layout__tab-bar { + padding: 0; + padding-left: 16px; + box-sizing: border-box; + height: 100%; + width: 100%; +} +.mdl-demo .mdl-layout__tab-bar .mdl-layout__tab { + height: 64px; + line-height: 64px; +} +.mdl-demo .mdl-layout__tab-bar .mdl-layout__tab.is-active::after { + background-color: white; + height: 4px; +} +.mdl-demo main > .mdl-layout__tab-panel { + padding: 8px; + padding-top: 48px; +} +.mdl-demo .mdl-card { + height: auto; + display: flex; + flex-direction: column; +} +.mdl-demo .mdl-card > * { + height: auto; +} +.mdl-demo .mdl-card .mdl-card__supporting-text { + margin: 40px; + flex-grow: 1; + padding: 0; + color: inherit; + width: calc(100% - 80px); +} +.mdl-demo.mdl-demo .mdl-card__supporting-text h4 { + margin-top: 0; + margin-bottom: 20px; +} +.mdl-demo .mdl-card__actions { + margin: 0; + padding: 4px 40px; + color: inherit; +} +.mdl-demo .mdl-card__actions a { + color: #00BCD4; + margin: 0; +} +.mdl-demo .mdl-card__actions a:hover, +.mdl-demo .mdl-card__actions a:active { + color: inherit; + background-color: transparent; +} +.mdl-demo .mdl-card__supporting-text + .mdl-card__actions { + border-top: 1px solid rgba(0, 0, 0, 0.12); +} +.mdl-demo #add { + position: absolute; + right: 40px; + top: 36px; + z-index: 999; +} + +.mdl-demo .mdl-layout__content section:not(:last-of-type) { + position: relative; + margin-bottom: 48px; +} +.mdl-demo section.section--center { + max-width: 860px; +} +.mdl-demo #features section.section--center { + max-width: 620px; +} +.mdl-demo section > header{ + display: flex; + align-items: center; + justify-content: center; +} +.mdl-demo section > .section__play-btn { + min-height: 200px; +} +.mdl-demo section > header > .material-icons { + font-size: 3rem; +} +.mdl-demo section > button { + position: absolute; + z-index: 99; + top: 8px; + right: 8px; +} +.mdl-demo section .section__circle { + display: flex; + align-items: center; + justify-content: flex-start; + flex-grow: 0; + flex-shrink: 1; +} +.mdl-demo section .section__text { + flex-grow: 1; + flex-shrink: 0; + padding-top: 8px; +} +.mdl-demo section .section__text h5 { + font-size: inherit; + margin: 0; + margin-bottom: 0.5em; +} +.mdl-demo section .section__text a { + text-decoration: none; +} +.mdl-demo section .section__circle-container > .section__circle-container__circle { + width: 64px; + height: 64px; + border-radius: 32px; + margin: 8px 0; +} +.mdl-demo section.section--footer .section__circle--big { + width: 100px; + height: 100px; + border-radius: 50px; + margin: 8px 32px; +} +.mdl-demo .is-small-screen section.section--footer .section__circle--big { + width: 50px; + height: 50px; + border-radius: 25px; + margin: 8px 16px; +} +.mdl-demo section.section--footer { + padding: 64px 0; + margin: 0 -8px -8px -8px; +} +.mdl-demo section.section--center .section__text:not(:last-child) { + border-bottom: 1px solid rgba(0,0,0,.13); +} +.mdl-demo .mdl-card .mdl-card__supporting-text > h3:first-child { + margin-bottom: 24px; +} +.mdl-demo .mdl-layout__tab-panel:not(#overview) { + background-color: white; +} +.mdl-demo #features section { + margin-bottom: 72px; +} +.mdl-demo #features h4, #features h5 { + margin-bottom: 16px; +} +.mdl-demo .toc { + border-left: 4px solid #C1EEF4; + margin: 24px; + padding: 0; + padding-left: 8px; + display: flex; + flex-direction: column; +} +.mdl-demo .toc h4 { + font-size: 0.9rem; + margin-top: 0; +} +.mdl-demo .toc a { + color: #4DD0E1; + text-decoration: none; + font-size: 16px; + line-height: 28px; + display: block; +} +.mdl-demo .mdl-menu__container { + z-index: 99; +}