-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassembler.php
More file actions
193 lines (163 loc) · 6.6 KB
/
assembler.php
File metadata and controls
193 lines (163 loc) · 6.6 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<title>Assembler</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
</head>
<body>
<button type="button" class="btn btn-success" id="mot" onclick="MOT()">Machine Opcode Table</button>
<button type="button" class="btn btn-success" id="pot" onclick="POT()">Psuedo Opcode Table</button>
<button type="button" class="btn btn-success" id="sym">Symbol Table</button>
<?php
$con=mysqli_connect("localhost","root","","assembler");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
function MOT(){
$result = mysqli_query($con,"SELECT * FROM MOT");
echo '<div class="container"><div class="row"><div class="container"><div class="panel panel-primary filterable">
<div class="panel-heading">
<h3 class="panel-title">MOT</h3>
<div class="pull-right">
<button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>
</div>
</div>';
echo "<table border='1' class='table'>
<thead>
<tr class='filters'>
<th><input type='text' class='form-control' placeholder='Mnemonic' disabled></th>
<th><input type='text' class='form-control' placeholder='Size' disabled></th>
<th><input type='text' class='form-control' placeholder='Opcode' disabled></th>
</tr>
</thead>
<tbody>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Mnemonic'] . "</td>";
echo "<td>" . $row['Size'] . "</td>";
echo "<td>" . $row['Opcode'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table></div></div></div>";
}
function POT(){
$result = mysqli_query($con,"SELECT * FROM POT");
echo '<div class="container"><div class="row"><div class="container"><div class="panel panel-primary filterable">
<div class="panel-heading">
<h3 class="panel-title">MOT</h3>
<div class="pull-right">
<button class="btn btn-default btn-xs btn-filter"><span class="glyphicon glyphicon-filter"></span> Filter</button>
</div>
</div>';
echo "<table border='1' class='table'>
<thead>
<tr class='filters'>
<th><input type='text' class='form-control' placeholder='Pseudo-opcode' disabled></th>
<th><input type='text' class='form-control' placeholder='Type' disabled></th>
<th><input type='text' class='form-control' placeholder='Size' disabled></th>
<th><input type='text' class='form-control' placeholder='Initializable' disabled></th>
</tr>
</thead>
<tbody>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Pseudo-opcode'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "<td>" . $row['Size'] . "</td>";
echo "<td>" . $row['Initializable'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table></div></div></div>";
}
mysqli_close($con);
?>
</body>
<style type="text/css">
button{
margin-left: 200px;
margin-top: 50px;
}
.filterable {
margin-top: 15px;
}
.filterable .panel-heading .pull-right {
margin-top: -20px;
}
.filterable .filters input[disabled] {
background-color: transparent;
border: none;
cursor: auto;
box-shadow: none;
padding: 0;
height: auto;
}
.filterable .filters input[disabled]::-webkit-input-placeholder {
color: #333;
}
.filterable .filters input[disabled]::-moz-placeholder {
color: #333;
}
.filterable .filters input[disabled]:-ms-input-placeholder {
color: #333;
}
</style>
<script type="text/javascript">
/*
Please consider that the JS part isn't production ready at all, I just code it to show the concept of merging filters and titles together !
*/
$(document).ready(function(){
$('.filterable .btn-filter').click(function(){
var $panel = $(this).parents('.filterable'),
$filters = $panel.find('.filters input'),
$tbody = $panel.find('.table tbody');
if ($filters.prop('disabled') == true) {
$filters.prop('disabled', false);
$filters.first().focus();
} else {
$filters.val('').prop('disabled', true);
$tbody.find('.no-result').remove();
$tbody.find('tr').show();
}
});
$('.filterable .filters input').keyup(function(e){
/* Ignore tab key */
var code = e.keyCode || e.which;
if (code == '9') return;
/* Useful DOM data and selectors */
var $input = $(this),
inputContent = $input.val().toLowerCase(),
$panel = $input.parents('.filterable'),
column = $panel.find('.filters th').index($input.parents('th')),
$table = $panel.find('.table'),
$rows = $table.find('tbody tr');
/* Dirtiest filter function ever ;) */
var $filteredRows = $rows.filter(function(){
var value = $(this).find('td').eq(column).text().toLowerCase();
return value.indexOf(inputContent) === -1;
});
/* Clean previous no-result if exist */
$table.find('tbody .no-result').remove();
/* Show all rows, hide filtered ones (never do that outside of a demo ! xD) */
$rows.show();
$filteredRows.hide();
/* Prepend no-result row if all rows are filtered */
if ($filteredRows.length === $rows.length) {
$table.find('tbody').prepend($('<tr class="no-result text-center"><td colspan="'+ $table.find('.filters th').length +'">No result found</td></tr>'));
}
});
});
</script>
</html>