2
// Copyright (C) 2008-2014 Centaur Technology
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/
9
// License: (An MIT/X11-style license)
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:
18
// The above copyright notice and this permission notice shall be included in
19
// all copies or substantial portions of the Software.
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.
29
// Original author: Jared Davis <jared@centtech.com>
31
function make_model_list_table(data)
33
var div = jQuery("<table></table>");
35
div.append("<p>No models</p>");
39
var keys = Object.keys(data);
43
var models = data[base];
46
entry += "<td class='modelnames'>";
47
for(var m = 0; m < models.length; m++)
49
var model = models[m];
50
entry += "<a href=\"javascript:void(0)\" ";
51
entry += "onclick=\"loadModel('" + base + "', '" + model + "')\">";
54
if (m != models.length - 1)
58
entry += "<td class='basename'><nobr>" + base + "</nobr></td>";
67
// Don't use vlsGetJson because this is a special pre-model-loading command
68
// that has no MODEL/BASE.
74
success: function(data,textStatus,jqXHR) {
76
$("#loaded").html("Error: " + data[":ERROR"]);
79
var div = make_model_list_table(data[":VALUE"]);
80
$("#loaded").html(div);
83
$("#loaded").html("<p>Error listing models.</p>");
88
function get_unloaded()
90
// Don't use vlsGetJson because this is a special pre-model-loading command
91
// that has no MODEL/BASE.
93
url: "/list-unloaded",
97
success: function(data,textStatus,jqXHR) {
99
$("#unloaded").html("<p>Error: " + data[":ERROR"]);
103
var div = make_model_list_table(data[":VALUE"]);
104
$("#unloaded").html(div);
107
$("#unloaded").html("<p>Error listing unloaded.</p>");
112
$(document).ready(function()
118
var showedLoadingMessage = false;
120
function loadModel(base, model)
122
console.log("loadModel(" + base + ", " + model + ")");
126
data: {"base":base, "model":model},
129
success: function(data,textStatus,jqXHR)
131
if (data[":ERROR"]) {
132
$("body").html("Error: " + data[":ERROR"]);
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);
142
else if (status == ":STARTED")
144
if (!showedLoadingMessage) {
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>";
154
$("#loading").html(msg);
155
showedLoadingMessage = true;
158
$("#progress").append(".");
160
setTimeout(function() { loadModel(base, model); }, 5000);
163
$("#content").html("<p>Unexpected response from server: "
165
+ "status " + status + "</p>");
170
$("#content").html("<p>Error posting load_model request.</p>");