JSFiddle - React, Tailwind, and code Playground

by aknuds1

HTML

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/themes/base/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.min.js"></script>
<button id="button-status">Click me!</button>
<div id="dialog-content" style="display:none">
    Getting binary ID...
    <div id="spinner" class="loading"></div>
</div>
<div id="errordialog-message" style="display:none" class="ui-state-error" title="Failure Getting Binary Build ID">
  <p class="ui-state-error-text">Couldn't get binary ID from Web server :(</p>
</div>

CSS

div.loading
{
    background: url(http://getitdone.googlecode.com/files/spinner.gif) no-repeat center center;
    display: none;
    width: 16px;
    height: 16px;
}

JavaScript

var status = function() {
    var init = function(id) {
        var progressDialog = $("#dialog-content").dialog({
            autoOpen: false,
            title: "Launching Status Page"
        });
        var errorDialog = $("#errordialog-message").dialog({
            autoOpen: false,
            modal: true,
            buttons: {
                "OK": function() {
                    $(this).dialog("close");
                }
            }
        });

        var handleClick = function() {
            $("#spinner").show();
            progressDialog.dialog("open");
            var url = $.validator.format("/api/binid/?id={0}", id);
            // Call Web service to get binary ID
            $.ajax({
                url: url,
                datatype: "json"
            }).always(function() {
                progressDialog.dialog("close");
            }).done(function(data) {
                window.open($.validator.format("http://status/?Page=Status&Id={0}", data), target = "_newtab");
            }).fail(function(jqXHR, msg, errorThrown) {
                errorDialog.dialog("open");
            });

            return false;
        }

        var btn = $("#button-status");
        btn.button().click(handleClick); //.qtip({
        //content: $.validator.format("Launch status page for binary corresponding to {0}", id)
        //});
    };

    return {
        init: init,
    };
}();

$(document).ready(function() {
    status.init("1");
});