|
| 1 | +pageValueNews: 0; |
| 2 | +pageValueVideogames: 0; |
| 3 | +pageValueRecommendedGames: 0; |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +/*document.addEventListener("DOMContentLoaded", () => { |
| 8 | + const $boton = document.querySelector("#generatePDF"); |
| 9 | + $boton.addEventListener("click", () => { |
| 10 | + const $elementoParaConvertir = document.body; // <-- Here you can choose any element of the DOM |
| 11 | + html2pdf() |
| 12 | + .set({ |
| 13 | + margin: 1, |
| 14 | + filename: 'documento.pdf', |
| 15 | + image: { |
| 16 | + type: 'jpeg', |
| 17 | + quality: 0.98 |
| 18 | + }, |
| 19 | + html2canvas: { |
| 20 | + scale: 3, // Larger scale, better graphics, but more weight |
| 21 | + letterRendering: true, |
| 22 | + }, |
| 23 | + jsPDF: { |
| 24 | + unit: "in", |
| 25 | + format: "a3", |
| 26 | + orientation: 'portrait' // landscape o portrait |
| 27 | + } |
| 28 | + }) |
| 29 | + .from($elementoParaConvertir) |
| 30 | + .save() |
| 31 | + .catch(err => console.log(err)); |
| 32 | + |
| 33 | + }); |
| 34 | +});*/ |
| 35 | +/* |
| 36 | +$(document).ready(function() { |
| 37 | + $('#moreImagesButton').on('click', function(){ |
| 38 | + |
| 39 | + $('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>'); |
| 40 | + increaseNews(); |
| 41 | + $.ajax({ |
| 42 | + type: "GET", |
| 43 | + url: '/news/' + pageValueNews, |
| 44 | + beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block. |
| 45 | + $('#loader').removeClass('hidden'); |
| 46 | + }, |
| 47 | + success: function (data) { |
| 48 | + //We finally load the desired content |
| 49 | + //$('#moreImgages').fadeIn(1000).html(data); |
| 50 | + $("#moreImages").fadeIn(1000).append(data); |
| 51 | + }, |
| 52 | + complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner. |
| 53 | + $('#loader').addClass('hidden'); |
| 54 | + }, |
| 55 | + }); |
| 56 | + }); |
| 57 | +}); |
| 58 | +
|
| 59 | +$(document).ready(function() { |
| 60 | + $('#moreRecomendedVideogame').on('click', function(){ |
| 61 | + |
| 62 | + $('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>'); |
| 63 | + increaseRecommendedVideogames(); |
| 64 | + $.ajax({ |
| 65 | + type: "GET", |
| 66 | + url: '/videogameStatistics/' + pageValueRecommendedGames, |
| 67 | + beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block. |
| 68 | + $('#loader').removeClass('hidden'); |
| 69 | + }, |
| 70 | + success: function (data) { |
| 71 | + $("#moreImages").fadeIn(1000).append(data); |
| 72 | + }, |
| 73 | + complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner. |
| 74 | + $('#loader').addClass('hidden'); |
| 75 | + }, |
| 76 | + }); |
| 77 | + }); |
| 78 | +}); |
| 79 | +
|
| 80 | +$(document).ready(function () { |
| 81 | + $('#moreVideogamesButton').on('click', function () { |
| 82 | + //Añadimos la imagen de carga en el contenedor |
| 83 | + $('#loader').html('<div class="loading"><img src="Photos/loader.gif" alt="loading" /><br/>Un momento, por favor...</div>'); |
| 84 | + increaseVideogames(); |
| 85 | + $.ajax({ |
| 86 | + type: "GET", //era un get |
| 87 | + url: '/videogames/' + pageValueVideogames, |
| 88 | + beforeSend: function () { // Before we send the request, remove the .hidden class from the spinner and default to inline-block. |
| 89 | + $('#loader').removeClass('hidden'); |
| 90 | + }, |
| 91 | + success: function (data) { |
| 92 | + //Cargamos finalmente el contenido deseado |
| 93 | + //$('#masImagenes').fadeIn(1000).html(data); |
| 94 | + $("#moreImages").fadeIn(1000).append(data); |
| 95 | + }, |
| 96 | + complete: function () { // Set our complete callback, adding the .hidden class and hiding the spinner. |
| 97 | + $('#loader').addClass('hidden'); |
| 98 | + }, |
| 99 | + }); |
| 100 | + }); |
| 101 | +}); |
| 102 | +
|
| 103 | +
|
| 104 | +function increaseNews() { |
| 105 | + pageValueNews += 1; |
| 106 | + return pageValueNews; |
| 107 | +} |
| 108 | +
|
| 109 | +function increaseVideogames() { |
| 110 | + pageValueVideogames += 1; |
| 111 | + return pageValueVideogames; |
| 112 | +} |
| 113 | +
|
| 114 | +function increaseRecommendedVideogames() { |
| 115 | + pageValueRecommendedGames += 1; |
| 116 | + return pageValueRecommendedGames; |
| 117 | +} |
| 118 | +
|
| 119 | +function verifySignin() { |
| 120 | + principal = request.getUserPrincipal(); |
| 121 | +
|
| 122 | + if (getUserPrincipal() === true) { |
| 123 | + location.href = '/paymentConfirmation'; |
| 124 | + } else { |
| 125 | + location.href = '/errorMessage'; |
| 126 | + } |
| 127 | +} |
| 128 | +
|
| 129 | +
|
| 130 | +function alertDataChange() { |
| 131 | + alert("Los datos de usuario se han guardado") |
| 132 | +} |
| 133 | +
|
| 134 | +var check = function () { |
| 135 | + if (document.getElementById('inputPassword1').value == |
| 136 | + document.getElementById('inputPassword2').value) { |
| 137 | + document.getElementById('passwordMessage').style.color = 'green'; |
| 138 | + document.getElementById('passwordMessage').innerHTML = 'contraseñas coinciden'; |
| 139 | + document.getElementById('createUserBtn').disabled = false; |
| 140 | + } else { |
| 141 | + document.getElementById('passwordMessage').style.color = 'red'; |
| 142 | + document.getElementById('passwordMessage').innerHTML = 'contraseñas no coinciden'; |
| 143 | + document.getElementById('createUserBtn').disabled = true; |
| 144 | + } |
| 145 | + } |
| 146 | +
|
| 147 | + $(document).ready(function () { |
| 148 | + $('#myChart').ready(function () { |
| 149 | +
|
| 150 | + var games = []; |
| 151 | + var solds = []; |
| 152 | +
|
| 153 | + $.ajax({ |
| 154 | + type: "GET", |
| 155 | + url: '/api/videogames/stats/sales', |
| 156 | + success: function (data) { |
| 157 | +
|
| 158 | + for (let item of data) { |
| 159 | + games.push(item[0]) |
| 160 | + solds.push(item[1]) |
| 161 | + } |
| 162 | +
|
| 163 | + var ctx = document.getElementById("myChart"); |
| 164 | + var myChart = new Chart(ctx, { |
| 165 | + type: 'bar', |
| 166 | + data: { |
| 167 | + labels: games, |
| 168 | + datasets: [{ |
| 169 | + label: 'nº de ventas', |
| 170 | + data: solds, |
| 171 | + backgroundColor: [ |
| 172 | + 'rgba(255, 99, 132, 0.2)', |
| 173 | + 'rgba(54, 162, 235, 0.2)', |
| 174 | + 'rgba(255, 206, 86, 0.2)', |
| 175 | + 'rgba(75, 192, 192, 0.2)', |
| 176 | + 'rgba(153, 102, 255, 0.2)', |
| 177 | + 'rgba(255, 159, 64, 0.2)' |
| 178 | + ], |
| 179 | + borderColor: [ |
| 180 | + 'rgba(255,99,132,1)', |
| 181 | + 'rgba(54, 162, 235, 1)', |
| 182 | + 'rgba(255, 206, 86, 1)', |
| 183 | + 'rgba(75, 192, 192, 1)', |
| 184 | + 'rgba(153, 102, 255, 1)', |
| 185 | + 'rgba(255, 159, 64, 1)' |
| 186 | + ], |
| 187 | + borderWidth: 1 |
| 188 | + }] |
| 189 | + }, |
| 190 | + options: { |
| 191 | + scales: { |
| 192 | + yAxes: [{ |
| 193 | + ticks: { |
| 194 | + beginAtZero: true |
| 195 | + } |
| 196 | + }] |
| 197 | + } |
| 198 | + } |
| 199 | + }); |
| 200 | + }, |
| 201 | + }); |
| 202 | + }) |
| 203 | +}) |
| 204 | +
|
| 205 | + $(document).ready(function () { |
| 206 | + $('#myChartSoldGenre').ready(function () { |
| 207 | +
|
| 208 | + var games1 = []; |
| 209 | + var solds1 = []; |
| 210 | +
|
| 211 | + $.ajax({ |
| 212 | + type: "GET", |
| 213 | + url: '/api/videogames/stats/genres', |
| 214 | + success: function (data) { |
| 215 | +
|
| 216 | + for (let item of data) { |
| 217 | + games1.push(item[0]) |
| 218 | + solds1.push(item[1]) |
| 219 | + } |
| 220 | +
|
| 221 | + var ctx = document.getElementById("myChartSoldGenre"); |
| 222 | + var myChartSoldGenre = new Chart(ctx, { |
| 223 | + type: 'pie', |
| 224 | + data: { |
| 225 | + labels: games1, |
| 226 | + datasets: [{ |
| 227 | + label: 'nº de ventas', |
| 228 | + data: solds1, |
| 229 | + backgroundColor: [ |
| 230 | + 'rgba(255, 99, 132, 0.2)', |
| 231 | + 'rgba(54, 162, 235, 0.2)', |
| 232 | + 'rgba(255, 206, 86, 0.2)', |
| 233 | + 'rgba(75, 192, 192, 0.2)', |
| 234 | + 'rgba(153, 102, 255, 0.2)', |
| 235 | + 'rgba(255, 159, 64, 0.2)', |
| 236 | + 'rgba(0, 0, 0, 0.2)', |
| 237 | + 'rgba(255, 0, 0, 0.2)', |
| 238 | + 'rgba(255, 255, 0, 0.2)', |
| 239 | + 'rgba(0, 255, 0, 0.2)', |
| 240 | + 'rgba(128, 0, 128, 0.2)' |
| 241 | + ], |
| 242 | + borderColor: [ |
| 243 | + 'rgba(255,99,132,1)', |
| 244 | + 'rgba(54, 162, 235, 1)', |
| 245 | + 'rgba(255, 206, 86, 1)', |
| 246 | + 'rgba(75, 192, 192, 1)', |
| 247 | + 'rgba(153, 102, 255, 1)', |
| 248 | + 'rgba(0, 0, 0, 1)', |
| 249 | + 'rgba(255, 0, 0, 1)', |
| 250 | + 'rgba(255, 0, 04, 1)', |
| 251 | + 'rgba(255, 255, 0, 1)', |
| 252 | + 'rgba(0, 255, 0, 1)', |
| 253 | + 'rgba(128, 0, 128, 1)' |
| 254 | + ], |
| 255 | + borderWidth: 1 |
| 256 | + }] |
| 257 | + }, |
| 258 | + options: { |
| 259 | + scales: { |
| 260 | + yAxes: [{ |
| 261 | + ticks: { |
| 262 | + beginAtZero: true |
| 263 | + } |
| 264 | + }] |
| 265 | + } |
| 266 | + } |
| 267 | + }); |
| 268 | + }, |
| 269 | + }); |
| 270 | + }) |
| 271 | +})*/ |
0 commit comments