From 3efe2b4621d3e076f42649683e2b01b54366399b Mon Sep 17 00:00:00 2001 From: NexusNovaz <tylerstaples21@outlook.com> Date: Sat, 8 Mar 2025 19:19:53 +0000 Subject: [PATCH 1/2] Issue #3511702: Updated readme and help page --- README.md | 208 ++++++------------------------------------------- jstimer.module | 26 +++---- 2 files changed, 35 insertions(+), 199 deletions(-) diff --git a/README.md b/README.md index 68d360f..fa6aeb0 100644 --- a/README.md +++ b/README.md @@ -1,203 +1,39 @@ +# Javascript Timer module -# OVERVIEW The Javascript Timer module provides a timer api that can hook html elements to javascript widget objects. This is useful if you want a moving timer/clock or a widget that updates every second. It comes with widgets for a countdown timer, a countup timer, and a clock. +## Table of contents -# INSTALLING -Simply by activating the module and a widget. -There are no module dependencies. -There are no table components. +- Requirements +- Recommended modules +- Installation +- Configuration +- Maintainers +## Requirements -# GENERAL USAGE -You can either build-up your own nested <span> tags within -a full html (or filtered with <spans allowed>) input format, or -use php directly. There are now theme functions to help with -the php formatted strings. +This module has no dependencies -NOTE: the date format is an ISO8601 subset, so use the formats as you see them below. +## Recommended modules +This module has no recommended modules -## Inline HTML Examples +## Installation -Countdown timer (with DateTime specified): -``` -<span class="jst_timer"> - <span style="display:none" class="datetime">2015-05-02T08:11:00-08:00</span> -</span> -``` +Install as you would normally install a contributed Drupal module. For further information, see [Installing Drupal Modules](https://www.drupal.org/docs/extending-drupal/installing-drupal-modules). +## Configuration -Countdown timer (with interval specified in seconds): -``` -<span class="jst_timer"> - <span style="display:none" class="interval">22</span> -</span> -``` +Module configuration can be found at `admin/config/system/jstimer`. The config +relies on other modules to generate the config form. For example the jst_clock or +jst_timer modules bundled with this module. +## Maintainers -Countdown timer with output format number setting: -``` -<span class="jst_timer"> -<span class="datetime" style="display: none;">2015-11-27T10:15:00-07:00</span> -<span class="format_num" style="display:none;">2</span> -</span> -``` - - -Count up timer: -``` -<span class="jst_timer"> - <span style="display:none" class="datetime">2010-09-20T08:11:00Z</span> - <span style="display:none" class="dir">up</span> -</span> -``` - - -NASA style down/up timer: -``` -<span class="jst_timer"> - <span class="datetime" style="display: none;">2012-10-26T10:28:00-07:00</span> - <span class="dir" style="display: none;">up</span> - <span class="format_txt" style="display:none;">%sign%%hours%::%mins%::%secs%</span> -</span> -``` - - -SVG Clock: -``` -<span class="jst_clock"> - <span style="display:none" class="clock_type">3</span> - <span style="display:none" class="size">400</span> -</span> -``` - - -HTML Canvas Clock: -``` -<span class="jst_clock"> - <span style="display:none" class="clock_type">2</span> - <span style="display:none" class="size">200</span> -</span> -``` - - - - -## PHP Input Format Examples - -Countdown timer: -``` -<?php -print theme('jstimer', array( - 'widget_name' => 'jst_timer', - 'widget_args' => array( - 'datetime' => '2015-05-02T08:11:00-08:00' - ) -)); -?> -``` - - -Countdown timer with output format number setting: -``` -<?php -print theme('jstimer', array( - 'widget_name' => 'jst_timer', - 'widget_args' => array( - 'datetime' => '2015-05-02T08:11:00-08:00', - 'format_num' => 2, - ) -)); -?> -``` - -Count up timer: -``` -<?php -print theme('jstimer', array( - 'widget_name' => 'jst_timer', - 'widget_args' => array( - 'datetime' => '2010-05-02T08:11:00+02:00', - 'dir'=>'up' - ) -)); -?> -``` - -NASA style down/up timer: -``` -<?php -print theme('jstimer', array( - 'widget_name' => 'jst_timer', - 'widget_args' => array( - 'datetime' => '2015-05-02T08:11:00+02:00', - 'dir'=>'up', - 'format_txt' => '%sign%%hours%::%mins%::%secs%' - ) -)); -?> -``` - -Clock Widget: -``` -<?php -print theme('jstimer', array( - 'widget_name' => 'jst_clock', - 'widget_args' => array( - 'clock_type' => 2, - 'size' => 200 - ) -)); -?> -``` - - -# Timer widget OUTPUT FORMAT -The display of the actual timer is configurable in the Site configuration -admin menu: countdowntimer. - -IMPORTANT: If you have a format_num and a format_txt in a timer, the format_txt -value will trump the format_num value. - -Currently supported replacement values are: - -Target date replacements: -- %day% - Day number of target date (0-31) -- %month% - Month number of target date (1-12) -- %year% - Year number of target date (2013) -- %dow% - Day-Of-Week (Mon-Sun) -- %moy% - Month-Of-Year (Jan-Dec) - - -Duration/Interval replacements: -- %years% - Years from set date (ex:2013, integer number) -- %ydays% - (Days - Years) from set date(integer number) -- %days% - Total Days from set date (integer number) -- %hours% - (Hours - Days) from set date (integer number, zero padded) -- %hours_nopad% - (Hours - Days) from set date (integer number, no padding) -- %mins% - (Minutes - Hours) from set date (intger number, zero padded) -- %mins_nopad% - (Minutes - Hours) from set date (intger number, no padding) -- %secs% - (Seconds - Minutes) from set date (integer number, zero padded) -- %secs_nopad% - (Seconds - Minutes) from set date (integer number, no padding) -- %months% - (Months - Years) from set date, will be 11 or less (integer number) -- %tot_months% - Total months from set date, can be larger than 11 (integer number) -- %tot_hours% - Total hours from set date, can be larger than 23 (integer number) -- %tot_minutes% - Total minutes from set date, can be larger than 59 (integer number) -- %tot_seconds% - Total seconds from set date, can be larger than 59 (integer number) -- %sign% - Is used for NASA style countdown, will be '-' before set date and '' after set date (blank or '-') - - - - -# CAVEATS -If a daylight saving time shift should occur in either the client's tz or -the target's tz between the current date/time and your target datetime, -you could be off by one hour until you pass the point of conversion. - -If you use the PHP input format beware. If you have a syntax or other PHP error -and you've put your code in a block visible on all pages your entire site -may go down and you'll need to edit your database directly to delete that block! +- [Aaron Ferris] - [aaron.ferris](https://www.drupal.org/u/aaronferris) +- [Ivan Trokhanenko] - [i-trokhanenko](https://www.drupal.org/u/i-trokhanenko) +- [John Vandervort] - [jvandervort](https://www.drupal.org/u/jvandervort) +- [Paul Sebborn] - [psebborn](https://www.drupal.org/u/psebborn) diff --git a/jstimer.module b/jstimer.module index 4b591bd..d8d0b29 100644 --- a/jstimer.module +++ b/jstimer.module @@ -1,6 +1,8 @@ <?php use Drupal\Core\File\FileSystemInterface; +use Drupal\Core\Routing\RouteMatchInterface; + /** * @file * A module which creates javascript timed dhtml things. @@ -13,19 +15,17 @@ use Drupal\Core\File\FileSystemInterface; /** * Implementation of hook_help(). */ -function jstimer_help($path, $arg) { - switch ($path) { - case 'admin/modules#description': - return t('A module which creates javascript timers.'); - case 'admin/help#jstimer': - $output = <<<HELP_TXT -<p>Please look at the readme.txt file that comes with this module. It really has a lot of great information.</p> -<p>The javascript timer module provides an api to allow you to make dhtml widgets which are updated every second. -There are some good examples for node and block usage in the readme.txt file. -Please look at it.</p> -HELP_TXT; - $output .= '<p>Usage Example for a Node<br/><span class="jst_timer">Count Up to 11:30<br/><span style="display:none" class="datetime">2007-02-26T09:30:00</span><br/><span style="display:none"<br/>'; - $output .= '<span style="display:none" class="dir">up</span><br/></span></p>'; +function jstimer_help($route_name, RouteMatchInterface $route_match) { + switch ($route_name) { + case 'help.page.jstimer': + $output = '<p>' . t('Please look at the readme.txt file that comes with this module. It really has a lot of great information.') . '</p>'; + $output .= '<p>' . t('The javascript timer module provides an api to allow you to make dhtml widgets which are updated every second.') . '</p>'; + $output .= '<p>' . t('Usage Example for a Node:<br/>'); + $output .= '<pre>' . t('<span class="jst_timer">Count Up to 11:30<br/>'); + $output .= t('	<span style="display:none" class="datetime">2025-02-26T11:30:00</span><br/>'); + $output .= t('	<span style="display:none"<br/>'); + $output .= t('	<span style="display:none" class="dir">up</span><br/>'); + $output .= t('</span></p>') . '</pre>'; return ($output); } } -- GitLab From 40e37371c5eccfd19252dc2cc729d0c6a2020c72 Mon Sep 17 00:00:00 2001 From: NexusNovaz <tylerstaples21@outlook.com> Date: Sun, 9 Mar 2025 15:24:56 +0000 Subject: [PATCH 2/2] Issue #3511702: Updated readme and help page --- README.md | 179 +++++++++++++++++++++++++++++++++++++++++++++++++ jstimer.module | 2 +- 2 files changed, 180 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fa6aeb0..8b9252a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ countup timer, and a clock. - Recommended modules - Installation - Configuration +- General Usage + - Inline HTML Examples + - PHP Input Format Examples +- Timer widget OUTPUT FORMAT - Maintainers ## Requirements @@ -31,6 +35,181 @@ Module configuration can be found at `admin/config/system/jstimer`. The config relies on other modules to generate the config form. For example the jst_clock or jst_timer modules bundled with this module. +## General Usage +You can either build-up your own nested <span> tags within +a full html (or filtered with <spans allowed>) input format, or +use php directly. There are now theme functions to help with +the php formatted strings. + +NOTE: the date format is an ISO8601 subset, so use the formats as you see them below. + + +### Inline HTML Examples + +Countdown timer (with DateTime specified): +``` +<span class="jst_timer"> + <span style="display:none" class="datetime">2015-05-02T08:11:00-08:00</span> +</span> +``` + + +Countdown timer (with interval specified in seconds): +``` +<span class="jst_timer"> + <span style="display:none" class="interval">22</span> +</span> +``` + + +Countdown timer with output format number setting: +``` +<span class="jst_timer"> +<span class="datetime" style="display: none;">2015-11-27T10:15:00-07:00</span> +<span class="format_num" style="display:none;">2</span> +</span> +``` + + +Count up timer: +``` +<span class="jst_timer"> + <span style="display:none" class="datetime">2010-09-20T08:11:00Z</span> + <span style="display:none" class="dir">up</span> +</span> +``` + + +NASA style down/up timer: +``` +<span class="jst_timer"> + <span class="datetime" style="display: none;">2012-10-26T10:28:00-07:00</span> + <span class="dir" style="display: none;">up</span> + <span class="format_txt" style="display:none;">%sign%%hours%::%mins%::%secs%</span> +</span> +``` + + +SVG Clock: +``` +<span class="jst_clock"> + <span style="display:none" class="clock_type">3</span> + <span style="display:none" class="size">400</span> +</span> +``` + + +HTML Canvas Clock: +``` +<span class="jst_clock"> + <span style="display:none" class="clock_type">2</span> + <span style="display:none" class="size">200</span> +</span> +``` + + + + +### PHP Input Format Examples + +Countdown timer: +``` +<?php +print theme('jstimer', array( + 'widget_name' => 'jst_timer', + 'widget_args' => array( + 'datetime' => '2015-05-02T08:11:00-08:00' + ) +)); +?> +``` + + +Countdown timer with output format number setting: +``` +<?php +print theme('jstimer', array( + 'widget_name' => 'jst_timer', + 'widget_args' => array( + 'datetime' => '2015-05-02T08:11:00-08:00', + 'format_num' => 2, + ) +)); +?> +``` + +Count up timer: +``` +<?php +print theme('jstimer', array( + 'widget_name' => 'jst_timer', + 'widget_args' => array( + 'datetime' => '2010-05-02T08:11:00+02:00', + 'dir'=>'up' + ) +)); +?> +``` + +NASA style down/up timer: +``` +<?php +print theme('jstimer', array( + 'widget_name' => 'jst_timer', + 'widget_args' => array( + 'datetime' => '2015-05-02T08:11:00+02:00', + 'dir'=>'up', + 'format_txt' => '%sign%%hours%::%mins%::%secs%' + ) +)); +?> +``` + +Clock Widget: +``` +<?php +print theme('jstimer', array( + 'widget_name' => 'jst_clock', + 'widget_args' => array( + 'clock_type' => 2, + 'size' => 200 + ) +)); +?> +``` + + +## Timer widget OUTPUT FORMAT +IMPORTANT: If you have a format_num and a format_txt in a timer, the format_txt +value will trump the format_num value. + +Currently supported replacement values are: + +Target date replacements: +- %day% - Day number of target date (0-31) +- %month% - Month number of target date (1-12) +- %year% - Year number of target date (2013) +- %dow% - Day-Of-Week (Mon-Sun) +- %moy% - Month-Of-Year (Jan-Dec) + + +Duration/Interval replacements: +- %years% - Years from set date (ex:2013, integer number) +- %ydays% - (Days - Years) from set date(integer number) +- %days% - Total Days from set date (integer number) +- %hours% - (Hours - Days) from set date (integer number, zero padded) +- %hours_nopad% - (Hours - Days) from set date (integer number, no padding) +- %mins% - (Minutes - Hours) from set date (intger number, zero padded) +- %mins_nopad% - (Minutes - Hours) from set date (intger number, no padding) +- %secs% - (Seconds - Minutes) from set date (integer number, zero padded) +- %secs_nopad% - (Seconds - Minutes) from set date (integer number, no padding) +- %months% - (Months - Years) from set date, will be 11 or less (integer number) +- %tot_months% - Total months from set date, can be larger than 11 (integer number) +- %tot_hours% - Total hours from set date, can be larger than 23 (integer number) +- %tot_minutes% - Total minutes from set date, can be larger than 59 (integer number) +- %tot_seconds% - Total seconds from set date, can be larger than 59 (integer number) +- %sign% - Is used for NASA style countdown, will be '-' before set date and '' after set date (blank or '-') + ## Maintainers - [Aaron Ferris] - [aaron.ferris](https://www.drupal.org/u/aaronferris) diff --git a/jstimer.module b/jstimer.module index d8d0b29..2438c2b 100644 --- a/jstimer.module +++ b/jstimer.module @@ -18,7 +18,7 @@ use Drupal\Core\Routing\RouteMatchInterface; function jstimer_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.jstimer': - $output = '<p>' . t('Please look at the readme.txt file that comes with this module. It really has a lot of great information.') . '</p>'; + $output = '<p>' . t('Please look at the README.md file that comes with this module. It really has a lot of great information.') . '</p>'; $output .= '<p>' . t('The javascript timer module provides an api to allow you to make dhtml widgets which are updated every second.') . '</p>'; $output .= '<p>' . t('Usage Example for a Node:<br/>'); $output .= '<pre>' . t('<span class="jst_timer">Count Up to 11:30<br/>'); -- GitLab