-
Notifications
You must be signed in to change notification settings - Fork 0
/
tickets.php
171 lines (148 loc) · 5.97 KB
/
tickets.php
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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="public/styles.css" />
<title>Ticket Generation</title>
</head>
<style>
.box {
display: table-cell;
padding: 5px 10px;
border : solid 1px black;
background-color: white !important;
z-index : 1;
margin: 0;
width : 10% !important;
text-align: center;
}
.box:hover {
display: table-cell;
padding: 5px 10px;
border : solid 1px black;
background-color: white !important;
z-index : 1;
margin: 0;
width : 10% !important;
text-align: center;
}
br {
margin: 0;
}
.row {
display: table-row;
margin : 0;
}
.radio {
border : solid 5px black;
border-radius: 100%;
}
</style>
<body style='margin : 0;' >
<div class='topbar' style="display:block;">
<img src="cbitlogo.png" class="logo">
<div class='title' style="display : inline ; margin : 0;"><strong><i><h1 style="display : inline-block;">Online Tambola Game</h1></i></strong></div>
</div>
<div class="downpart" >
<div class="downbar">
<center>
<div class="buttonclass"><a class='button' href="rules.php" target="_blank">Home/Rules</a></div>
<div class="buttonclass"><a class='button' href="numberboard.php" target="_blank">Numberboard</a></div>
<div class="buttonclass" style='margin-bottom : 35px'><a class='button' href="signin.php">Log Out</a></div>
</center>
</div>
<div class="content-box" id="content">
<div class="form">
<center>
<label ><br /><h3>Select the number of players:</h3></label><br />
<input type="radio" name="radio" class="radio" value="1"><h4>1</h4>
<input type="radio" name="radio" class="radio" value="2"><h4>2</h4>
<input type="radio" name="radio" class="radio" value="3"><h4>3</h4>
<input type="radio" name="radio" class="radio" value="4"><h4>4</h4>
<input type="radio" name="radio" class="radio" value="5"><h4>5</h4>
<input type="radio" name="radio" class="radio" value="6"><h4>6</h4><br /><br />
<button id="mybutton" type="submit" name="submit" value="hi" class="button">Submit</button><br /><br />
<div id="ticket" style='display : block'>
</div>
</center>
</div>
</div>
</div>
<?php
$command ='python3 ticketgenerator.py';
$output = shell_exec($command);
$output = str_replace('Structural representation','*', $output);
$output = substr($output, 1);
$output = str_replace('\\n','', $output);
$arr = explode("*",$output);
?>
<script type='text/javascript'>
var xampp = '';
function remove_linebreaks(str){
return str.replace( /[\\n\r\n]+/gm, "" );
}
var arr = [];
var tentickets = <?php echo json_encode($arr); ?>;
document.getElementById("mybutton").addEventListener("click", function(){
document.getElementById("mybutton").value = "bye";
document.getElementById("mybutton").innerHTML = "Fetching data...";
if( document.getElementById("mybutton").value == "bye" ){
var ele = document.getElementsByName('radio');
for(i = 0; i < ele.length; i++) {
if(ele[i].checked){
xampp = ele[i];
document.getElementById("mybutton").innerHTML = "Submitted !";
}
}
}
for( var i = 0 ; i < parseInt(xampp.value) ; i++){
arr[i] = JSON.stringify( tentickets[i]);
}
var count = 1;
document.getElementById('content').innerHTML += "<center>";
for (element of arr){
element = String(element);
element = element.replace( /["]/gm,"");
element = element.replace(/\\/g,"");
element = element.replace(/n/g,"");
// document.getElementById('ticket').innerHTML += "<p>"+element+"</p>";
let reg = /\[|\]/g
element = element.replace(reg,'');
element = element.split(' ');
var final= element.filter((str) => str !== '');
for (var i = 0; i < final.length; i++) {
var p = '<p class="box">' + final[i] + '</p>';
document.getElementById('ticket').innerHTML += p;
if( (i+1)%9 === 0){
document.getElementById('ticket').innerHTML += p;
document.getElementById('ticket').lastChild.style.display = "table-column-group";
}
}
document.getElementById('ticket').innerHTML += "<br /><h4>Ticket for player "+count+"</h4><br /><br /><br />";
count = count + 1;
//document.getElementById('ticket').innerHTML += "<p>element added</p>";
}
document.getElementById('content').innerHTML += "</center>";
});
// arr[0] = String(arr[0]);
// arr[0] = arr[0].replace(/(\r\n|\n|\r)/gm, "");
// arr[0] = arr[0].replace(/^[0-9-( )]+$/gm,"");
// arr[0] = arr[0].replace( /["]/gm,"");
// arr[0] = arr[0].replace(/[[]/gm,"");
// arr[0] = arr[0].replace(/[]]/gm,"");
//
// arr[0] = arr[0].replace(reg,'');
// arr[0] = arr[0].slice(1);
// arr[0] = arr[0].slice(0, arr.length - 1);
// arr[0] = arr[0].split(' ');
// const final= arr[0].filter((str) => str !== '');
// for (var i = 0; i < final.length; i++) {
// var p = '<p class="box">' + final[i] + '</p>';
// document.getElementById('ticket').innerHTML += p;
// if( (i+1)%9 === 0){
// document.getElementById('ticket').lastChild.style.display = "table-column-group";
// }
// }
</script>
</body>
</html>