Sha256: a867ec47b499f48e149ac104070df40205ceb2f625119f737668640e3f98697c

Contents?: true

Size: 982 Bytes

Versions: 4

Compression:

Stored size: 982 Bytes

Contents

$(document).ready(function() {
  var timeout = null;
  var updater = function(target) {
    if(timeout)
      clearTimeout(timeout);

    var target = $("#ops");
    if(!target || target.length == 0)
      return;

    $.ajax({url: "/ops.json", type: "GET", dataType: "json", success: function(data) {
        var html = "";
        for(var prop in data) {
          html += "<b>"+prop+"=</b> ";
          html += data[prop] + "<br/>";
        }
        target.html(html);
      }
    });
    timeout = setTimeout(updater, 1500);
  };

  $('div[data-role*="page"]').live('pagehide',function(event, ui) {
    if(timeout)
      clearTimeout(timeout);
  });

  $('div[data-role*="page"]').live('pageshow',function(event, ui) {
    var page = $(event.target);
    var target = page.find("#ops");

    if(page.hasClass("status_page") && target.length > 0) {
      target.html("processing...");
      updater(target);
    } else if(timeout) {
      clearTimeout(timeout);
    }
  });
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongobile-0.1.5 public/javascripts/status.js
mongobile-0.1.4 public/javascripts/status.js
mongobile-0.1.3 public/javascripts/status.js
mongobile-0.1.2 public/javascripts/status.js