// Generated by CoffeeScript 1.6.2
(function() {
  "use strict";
  var loadData;

  loadData = function(data) {
    return window.ma_app.drawGraph(data);
  };

  window.log = function(msg) {
    if (console) {
      return console.log(msg);
    }
  };

  window.ma = {};

  window.ma.callbackMsg = "";

  window.ma.Data = {};

  window.ma_app = window.ma_app || {};

  window.ma.isDemo = function() {
    var isDemo, ua;

    ua = navigator.userAgent.toLowerCase();
    isDemo = true;
    if (/firefox/.test(ua)) {

    } else if (/safari/.test(ua)) {

    } else if (/chrome/.test(ua)) {

    } else if (/opera/.test(ua)) {

    } else if (/msie 7/.test(ua)) {
      isDemo = false;
    } else if (/msie/.test(ua)) {

    } else {
      isDemo = false;
    }
    return isDemo;
  };

  window.ma.Callback = function(msg) {
    var url;

    url = "#/" + Math.random() + "/callback.html";
    window.ma.callbackMsg = msg;
    return window.open(url, '_self', '', false);
  };

  window.ma.FormEvent = function(action, param) {
    var err, json, ret;

    json = "";
    ret = "";
    if (!action && ma.isDemo()) {
      loadData(ma_app.exampleData());
    } else {
      if (action === "AddData") {
        if (param) {
          json += param.replace("*ksQS*", "'");
        } else {
          ret = "'AddData' parameter is missing (ma.FormEvent)";
        }
      } else if (action === "SetData") {
        if (param) {
          json += param.replace("*ksQS*", "'");
          try {
            window.ma.Data = JSON.parse(json);
          } catch (_error) {
            err = _error;
            ret = "'SetData' JSON.parse failed (ma.FormEvent), error: " + err;
            alert(ret);
          }
          if (ret === "") {
            ret = "" + action;
            try {
              loadData(window.ma.Data);
            } catch (_error) {
              err = _error;
              ret = "'SetData' loadData() failed (ma.FormEvent), error: " + err;
              alert(ret);
            }
          }
        } else {
          ret = "'SetData' parameter is missing (ma.FormEvent)";
        }
      } else {
        ret = "No action defined: '" + param + "' (ma.FormEvent)";
      }
    }
    return ret;
  };

}).call(this);

/*
//@ sourceMappingURL=app.map
*/
