~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/centaur/vl/server/public/index.js

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// VL Verilog Toolkit
 
2
// Copyright (C) 2008-2014 Centaur Technology
 
3
//
 
4
// Contact:
 
5
//   Centaur Technology Formal Verification Group
 
6
//   7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
 
7
//   http://www.centtech.com/
 
8
//
 
9
// License: (An MIT/X11-style license)
 
10
//
 
11
//   Permission is hereby granted, free of charge, to any person obtaining a
 
12
//   copy of this software and associated documentation files (the "Software"),
 
13
//   to deal in the Software without restriction, including without limitation
 
14
//   the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
15
//   and/or sell copies of the Software, and to permit persons to whom the
 
16
//   Software is furnished to do so, subject to the following conditions:
 
17
//
 
18
//   The above copyright notice and this permission notice shall be included in
 
19
//   all copies or substantial portions of the Software.
 
20
//
 
21
//   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
//   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
//   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 
24
//   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
//   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
//   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
27
//   DEALINGS IN THE SOFTWARE.
 
28
//
 
29
// Original author: Jared Davis <jared@centtech.com>
 
30
 
 
31
function make_model_list_table(data)
 
32
{
 
33
    var div = jQuery("<table></table>");
 
34
    if (data == "NIL") {
 
35
        div.append("<p>No models</p>");
 
36
        return div;
 
37
    }
 
38
 
 
39
    var keys = Object.keys(data);
 
40
    for(var i in keys)
 
41
    {
 
42
        var base = keys[i];
 
43
        var models = data[base];
 
44
        var entry = "";
 
45
        entry += "<tr>";
 
46
        entry += "<td class='modelnames'>";
 
47
        for(var m = 0; m < models.length; m++)
 
48
        {
 
49
            var model = models[m];
 
50
            entry += "<a href=\"javascript:void(0)\" ";
 
51
            entry += "onclick=\"loadModel('" + base + "', '" + model + "')\">";
 
52
            entry += model;
 
53
            entry += "</a>";
 
54
            if (m != models.length - 1)
 
55
                entry += ", ";
 
56
        }
 
57
        entry += "</td>";
 
58
        entry += "<td class='basename'><nobr>" + base + "</nobr></td>";
 
59
        entry += "</tr>";
 
60
        div.append(entry);
 
61
    }
 
62
    return div;
 
63
}
 
64
 
 
65
function get_loaded()
 
66
{
 
67
    // Don't use vlsGetJson because this is a special pre-model-loading command
 
68
    // that has no MODEL/BASE.
 
69
    $.ajax({
 
70
        url: "/list-loaded",
 
71
        data: null,
 
72
        dataType: "json",
 
73
        cache: false,
 
74
        success: function(data,textStatus,jqXHR) {
 
75
            if (data[":ERROR"]) {
 
76
                $("#loaded").html("Error: " + data[":ERROR"]);
 
77
                return;
 
78
            }
 
79
            var div = make_model_list_table(data[":VALUE"]);
 
80
            $("#loaded").html(div);
 
81
        },
 
82
        fail: function() {
 
83
            $("#loaded").html("<p>Error listing models.</p>");
 
84
        }
 
85
    });
 
86
}
 
87
 
 
88
function get_unloaded()
 
89
{
 
90
    // Don't use vlsGetJson because this is a special pre-model-loading command
 
91
    // that has no MODEL/BASE.
 
92
    $.ajax({
 
93
        url: "/list-unloaded",
 
94
        data: null,
 
95
        dataType: "json",
 
96
        cache: false,
 
97
        success: function(data,textStatus,jqXHR) {
 
98
            if (data[":ERROR"]) {
 
99
                $("#unloaded").html("<p>Error: " + data[":ERROR"]);
 
100
                return;
 
101
            }
 
102
 
 
103
            var div = make_model_list_table(data[":VALUE"]);
 
104
            $("#unloaded").html(div);
 
105
        },
 
106
        fail: function() {
 
107
            $("#unloaded").html("<p>Error listing unloaded.</p>");
 
108
        }
 
109
    });
 
110
}
 
111
 
 
112
$(document).ready(function()
 
113
{
 
114
    get_loaded();
 
115
    get_unloaded();
 
116
});
 
117
 
 
118
var showedLoadingMessage = false;
 
119
 
 
120
function loadModel(base, model)
 
121
{
 
122
    console.log("loadModel(" + base + ", " + model + ")");
 
123
    $.ajax({
 
124
        url: "/load-model",
 
125
        cache: false,
 
126
        data: {"base":base, "model":model},
 
127
        dataType: "json",
 
128
        type: "post",
 
129
        success: function(data,textStatus,jqXHR)
 
130
        {
 
131
            if (data[":ERROR"]) {
 
132
                $("body").html("Error: " + data[":ERROR"]);
 
133
                return;
 
134
            }
 
135
 
 
136
            var value = data[":VALUE"];
 
137
            var status = value[":STATUS"];
 
138
            console.log("Status: " + status);
 
139
            if (status == ":LOADED") {
 
140
                window.location = "main.html?base=" + encodeURIComponent(base) + "&model=" + encodeURIComponent(model);
 
141
            }
 
142
            else if (status == ":STARTED")
 
143
            {
 
144
                if (!showedLoadingMessage) {
 
145
                    var msg = "";
 
146
                    msg += "<div id='loadbox'>";
 
147
                    msg += "<h2><b>Loading " + model + " from " + base + "</b></h2>";
 
148
                    msg += "<p>This can take some time.  It usually completes within <b>2 minutes</b>, ";
 
149
                    msg += "except for some very large models.</p>";
 
150
                    msg += "<p>The page will automatically refresh when the model is ready.</p>";
 
151
                    msg += "<p id='progress'>.</p>";
 
152
                    msg += "<hr>";
 
153
                    msg += "</div>";
 
154
                    $("#loading").html(msg);
 
155
                    showedLoadingMessage = true;
 
156
                }
 
157
                else {
 
158
                    $("#progress").append(".");
 
159
                }
 
160
                setTimeout(function() { loadModel(base, model); }, 5000);
 
161
            }
 
162
            else {
 
163
                $("#content").html("<p>Unexpected response from server: "
 
164
                                   + "value " + value
 
165
                                   + "status " + status + "</p>");
 
166
            }
 
167
        },
 
168
        fail: function()
 
169
        {
 
170
            $("#content").html("<p>Error posting load_model request.</p>");
 
171
        }
 
172
    });
 
173
}