1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
$(function() {
jQuery.fn.toggleWarnings = function(id) {
var id = id;
this.bind("click", function() {
if($("a#show_model_" + id + "_warnings").html()=="show") {
$("dd#model_" + id + "_warnings").slideDown("slow");
$("a#show_model_" + id + "_warnings").html("hide");
}else{
$("dd#model_" + id + "_warnings").slideUp("slow");
$("a#show_model_" + id + "_warnings").html("show");
}
return false;
});
};
checkStati = function(stati) {
stati = stati.split(", ")
$("body")
var newstati = new Array;
$.each(stati, function(){
if(checkStatus(this) > 0) newstati.push(this);
});
if (newstati.length > 0) var statusCheck = setTimeout('checkStati("' + newstati.join(", ") + '")',10000);
};
checkStatus = function(id) {
if(id == "") return -1;
var opts = {method: 'get', action: 'model/' + id + '/status', id: id};
var status_changed = $.ajax({
type: opts.method,
url: opts.action,
async: false,
dataType: 'html',
data: {
'_method': 'get'
},
success: function(data) {
var erg = data.search(/Running/);
status_changed = false;
if(erg < 0) status_changed = true;
$("span#model_" + id + "_status").animate({"opacity": "0.1"},1000);
$("span#model_" + id + "_status").animate({"opacity": "1"},1000);
if( status_changed ) {
$("span#model_" + id + "_status").html(data);
loadModel(id, 'model');
id = -1;
}
},
error: function(data) {
//alert("status check error");
id = -1;
}
});
return id;
};
loadModel = function(id, view) {
if(id == "") return -1;
var opts = {method: 'get', action: 'model/' + id + '/' + view, view: view };
var out = id;
$.ajax({
type: opts.method,
url: opts.action,
dataType: 'html',
data: {
'_method': 'get'
},
success: function(data) {
if (view == "model") $("div#model_" + id).html(data);
if (view.match(/validation/)) $("dl#model_validation_" + id).html(data);
},
error: function(data) {
//alert("loadModel error");
}
});
return false;
};
checkValidation = function() {
var reload_id = "";
$("input.model_validation_report").each(function(){
if(!$(this).val().match(/Completed|Error/)) {
reload_id = this.id.replace("model_validation_report_","");
if(/^\d+$/.test(reload_id)) loadModel(reload_id, 'validation');
};
});
var validationCheck = setTimeout('checkValidation()',15000);
}
});
jQuery.fn.deleteModel = function(type, options) {
var defaults = {
method: 'post',
action: this.attr('href'),
confirm_message: 'Are you sure?',
trigger_on: 'click'
};
var opts = $.extend(defaults, options);
this.bind(opts.trigger_on, function() {
if(confirm(opts.confirm_message)) {
$(opts.elem).fadeTo("slow",0.5);
$.ajax({
type: opts.method,
url: opts.action,
dataType: 'html',
data: {
'_method': 'delete'
},
success: function(data) {
$(opts.elem).fadeTo("slow",0).slideUp("slow").remove();
},
error: function(data) {
//alert("model delete error!");
}
});
}
return false;
});
};
|