From edfb338e073df435484b7015768dfa63933786c1 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Wed, 23 Mar 2016 13:39:07 -0400 Subject: [PATCH 01/23] Semicolons --- Time.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Time.js b/Time.js index a7d878d..6c23ffc 100644 --- a/Time.js +++ b/Time.js @@ -13,19 +13,19 @@ ext._getDay = function() { var today = new Date() return today.getDay() - } + }; ext._getHours = function() { var today = new Date() return today.getHours() - } + }; ext._getMinutes = function() { var today = new Date() return today.getMinutes() - } + }; ext._getSeconds = function() { var today = new Date() return today.getSeconds() - } + }; // Block and block menu descriptions var descriptor = { @@ -39,4 +39,4 @@ // Register the extension ScratchExtensions.register('Time', descriptor, ext); -})({}); \ No newline at end of file +})({}); From dd9993ca25d9b992689d7c4ee478d92a8c3ebf14 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 10:21:59 -0400 Subject: [PATCH 02/23] Merge branch 'master' into gh-pages --- Time.js | 71 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/Time.js b/Time.js index 6c23ffc..4374de8 100644 --- a/Time.js +++ b/Time.js @@ -10,33 +10,62 @@ msg: 'Ready' }; }; - ext._getDay = function() { + ext._getHoursMinutes = function() { var today = new Date() - return today.getDay() - }; - ext._getHours = function() { - var today = new Date() - return today.getHours() - }; - ext._getMinutes = function() { + return today.getHours() + ":" + today.getMinutes() + } + ext._getHoursMinutesSeconds = function() { var today = new Date() - return today.getMinutes() - }; - ext._getSeconds = function() { + return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() + } + ext._getHoursPM = function() { var today = new Date() - return today.getSeconds() - }; - - // Block and block menu descriptions + var hours = today.getHours() + if (today < 12 && today > 0) { + return hours + " AM" + } else if (today == 12) { + return hours + " PM" + } else if (today == 0) { + return "12 AM" + } else if (today > 12) { + return hours - 12 + " PM" + } + } + ext._time = function(menu) { + today = new Date() + if (menu = 'Day') { + return today.getDay() + } else if (menu = 'Hour') { + return today.getHours() + } else if (menu = 'Minute') { + return today.getMinutes() + } else if (menu = 'Second') { + return today.getSeconds() + } else if (menu = 'Hour 12 Clock') { + var hours = today.getHours() + if (today < 12 && today > 0) { + return hours + " AM" + } else if (today == 12) { + return hours + " PM" + } else if (today == 0) { + return "12 AM" + } else if (today > 12) { + return hours - 12 + " PM" + } + } + } + // Block and block menu descriptions var descriptor = { blocks: [ - ['r', 'Days', 'getDay'] - ['r', 'Hours', 'getHours'] - ['r', 'Minutes', 'getMinutes'] - ['r', 'Seconds', 'getSeconds'] - ] + ['r', 'Time', 'getHoursMinutes'] + ['r', 'Time with Seconds', 'getHoursMinutesSeconds'] + ['r', 'Current %m.time', 'time'] + ], + menus: { + time: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second'] + } }; // Register the extension ScratchExtensions.register('Time', descriptor, ext); -})({}); +})({}); \ No newline at end of file From 2bc25b316e4dcb2717490ece11d4e8d17cbafddf Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 10:33:19 -0400 Subject: [PATCH 03/23] Update Time.js --- Time.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Time.js b/Time.js index 4374de8..e711571 100644 --- a/Time.js +++ b/Time.js @@ -31,17 +31,17 @@ return hours - 12 + " PM" } } - ext._time = function(menu) { + ext._time = function(timeMenu) { today = new Date() - if (menu = 'Day') { + if (timeMenu = 'Day') { return today.getDay() - } else if (menu = 'Hour') { + } else if (timeMenu = 'Hour') { return today.getHours() - } else if (menu = 'Minute') { + } else if (timeMenu = 'Minute') { return today.getMinutes() - } else if (menu = 'Second') { + } else if (timeMenu = 'Second') { return today.getSeconds() - } else if (menu = 'Hour 12 Clock') { + } else if (timeMenu = 'Hour 12 Clock') { var hours = today.getHours() if (today < 12 && today > 0) { return hours + " AM" @@ -54,18 +54,28 @@ } } } + ext._displayTime = function(displayMenu) { + var today = new Date() + if (displayMenu = 'Hours:Minutes') { + return today.getHours() + ":" + today.getMinutes() + } else if (displayMenu = 'Hours:Minutes:Seconds') { + return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() + } + } // Block and block menu descriptions var descriptor = { blocks: [ ['r', 'Time', 'getHoursMinutes'] ['r', 'Time with Seconds', 'getHoursMinutesSeconds'] - ['r', 'Current %m.time', 'time'] + ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'] + ['r', 'Current %m.timeMenu', 'time', 'Day'] ], menus: { - time: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second'] + timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second'], + displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds'] } }; // Register the extension ScratchExtensions.register('Time', descriptor, ext); -})({}); \ No newline at end of file +})({}); From a1a7b8a3d67dee640b3f475e64820a717c88a6b9 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 10:50:32 -0400 Subject: [PATCH 04/23] Update Time.js --- Time.js | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/Time.js b/Time.js index e711571..d729d7a 100644 --- a/Time.js +++ b/Time.js @@ -32,28 +32,33 @@ } } ext._time = function(timeMenu) { - today = new Date() - if (timeMenu = 'Day') { - return today.getDay() - } else if (timeMenu = 'Hour') { - return today.getHours() - } else if (timeMenu = 'Minute') { - return today.getMinutes() - } else if (timeMenu = 'Second') { - return today.getSeconds() - } else if (timeMenu = 'Hour 12 Clock') { - var hours = today.getHours() - if (today < 12 && today > 0) { - return hours + " AM" - } else if (today == 12) { - return hours + " PM" - } else if (today == 0) { - return "12 AM" - } else if (today > 12) { - return hours - 12 + " PM" - } + today = new Date() + if (timeMenu = 'Day') { + return today.getDay() + } else if (timeMenu = 'Hour') { + return today.getHours() + } else if (timeMenu = 'Minute') { + return today.getMinutes() + } else if (timeMenu = 'Second') { + return today.getSeconds() + } else if (timeMenu = 'Hour 12 Clock') { + var hours = today.getHours() + if (today < 12 && today > 0) { + return hours + " AM" + } else if (today == 12) { + return hours + " PM" + } else if (today == 0) { + return "12 AM" + } else if (today > 12) { + return hours - 12 + " PM" } + } else if (timeMenu = 'Month') { + return today.getMonth() + } else if (timeMenu = 'Year') { + return today.getYear() + 1900 } + } + ext._displayTime = function(displayMenu) { var today = new Date() if (displayMenu = 'Hours:Minutes') { @@ -62,7 +67,8 @@ return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() } } - // Block and block menu descriptions + + // Block and block menu descriptions var descriptor = { blocks: [ ['r', 'Time', 'getHoursMinutes'] @@ -71,11 +77,11 @@ ['r', 'Current %m.timeMenu', 'time', 'Day'] ], menus: { - timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second'], + timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Month', 'Year'], displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds'] } }; - + // Register the extension ScratchExtensions.register('Time', descriptor, ext); })({}); From 38a1fa297b5a021dcf7a71103d3be9ef0318f57d Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 11:02:47 -0400 Subject: [PATCH 05/23] Update Time.js --- Time.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Time.js b/Time.js index d729d7a..69e5eff 100644 --- a/Time.js +++ b/Time.js @@ -34,7 +34,22 @@ ext._time = function(timeMenu) { today = new Date() if (timeMenu = 'Day') { - return today.getDay() + var day = today.getDay() + if (day = 0 || day = 7) { + return 'Sunday' + } else if (day = 1) { + return 'Monday' + } else if (day = 2) { + return 'Tuesday' + } else if (day = 3) { + return 'Wednesday' + } else if (day = 4) { + return 'Thursday' + } else if (day = 5) { + return 'Friday' + } else if (day = 6) { + return 'Saturday' + } } else if (timeMenu = 'Hour') { return today.getHours() } else if (timeMenu = 'Minute') { @@ -52,6 +67,8 @@ } else if (today > 12) { return hours - 12 + " PM" } + } else if (timeMenu = 'Date') { + return today.getDate() } else if (timeMenu = 'Month') { return today.getMonth() } else if (timeMenu = 'Year') { @@ -65,6 +82,10 @@ return today.getHours() + ":" + today.getMinutes() } else if (displayMenu = 'Hours:Minutes:Seconds') { return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() + } else if (displayMenu = 'Month/Date/Year') { + return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() + } else if (displayMenu = 'Date/Month/Year') { + return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() } } @@ -77,7 +98,7 @@ ['r', 'Current %m.timeMenu', 'time', 'Day'] ], menus: { - timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Month', 'Year'], + timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds'] } }; From 6e23aebf6aef5a41a205b50a80d339c9d3b72c80 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 11:04:44 -0400 Subject: [PATCH 06/23] Update Time.js --- Time.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Time.js b/Time.js index 69e5eff..090feae 100644 --- a/Time.js +++ b/Time.js @@ -86,6 +86,10 @@ return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() } else if (displayMenu = 'Date/Month/Year') { return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() + } else if (displayMenu = 'Month/Date') { + return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() + } else if (displayMenu = 'Date/Month') { + return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() } } @@ -99,7 +103,7 @@ ], menus: { timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], - displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds'] + displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From f08f34731743a5dddd34216dc32bdd9a6b2097ae Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 11:08:24 -0400 Subject: [PATCH 07/23] Update Time.js --- Time.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Time.js b/Time.js index 090feae..bc812e5 100644 --- a/Time.js +++ b/Time.js @@ -33,7 +33,7 @@ } ext._time = function(timeMenu) { today = new Date() - if (timeMenu = 'Day') { + if (timeMenu = 'Day of Week') { var day = today.getDay() if (day = 0 || day = 7) { return 'Sunday' @@ -99,10 +99,10 @@ ['r', 'Time', 'getHoursMinutes'] ['r', 'Time with Seconds', 'getHoursMinutesSeconds'] ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'] - ['r', 'Current %m.timeMenu', 'time', 'Day'] + ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], menus: { - timeMenu: ['Day', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], + timeMenu: ['Day of Week', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From ea41bd62d8596a3aa74d0c921d6cbebb7b6b2bef Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 11:11:59 -0400 Subject: [PATCH 08/23] Update Time.js --- Time.js | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/Time.js b/Time.js index bc812e5..77e6d3d 100644 --- a/Time.js +++ b/Time.js @@ -10,27 +10,6 @@ msg: 'Ready' }; }; - ext._getHoursMinutes = function() { - var today = new Date() - return today.getHours() + ":" + today.getMinutes() - } - ext._getHoursMinutesSeconds = function() { - var today = new Date() - return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() - } - ext._getHoursPM = function() { - var today = new Date() - var hours = today.getHours() - if (today < 12 && today > 0) { - return hours + " AM" - } else if (today == 12) { - return hours + " PM" - } else if (today == 0) { - return "12 AM" - } else if (today > 12) { - return hours - 12 + " PM" - } - } ext._time = function(timeMenu) { today = new Date() if (timeMenu = 'Day of Week') { @@ -50,23 +29,21 @@ } else if (day = 6) { return 'Saturday' } - } else if (timeMenu = 'Hour') { - return today.getHours() } else if (timeMenu = 'Minute') { return today.getMinutes() } else if (timeMenu = 'Second') { return today.getSeconds() - } else if (timeMenu = 'Hour 12 Clock') { + } else if (timeMenu = 'Hour') { var hours = today.getHours() - if (today < 12 && today > 0) { - return hours + " AM" - } else if (today == 12) { - return hours + " PM" + if (today <= 12 && today > 0) { + return hours } else if (today == 0) { - return "12 AM" + return 12 } else if (today > 12) { - return hours - 12 + " PM" + return hours - 12 } + } else if (timeMenu = 'Hour 24 Clock') { + return today.getHours() } else if (timeMenu = 'Date') { return today.getDate() } else if (timeMenu = 'Month') { @@ -102,7 +79,7 @@ ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], menus: { - timeMenu: ['Day of Week', 'Hour', 'Hour 12 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], + timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From 542b1fe63d937a78f8d0ea913e5037697d286e05 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 11:13:49 -0400 Subject: [PATCH 09/23] Update Time.js --- Time.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/Time.js b/Time.js index 77e6d3d..dd883fa 100644 --- a/Time.js +++ b/Time.js @@ -73,8 +73,6 @@ // Block and block menu descriptions var descriptor = { blocks: [ - ['r', 'Time', 'getHoursMinutes'] - ['r', 'Time with Seconds', 'getHoursMinutesSeconds'] ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'] ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], From a31ca22cc9d0966b8880b5953c053ef993fc16cb Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 13:53:57 -0400 Subject: [PATCH 10/23] Update Time.js --- Time.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Time.js b/Time.js index dd883fa..88379fa 100644 --- a/Time.js +++ b/Time.js @@ -12,28 +12,28 @@ }; ext._time = function(timeMenu) { today = new Date() - if (timeMenu = 'Day of Week') { + if (timeMenu == 'Day of Week') { var day = today.getDay() - if (day = 0 || day = 7) { + if (day == 0 || day == 7) { return 'Sunday' - } else if (day = 1) { + } else if (day == 1) { return 'Monday' - } else if (day = 2) { + } else if (day == 2) { return 'Tuesday' - } else if (day = 3) { + } else if (day == 3) { return 'Wednesday' - } else if (day = 4) { + } else if (day == 4) { return 'Thursday' - } else if (day = 5) { + } else if (day == 5) { return 'Friday' - } else if (day = 6) { + } else if (day == 6) { return 'Saturday' } - } else if (timeMenu = 'Minute') { + } else if (timeMenu == 'Minute') { return today.getMinutes() - } else if (timeMenu = 'Second') { + } else if (timeMenu == 'Second') { return today.getSeconds() - } else if (timeMenu = 'Hour') { + } else if (timeMenu == 'Hour') { var hours = today.getHours() if (today <= 12 && today > 0) { return hours @@ -42,30 +42,30 @@ } else if (today > 12) { return hours - 12 } - } else if (timeMenu = 'Hour 24 Clock') { + } else if (timeMenu == 'Hour 24 Clock') { return today.getHours() - } else if (timeMenu = 'Date') { + } else if (timeMenu == 'Date') { return today.getDate() - } else if (timeMenu = 'Month') { + } else if (timeMenu == 'Month') { return today.getMonth() - } else if (timeMenu = 'Year') { + } else if (timeMenu == 'Year') { return today.getYear() + 1900 } } ext._displayTime = function(displayMenu) { var today = new Date() - if (displayMenu = 'Hours:Minutes') { + if (displayMenu == 'Hours:Minutes') { return today.getHours() + ":" + today.getMinutes() - } else if (displayMenu = 'Hours:Minutes:Seconds') { + } else if (displayMenu == 'Hours:Minutes:Seconds') { return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() - } else if (displayMenu = 'Month/Date/Year') { + } else if (displayMenu == 'Month/Date/Year') { return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() - } else if (displayMenu = 'Date/Month/Year') { + } else if (displayMenu == 'Date/Month/Year') { return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() - } else if (displayMenu = 'Month/Date') { + } else if (displayMenu == 'Month/Date') { return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() - } else if (displayMenu = 'Date/Month') { + } else if (displayMenu == 'Date/Month') { return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() } } From b0fa1902e8b89ca6b6e8be7d5b929df931e23e32 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:00:18 -0400 Subject: [PATCH 11/23] Punctuation --- Time.js | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Time.js b/Time.js index 88379fa..fe68789 100644 --- a/Time.js +++ b/Time.js @@ -15,65 +15,65 @@ if (timeMenu == 'Day of Week') { var day = today.getDay() if (day == 0 || day == 7) { - return 'Sunday' + return 'Sunday'; } else if (day == 1) { - return 'Monday' + return 'Monday'; } else if (day == 2) { - return 'Tuesday' + return 'Tuesday'; } else if (day == 3) { - return 'Wednesday' + return 'Wednesday'; } else if (day == 4) { - return 'Thursday' + return 'Thursday'; } else if (day == 5) { - return 'Friday' + return 'Friday'; } else if (day == 6) { - return 'Saturday' + return 'Saturday'; } } else if (timeMenu == 'Minute') { - return today.getMinutes() + return today.getMinutes(); } else if (timeMenu == 'Second') { - return today.getSeconds() + return today.getSeconds(); } else if (timeMenu == 'Hour') { - var hours = today.getHours() + var hours = today.getHours(); if (today <= 12 && today > 0) { - return hours + return hours; } else if (today == 0) { - return 12 + return 12; } else if (today > 12) { - return hours - 12 + return hours - 12; } } else if (timeMenu == 'Hour 24 Clock') { - return today.getHours() + return today.getHours(); } else if (timeMenu == 'Date') { - return today.getDate() + return today.getDate(); } else if (timeMenu == 'Month') { - return today.getMonth() + return today.getMonth(); } else if (timeMenu == 'Year') { - return today.getYear() + 1900 + return today.getFullYear(); } } ext._displayTime = function(displayMenu) { - var today = new Date() + var today = new Date(); if (displayMenu == 'Hours:Minutes') { - return today.getHours() + ":" + today.getMinutes() + return today.getHours() + ":" + today.getMinutes(); } else if (displayMenu == 'Hours:Minutes:Seconds') { - return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds() + return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); } else if (displayMenu == 'Month/Date/Year') { - return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() + return today.getMonth() + "/" + today.getDate() + "/" + today.getYear(); } else if (displayMenu == 'Date/Month/Year') { - return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() + return today.getDate() + "/" + today.getMonth() + "/" + today.getYear(); } else if (displayMenu == 'Month/Date') { - return today.getMonth() + "/" + today.getDate() + "/" + today.getYear() + return today.getMonth() + "/" + today.getDate() + "/" + today.getYear(); } else if (displayMenu == 'Date/Month') { - return today.getDate() + "/" + today.getMonth() + "/" + today.getYear() + return today.getDate() + "/" + today.getMonth() + "/" + today.getYear(); } } - + // Block and block menu descriptions var descriptor = { blocks: [ - ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'] + ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'], ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], menus: { @@ -81,7 +81,7 @@ displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; - + // Register the extension ScratchExtensions.register('Time', descriptor, ext); })({}); From 584e247e680dd67863fc238c5126199a023e9777 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:03:27 -0400 Subject: [PATCH 12/23] Stupid Ss --- Time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Time.js b/Time.js index fe68789..8407048 100644 --- a/Time.js +++ b/Time.js @@ -78,7 +78,7 @@ ], menus: { timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], - displayMenus: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] + displayMenu: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From aee3c14be41d9e55ceda9fdb8a7e065d2bc41225 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:06:06 -0400 Subject: [PATCH 13/23] Underscores --- Time.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Time.js b/Time.js index 8407048..090c3ff 100644 --- a/Time.js +++ b/Time.js @@ -10,7 +10,8 @@ msg: 'Ready' }; }; - ext._time = function(timeMenu) { + + ext.time = function(timeMenu) { today = new Date() if (timeMenu == 'Day of Week') { var day = today.getDay() @@ -53,7 +54,7 @@ } } - ext._displayTime = function(displayMenu) { + ext.displayTime = function(displayMenu) { var today = new Date(); if (displayMenu == 'Hours:Minutes') { return today.getHours() + ":" + today.getMinutes(); From dee7cff63840e4390dcf8268fe3b5db8a70cc36a Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:11:21 -0400 Subject: [PATCH 14/23] Test without parameters --- Time.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Time.js b/Time.js index 090c3ff..cd4af87 100644 --- a/Time.js +++ b/Time.js @@ -11,8 +11,9 @@ }; }; - ext.time = function(timeMenu) { - today = new Date() + ext.time = function() { + var timeMenu = 'Day of Week' + var today = new Date() if (timeMenu == 'Day of Week') { var day = today.getDay() if (day == 0 || day == 7) { @@ -54,7 +55,8 @@ } } - ext.displayTime = function(displayMenu) { + ext.displayTime = function() { + var displayMenu = 'Hours:Minutes' var today = new Date(); if (displayMenu == 'Hours:Minutes') { return today.getHours() + ":" + today.getMinutes(); @@ -74,11 +76,11 @@ // Block and block menu descriptions var descriptor = { blocks: [ - ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'], - ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] + ['r', 'Display %m.displayMenu', 'displayTime'], + ['r', 'Current %m.timeMenu', 'time'] ], menus: { - timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], + timeMenus: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], displayMenu: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From ecfafeac738b813aea2665b2c23e00d3396df3c5 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:12:53 -0400 Subject: [PATCH 15/23] Hopefully last --- Time.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Time.js b/Time.js index cd4af87..a3a6264 100644 --- a/Time.js +++ b/Time.js @@ -11,8 +11,7 @@ }; }; - ext.time = function() { - var timeMenu = 'Day of Week' + ext.time = function(timeMenu) { var today = new Date() if (timeMenu == 'Day of Week') { var day = today.getDay() @@ -55,8 +54,7 @@ } } - ext.displayTime = function() { - var displayMenu = 'Hours:Minutes' + ext.displayTime = function(displayMenu) { var today = new Date(); if (displayMenu == 'Hours:Minutes') { return today.getHours() + ":" + today.getMinutes(); @@ -76,11 +74,11 @@ // Block and block menu descriptions var descriptor = { blocks: [ - ['r', 'Display %m.displayMenu', 'displayTime'], - ['r', 'Current %m.timeMenu', 'time'] + ['r', 'Display %m.displayMenu', 'displayTime', 'Hours:Minutes'], + ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], menus: { - timeMenus: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], + timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], displayMenu: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From 2d6e1868c47fd89aedad7cbb1b04d5d9d2789d99 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:18:03 -0400 Subject: [PATCH 16/23] Example --- Example.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Example.js diff --git a/Example.js b/Example.js new file mode 100644 index 0000000..074a8a4 --- /dev/null +++ b/Example.js @@ -0,0 +1,40 @@ +(function(ext) { + var alarm_went_off = false; // This becomes true after the alarm goes off + + // Cleanup function when the extension is unloaded + ext._shutdown = function() {}; + + // Status reporting code + // Use this to report missing hardware, plugin or unsupported browser + ext._getStatus = function() { + return {status: 2, msg: 'Ready'}; + }; + + ext.set_alarm = function(time) { + window.setTimeout(function() { + alarm_went_off = true; + }, time*1000); + }; + + ext.when_alarm = function() { + // Reset alarm_went_off if it is true, and return true + // otherwise, return false. + if (alarm_went_off === true) { + alarm_went_off = false; + return true; + } + + return false; + }; + + // Block and block menu descriptions + var descriptor = { + blocks: [ + ['', 'run alarm after %n seconds', 'set_alarm', '2'], + ['h', 'when alarm goes off', 'when_alarm'], + ] + }; + + // Register the extension + ScratchExtensions.register('Alarm extension', descriptor, ext); +})({}); From 51a32b13ca85277207126616f6a6b7adca38699a Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:18:37 -0400 Subject: [PATCH 17/23] Delete --- Example.js | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 Example.js diff --git a/Example.js b/Example.js deleted file mode 100644 index 074a8a4..0000000 --- a/Example.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(ext) { - var alarm_went_off = false; // This becomes true after the alarm goes off - - // Cleanup function when the extension is unloaded - ext._shutdown = function() {}; - - // Status reporting code - // Use this to report missing hardware, plugin or unsupported browser - ext._getStatus = function() { - return {status: 2, msg: 'Ready'}; - }; - - ext.set_alarm = function(time) { - window.setTimeout(function() { - alarm_went_off = true; - }, time*1000); - }; - - ext.when_alarm = function() { - // Reset alarm_went_off if it is true, and return true - // otherwise, return false. - if (alarm_went_off === true) { - alarm_went_off = false; - return true; - } - - return false; - }; - - // Block and block menu descriptions - var descriptor = { - blocks: [ - ['', 'run alarm after %n seconds', 'set_alarm', '2'], - ['h', 'when alarm goes off', 'when_alarm'], - ] - }; - - // Register the extension - ScratchExtensions.register('Alarm extension', descriptor, ext); -})({}); From 9b30b62101e0eb9bd759847ea67075171d925285 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:19:04 -0400 Subject: [PATCH 18/23] I HATE THIS --- Time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Time.js b/Time.js index a3a6264..a379c27 100644 --- a/Time.js +++ b/Time.js @@ -78,7 +78,7 @@ ['r', 'Current %m.timeMenu', 'time', 'Day of Week'] ], menus: { - timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date' 'Month', 'Year'], + timeMenu: ['Day of Week', 'Hour', 'Hour 24 Clock', 'Minute', 'Second', 'Date', 'Month', 'Year'], displayMenu: ['Hours:Minutes', 'Hours:Minutes:Seconds', 'Month/Date', 'Date/Month', 'Month/Date/Year', 'Date/Month/Year'] } }; From ee899bdf60535ce3503fad40fd5012fffe661aa0 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:23:12 -0400 Subject: [PATCH 19/23] Update Time.js --- Time.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Time.js b/Time.js index a379c27..2f5fc72 100644 --- a/Time.js +++ b/Time.js @@ -36,11 +36,11 @@ return today.getSeconds(); } else if (timeMenu == 'Hour') { var hours = today.getHours(); - if (today <= 12 && today > 0) { + if (hours <= 12 && hours > 0) { return hours; - } else if (today == 0) { + } else if (hours == 0) { return 12; - } else if (today > 12) { + } else if (hours > 12) { return hours - 12; } } else if (timeMenu == 'Hour 24 Clock') { @@ -56,10 +56,15 @@ ext.displayTime = function(displayMenu) { var today = new Date(); + var hours = today.getHours(); + if (hours == 0) { + hours = 12; + } else if (today > 12) { + hours = hours - 12; if (displayMenu == 'Hours:Minutes') { - return today.getHours() + ":" + today.getMinutes(); + return hours + ":" + today.getMinutes(); } else if (displayMenu == 'Hours:Minutes:Seconds') { - return today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); + return hours + ":" + today.getMinutes() + ":" + today.getSeconds(); } else if (displayMenu == 'Month/Date/Year') { return today.getMonth() + "/" + today.getDate() + "/" + today.getYear(); } else if (displayMenu == 'Date/Month/Year') { From e6ef39435c777d1b0228bcb47a937dfed7d326b7 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 14:27:18 -0400 Subject: [PATCH 20/23] Fix --- Time.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Time.js b/Time.js index 2f5fc72..632469d 100644 --- a/Time.js +++ b/Time.js @@ -61,6 +61,7 @@ hours = 12; } else if (today > 12) { hours = hours - 12; + } if (displayMenu == 'Hours:Minutes') { return hours + ":" + today.getMinutes(); } else if (displayMenu == 'Hours:Minutes:Seconds') { From 64b940aff244e81116d0ca7fc3b1b21e73860131 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Fri, 25 Mar 2016 18:15:31 -0400 Subject: [PATCH 21/23] JSHint --- Time.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Time.js b/Time.js index 632469d..b7075d8 100644 --- a/Time.js +++ b/Time.js @@ -12,10 +12,10 @@ }; ext.time = function(timeMenu) { - var today = new Date() + var today = new Date(); if (timeMenu == 'Day of Week') { - var day = today.getDay() - if (day == 0 || day == 7) { + var day = today.getDay(); + if (day === 0 || day === 7) { return 'Sunday'; } else if (day == 1) { return 'Monday'; @@ -38,7 +38,7 @@ var hours = today.getHours(); if (hours <= 12 && hours > 0) { return hours; - } else if (hours == 0) { + } else if (hours === 0) { return 12; } else if (hours > 12) { return hours - 12; @@ -52,12 +52,12 @@ } else if (timeMenu == 'Year') { return today.getFullYear(); } - } + }; ext.displayTime = function(displayMenu) { var today = new Date(); var hours = today.getHours(); - if (hours == 0) { + if (hours === 0) { hours = 12; } else if (today > 12) { hours = hours - 12; @@ -75,7 +75,7 @@ } else if (displayMenu == 'Date/Month') { return today.getDate() + "/" + today.getMonth() + "/" + today.getYear(); } - } + }; // Block and block menu descriptions var descriptor = { From e8fe8a01c2e30c4ec8d06cd0269c626bb3437500 Mon Sep 17 00:00:00 2001 From: nathanfi Date: Thu, 31 Mar 2016 10:31:04 -0400 Subject: [PATCH 22/23] Final --- Project Description.html | 23 +++++++++++++++++++++++ Time.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 Project Description.html diff --git a/Project Description.html b/Project Description.html new file mode 100755 index 0000000..fc2f77d --- /dev/null +++ b/Project Description.html @@ -0,0 +1,23 @@ + + + + + Untitled + + + + + + + + + + +

Nathan's ScratchXs

+

To access the code of Nathan's first go here: http://nathanfi.github.io/ScratchX1/Time.js + To use the extension in ScratchX, go here: scratchx.org/?url=http://nathanfi.github.io/ScratchX1/Time.js

+

Nathan's new project

+

The project is as follows: The use will click on a location on a world map, and then the extension will display "Hello" in that location's official language. + In order to complete this project, Nathan will provide a world map sprite, and use the Google Translate API as well as the log equations required to display "Hello" in the local language of the location of the mouse.

+ + diff --git a/Time.js b/Time.js index b7075d8..16c03d5 100644 --- a/Time.js +++ b/Time.js @@ -59,7 +59,7 @@ var hours = today.getHours(); if (hours === 0) { hours = 12; - } else if (today > 12) { + } else if (hours > 12) { hours = hours - 12; } if (displayMenu == 'Hours:Minutes') { From c41a9de166d91f35257f42083929556160b6427a Mon Sep 17 00:00:00 2001 From: nathanfi Date: Thu, 31 Mar 2016 10:38:29 -0400 Subject: [PATCH 23/23] Real Final --- Time.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Time.js b/Time.js index 16c03d5..a552d6d 100644 --- a/Time.js +++ b/Time.js @@ -62,18 +62,19 @@ } else if (hours > 12) { hours = hours - 12; } + var month = today.getMonth() + 1; if (displayMenu == 'Hours:Minutes') { return hours + ":" + today.getMinutes(); } else if (displayMenu == 'Hours:Minutes:Seconds') { return hours + ":" + today.getMinutes() + ":" + today.getSeconds(); } else if (displayMenu == 'Month/Date/Year') { - return today.getMonth() + "/" + today.getDate() + "/" + today.getYear(); + return month + "/" + today.getDate() + "/" + today.getFullYear(); } else if (displayMenu == 'Date/Month/Year') { - return today.getDate() + "/" + today.getMonth() + "/" + today.getYear(); + return today.getDate() + "/" + month + "/" + today.getFullYear(); } else if (displayMenu == 'Month/Date') { - return today.getMonth() + "/" + today.getDate() + "/" + today.getYear(); + return month + "/" + today.getDate(); } else if (displayMenu == 'Date/Month') { - return today.getDate() + "/" + today.getMonth() + "/" + today.getYear(); + return today.getDate() + "/" + month; } };