Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var api_key;
- var timer;
- $(document).ready(function () {
- if($.cookie("api_key") != null) {
- api_key = $.cookie("api_key");
- $("#api_key").hide();
- $("#submit").val("Logout");
- load_content();
- }
- $("#submit").click(function () {
- if(api_key == null) {
- login();
- } else {
- logout();
- }
- });
- });
- function login() {
- api_key = $("#api_key").val();
- $.cookie("api_key", api_key);
- $("#api_key").hide("slow");
- $("#submit").val("Logout");
- load_content();
- }
- function logout() {
- $.cookie("api_key", null);
- api_key = null;
- $("#api_key").show("slow");
- $("#submit").val("Login");
- $("#content").hide("slow");
- }
- function load_content() {
- jQuery.ajax({
- url: "proxy.php?api_key="+api_key,
- dataType: 'JSON',
- success:function(data){
- $("#content").show("slow");
- $("#errmsg").text("");
- show_data(data);
- timer = setInterval(load_content, 60000);
- },
- error: function(errorThrown){
- $("#errmsg").text("Invalid API Key");
- logout();
- }
- });
- }
- function show_data(data) {
- var workers = 0;
- var active_workers = 0;
- var hash_rate = data["hashrate"];
- var paid = data["confirmed_reward"];
- var table = '<table border="1" cellspacing="1" cellpadding="11">';
- table += "<tr><th>Name</th><th>Shares</th><th>Stale</th><th>%</th></tr>";
- $.each(data["workers"], function(index, item){
- table += "<tr><td>"+index+"</td><td>"+item.shares+"</td><td>"+item.stales+"</td><td>"+Math.round(((item.shares-item.stales)/item.shares)*100).toFixed(2)+"</td></tr>";
- if(item.alive == "true") {
- workers++;
- active_workers++;
- } else {
- workers++;
- }
- });
- table += '</table>';
- $("#content").html(active_workers +" of "+ workers + " workers @ " + hash_rate + " Mhash/sec<br/>" + paid + " BTC Pending" + "<br/>" +table);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement