-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidateFile.jsp
154 lines (110 loc) · 3.79 KB
/
validateFile.jsp
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<%@ page import="java.io.*, java.util.*,java.lang.*" %>
<HTML>
<HEAD>
<style>
#resultdiv{
background-color: #f3f3f3;
margin-left:20%;
margin-top:30px;
width: 55%;
min-height:70%;
border:3px solid;
border-color:#8fadff;
border-radius:25px;
}
#result{
padding:30px;
<<<<<<< HEAD
font: normal 14px courier !important;
=======
font: normal 12px courier !important;
>>>>>>> a32b1107a54a996ad8f8f1892ca0c590d574b191
}
</style>
<<<<<<< HEAD
=======
>>>>>>> a32b1107a54a996ad8f8f1892ca0c590d574b191
<script src="jshint.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
<<<<<<< HEAD
function parseline(str,a,b,c,d){
var res = str.replace('{a}',a);
res = res.replace('{b}',b);
res = res.replace('{c}',c);
res = res.replace('{d}',d);
return res;
}
=======
>>>>>>> a32b1107a54a996ad8f8f1892ca0c590d574b191
$(document).ready( function(){
var path = $('#debug').val();
console.log(path);
var cont = $('#rulename').val();
<<<<<<< HEAD
console.log(cont);
JSHINT(cont);
var res = JSON.stringify(JSHINT.errors, null, 2);
if (JSHINT.errors.length==0){
$('#result').html('No Errors were Found');
return;
}
for (var i=0;i<JSHINT.errors.length;i++){
console.log(JSHINT.errors[i]);
var obj = JSHINT.errors[i];
var a = obj.a;
var b = obj.b;
var c = obj.c;
var d = obj.d;
var objerr = obj.id;
var rawobj = obj.raw;
var rawS = parseline(rawobj,a,b,c,d);
var line = obj.line;
var char = obj.character;
var error = 'Error: '+objerr+' '+'Description: '+rawS+' '+'line: '+line+' '+'charecter: '+char;
//var error = JSON.stringify(obj, null, 2);
var html = $('#result').html() + '<br/>'+ error;
$('#result').html(html);
}
=======
JSHINT(cont);
var res = JSON.stringify(JSHINT.errors, null, 2);
console.log(res);
$('#result').text(res);
>>>>>>> a32b1107a54a996ad8f8f1892ca0c590d574b191
});
</script>
<TITLE>JSHint Checker</TITLE>
</HEAD>
<BODY>
<br/>
<H1 style="mergin-top:20px; margin-left:40%;">JSHint check</H1>
<br/>
<%
String path = org.uva.Implicit.REALPATH+request.getParameter("study");
//String file = request.getParameter("file");
//String path = new String ("C:/projects/workspace/rc1/app/user/bgoldenberg/study1/local.js");
String content = null;
File file = new File(path);
try {
FileReader reader = new FileReader(file);
char[] chars = new char[(int) file.length()];
reader.read(chars);
content = new String(chars);
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
%>
<<<<<<< HEAD
<textarea id="rulename" style="display:none;" name="Language"><%=content%></textarea>
=======
<input type="hidden" id="rulename" name="Language" value="<%=content%>">
>>>>>>> a32b1107a54a996ad8f8f1892ca0c590d574b191
<input type="hidden" id="debug" name="Language" value="<%=path%>">
<div id="resultdiv" style="">
</br>
<label id="result" ></label>
</div>
</BODY>
</HTML>