-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.html
100 lines (93 loc) · 4.83 KB
/
debug.html
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
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="./pdf.js"></script>
<script type="text/javascript">
//disable f5 and tab
//disable f5 and tab
window.addEventListener("keydown",
function(e){
switch(e.keyCode){
case 116: e.preventDefault(); break; // Space
default: break; // do not block other keys
}
},
false);
$(document).delegate('textarea', 'keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
e.preventDefault();
var start = $(this).get(0).selectionStart;
var end = $(this).get(0).selectionEnd;
// set textarea value to: text before caret + tab + text after caret
$(this).val($(this).val().substring(0, start)
+ "\t"
+ $(this).val().substring(end));
// put caret at right position again
$(this).get(0).selectionStart =
$(this).get(0).selectionEnd = start + 1;
}
});
$(document).ready(function(){
$('#submit').click(function(){
var doc = new pdf();
doc.setProperties({
title: 'Routine PDF',
subject: 'routine',
author: 'Ryan Wong'
});
// doc.addPage();
//doc.setFontSize(22);
/*doc.drawLine(100, 100, 100, 120, 1.0, 'dashed');
doc.drawLine(100, 100, 120, 100, 1.2, 'dotted');
doc.drawLine(120, 120, 100, 120, 1.4, 'dashed');
doc.drawLine(120, 120, 120, 100, 1.6, 'solid');
doc.drawRect(140, 140, 10, 10, 'solid');
*/
doc.setFont('Courier');
doc.setFontSize(9);
var start = 10;
var increment = 5;
start = titleline(doc,'Error: ' + $('#function-name').val(),start,increment);
start = titleline(doc,'Data Associated with Error:',start,increment);
start = multiline(doc,$('#error-handle').val(),start,increment);
start = titleline(doc,'Hypothesis for Error:',start,increment);
start = multiline(doc,$('#hypothesis').val(),start,increment);
start = titleline(doc,'How to Prove Hypothesis:',start,increment);
start = multiline(doc,$('#prove').val(),start,increment);
start = titleline(doc,'Result',start,increment);
start = multiline(doc,$('#result').val(),start,increment);
var fileName = "routine-"+$('#function-name').val()+".pdf";
var pdfAsDataURI = doc.output('datauri', {"fileName":fileName});
$('#pdfLink').html('<a href = "'+pdfAsDataURI+'">'+fileName+'</a>');
function titleline(doc,str,start,increment){
doc.text(5,start,str);
start= start + increment;
return start;
}
function multiline(doc,str,start,increment){
var problemstatement = str.split("\n");
for(x in problemstatement){
doc.text(10,start,problemstatement[x]);
start= start + increment;
}
return start;
}
});
});
</script>
</head>
<body>
<div>
<center>
<center><h1>Debugging</h1></center>
<p>Error:</p><input type="text" id="function-name" size="100"/>
<p>Data Associated with Error:</p><textarea id="error-handle" rows="4" cols="100"></textarea>
<p>Hypothesis for Error:</p><textarea id="hypothesis" rows="4" cols="100"></textarea>
<p>How to Prove Hypothesis:</p><textarea id="prove" rows="4" cols="100"></textarea>
<p>Result:</p><textarea id="result" rows="4" cols="100"></textarea>
<center><input type="button" id="submit" value="Create Document"/><span id="pdfLink"></span></center>
</center>
</div>
</body>
</html>