Sha256: 6c672c9bfd9d5a171585b5c17bfb05c5722a95a78a0a24cddf6d939d69a7cde4

Contents?: true

Size: 1.63 KB

Versions: 7

Compression:

Stored size: 1.63 KB

Contents

var tabs, go, editor;
function stamina_init() {
  menu = $("#menu");
  menu.accordion();
  $("#menu a.example").click(function(obj) {
    stamina_load_example(obj.srcElement.pathname);
    return false;
  });

  tabs = $("#center");
  tabs.tabs({ 
    cache: false 
  });

  go   = $("#go");
  go.button();
  go.click(function(){ 
    stamina_go();
    return false;
  });

  editor = ace.edit("editor");
  //editor.setTheme("ace/theme/textmate");
  //editor.setTheme("ace/theme/twilight");
  editor.setTheme("ace/theme/eclipse");
  var RubyMode = require("ace/mode/ruby").Mode;
  editor.getSession().setMode(new RubyMode());
};

function stamina_go() {
  $.ajax({
    type: 'POST',
    url: '/go',
    data: {src: editor.getSession().getValue()},
    contentType: "application/x-www-form-urlencoded",
    success: function(data) {
      stamina_refresh_tabs(data);
    },
    error: function(xhr, ajaxOptions, thrownError){
      stamina_error(xhr.responseText);
    }
  });
};

function stamina_clean_tabs() {
  while (tabs.tabs("length") > 1) {
    tabs.tabs("remove", tabs.tabs("length") - 1);
  };
};

function stamina_refresh_tabs(variables) {
  stamina_clean_tabs();
  $.each(variables, function(i, x){
    tabs.tabs("add", "/image/" + x, x);
  });
  tabs.tabs("select", 1);
};

function stamina_error(text) {
  stamina_clean_tabs();
  tabs.tabs({
    load: function(event, ui){ 
      $("#feedback").html(text);
    }
  });
  tabs.tabs("add", "/feedback.html", "Error");
  tabs.tabs("select", 1);
};

function stamina_load_example(path) {
  stamina_clean_tabs();
  $.get("/examples" + path, function(data){
    editor.getSession().setValue(data);
  });
};

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stamina-gui-0.6.1 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.6.0 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.5.4 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.5.3 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.5.2 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.5.1 lib/stamina-gui/stamina/gui/public/js/stamina.js
stamina-gui-0.5.0 lib/stamina-gui/stamina/gui/public/js/stamina.js