Last active
September 12, 2016 16:23
-
-
Save Steffo99/efb1769e212a94ca4f8c8e42f31a3f95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet"> | |
| <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> | |
| <style> | |
| body { | |
| background-color: #ff7f00; | |
| font-family: 'Ubuntu', sans-serif; | |
| } | |
| .scatola { | |
| background-color: #fff2cc; | |
| border-radius: 5px; | |
| padding-left: 12px; | |
| padding-right: 12px; | |
| margin-left: 5px; | |
| margin-right: 5px; | |
| } | |
| </style> | |
| <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> | |
| <script> | |
| function loaded() | |
| { | |
| var rows; | |
| //Ricevi dal server il diario intero | |
| $.get("/diario.txt", {}, function(data) | |
| { | |
| //Dividi il file di testo in un array di righe | |
| rows = data.split("\n"); | |
| for(var i = 0; i < rows.length; i++) | |
| { | |
| //Dividi ogni riga in tempo e testo | |
| var part = rows[i].split("|"); | |
| var time = part[0]; | |
| var text = part[1]; | |
| //Converti il tempo in un oggetto data | |
| var timeobject = new Date(time * 1000); | |
| //Converti il tempo in una stringa | |
| var timestring = timeobject.toDateString(); | |
| //Aggiungi la riga | |
| $("body").append("<p id=\"diario-" + i + "\"></p>"); | |
| //Aggiungi la data | |
| $("#diario-" + i).append("<span>" + timestring + "</span>"); | |
| //Aggiungi il testo | |
| $("#diario-" + i).append("<span class=\"scatola\">" + text + "</span>"); | |
| } | |
| }, "text"); | |
| } | |
| window.onload = loaded; | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment