Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
UO291047 authored Nov 30, 2023
1 parent 36eeebe commit 583018f
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 31 deletions.
60 changes: 30 additions & 30 deletions js/crucigrama.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class Crucigrama{
return;
}

expression_row = this.validRow(selectedCellElement);
expression_col = this.validCol(selectedCellElement);
expression_row = this.validRow(this.selectedCell);
expression_col = this.validCol(this.selectedCell);

// Si el número es válido, realizar acciones necesarias
if (expression_row && expression_col) {
Expand All @@ -166,64 +166,64 @@ class Crucigrama{
}

validRow(cell){
var {row, col} = cell;
var {row, column} = cell;

if(row + 1 >= this.rows || this.tablero[row+1][col] == -1){
if(column + 1 >= this.columns || this.tablero[row][column+1] == -1){
return true;
}

for(var i=1; i<this.rows; i++){
if(this.tablero[row+i][col] === "="){
row = row + i;
for(var i=1; i<this.columns; i++){
if(this.tablero[row][column+i] === "="){
column = column + i;
break;
}
}

var first_number = this.tablero[row - 3][col];
var second_number = this.tablero[row - 1][col];
var expression = this.tablero[row - 2][col];
var result = this.tablero[row + 1][col];
var first_number = this.tablero[row][column - 3];
var second_number = this.tablero[row][column - 1];
var expression = this.tablero[row][column - 2];
var result = this.tablero[row][column + 1];

if(first_number != 0 && second_number != 0 && expression != 0 && result != 0){
var expr = [first_number, expression, second_number].join();
var expr = [first_number, expression, second_number].join("");
var res = eval(expr);
if(res == result){
return true;
if(res != result){
return false;
}
}

return false;
return true;

}

validCol(cell){
var {row, col} = cell;
var {row, column} = cell;

if(col + 1 >= this.columns || this.tablero[row][col+1] == -1){
if(row + 1 >= this.rows || this.tablero[row+1][column] == -1){
return true;
}

for(var i=1; i<this.columns; i++){
if(this.tablero[row][col+i] === "="){
col = col + i;
for(var i=1; i<this.rows; i++){
if(this.tablero[row+i][column] === "="){
row = row + i;
break;
}
}

var first_number = this.tablero[row][col - 3];
var second_number = this.tablero[row][col - 1];
var expression = this.tablero[row][col - 2];
var result = this.tablero[row][col + 1];
var first_number = this.tablero[row - 3][column];
var second_number = this.tablero[row - 1][column];
var expression = this.tablero[row - 2][column];
var result = this.tablero[row + 1][column];

if(first_number != 0 && second_number != 0 && expression != 0 && result != 0){
var expr = [first_number, expression, second_number].join();
var expr = [first_number, expression, second_number].join("");
var res = eval(expr);
if(res == result){
return true;
if(res != result){
return false;
}
}

return false;
return true;

}

Expand All @@ -241,8 +241,8 @@ class Crucigrama{
calculate_date_difference(){
const diff = (this.end_time - this.init_time) * 1000;
var horas, minutos, segundos = 0;
horas = Math.trunc(diff/(60*60));
minutos = Math.trunc((diff/60) - horas*60);
horas = (diff/(60*60)) > 0 ? 0 : Math.trunc(diff/(60*60));
minutos = ((diff/60) - horas*60) > 0 ? 0 : Math.trunc((diff/60) - horas*60);
segundos = diff%60;

return horas + ":" + minutos + ":" + segundos;
Expand Down
2 changes: 1 addition & 1 deletion js/fondo.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Fondo{
$.each(data.items, function(i, item) {
var media = item.media.m;
$("body").css({
"background-image": "url(" + media.replace("-n.jpg", "-b.jpg") + ")",
"background-image": "url(" + media.replace("_m", "_b") + ")",
"background-repeat": "no-repeat",
"background-size": "cover"
});
Expand Down
33 changes: 33 additions & 0 deletions js/noticias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class Noticias{

constructor(){
if(!(window.File && window.FileReader && window.FileList && window.Blob)){
alert("Este navegador NO soporta el API File y este programa no puede funcionar correctamente");
}
}

readInputFile(files){
var archivo = files[0];
var tipoTexto = /text.*/;
if (archivo.type.match(tipoTexto))
{
var result;
var lector = new FileReader();

lector.onload = function (evento) {
this.parseNoticias(lector.result);
}

lector.readAsText(archivo);

}
else {
alert("Error : ¡¡¡ Archivo no válido !!!");
}
}

parseNoticias(result){

}

}
3 changes: 3 additions & 0 deletions multimedia/noticias.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
El aumento de la producción científica desborda de papeleo a la Universidad_El Rector promete cambiar el servicio de gestión y contratar personal_A la Universidad de Oviedo le desborda el papeleo por el gran salto dado en investigación_Mónica Salas
La Universidad presume de equipos deportivos en una jornada ilusionante_La presentación tuvo lugar en el polideportivo universitario_Ayer, por primera vez, todos los equipos deportivos de la Universidad de Oviedo realizaron una presentación conjunta_Juan Sanchez
Investigadores que se van por unos meses al otro lado, a la empresa_Deberían hacerlo todos los científicos, afirman un psicólogo y una informática_Una cosa es colaborar con una empresa y otra bien diferente es poder trabajar en ella durante unos meses_Manuel Rodriguez
12 changes: 12 additions & 0 deletions noticias.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<link rel="stylesheet" type="text/css" href="estilo.css" />
<link rel="stylesheet" type="text/css" href="layout.css" />
<link rel="icon" href="multimedia/imagenes/favicon.ico"/>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<script src="js/noticias.js"></script>

</head>

Expand All @@ -34,5 +38,13 @@ <h1>Escritorio Virtual</h1>

<h2>Noticias</h2>

<script>
const noticias = new Noticias();
</script>

<p>
<input type="file" onchange="noticias.readInputFile(this.files);">
</p>

</body>
</html>

0 comments on commit 583018f

Please sign in to comment.