From 0d44e0aca2d116e6a3f67d408f5dbc040eb7ffa9 Mon Sep 17 00:00:00 2001 From: jsrobson10 Date: Wed, 17 Apr 2019 17:39:03 +1000 Subject: [PATCH] Got better looking timestamps --- scripts/formatting.js | 18 +++++++++++++++++- scripts/profiles.js | 8 +++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/scripts/formatting.js b/scripts/formatting.js index 3f6dbbd..5497312 100644 --- a/scripts/formatting.js +++ b/scripts/formatting.js @@ -25,6 +25,22 @@ function is_url(text) { return /^(ftp|http|https):\/\/[^ "]+$/.test(text); } +function fixInt(num, size) +{ + // Convert the number to a string + num = num.toString() + + // Loop over the number until its big enough + while(num.length < size) + { + // Add a zero to the start + num = "0" + num; + } + + // Return the number + return num; +} + function text_to_html(text) { // Make the text XSS safe @@ -85,7 +101,7 @@ function text_to_html(text) } // Is the text a dash (underline) - if(text[r][i] == "-" && !code_check) + else if(text[r][i] == "-" && !code_check) { // Invert the varible underline_check = !underline_check; diff --git a/scripts/profiles.js b/scripts/profiles.js index 781c300..1f745f5 100644 --- a/scripts/profiles.js +++ b/scripts/profiles.js @@ -182,7 +182,13 @@ function chat_switch_to(id) // Get the date var date = new Date(connections[active_profile].chats[id].messages[i].date); - date = date.toString(); + date = ( + (date.getMonth()+1)+"/"+ + date.getDate()+"/"+ + date.getFullYear()+" - "+ + date.getHours()+":"+ + fixInt(date.getMinutes(), 2) + ); // Should the chat header be included if(