JGonera has submitted this change and it was merged.

Change subject: Improve documentation of mf-last-modified module
......................................................................


Improve documentation of mf-last-modified module

Create keys lookup object to allow better grepping
Document function

Change-Id: I7009cbe7aea33eb4e739827da403bc843de1816a
---
M javascripts/modules/mf-last-modified.js
1 file changed, 17 insertions(+), 1 deletion(-)

Approvals:
  Shirayuki: Looks good to me, but someone else must approve
  JGonera: Verified; Looks good to me, approved
  jenkins-bot: Checked



diff --git a/javascripts/modules/mf-last-modified.js 
b/javascripts/modules/mf-last-modified.js
index e93dde8..cb2d106 100644
--- a/javascripts/modules/mf-last-modified.js
+++ b/javascripts/modules/mf-last-modified.js
@@ -12,12 +12,28 @@
                return { value: Math.round( timestampDelta / limits[i] ), unit: 
units[i] };
        }
 
+       /**
+        * Initialisation function for last modified module.
+        *
+        * Enhances #mw-mf-last-modified element
+        * to show a human friendly date in seconds, minutes, hours, days
+        * months or years
+        *
+        */
        function init() {
                var $lastModified = $( '#mw-mf-last-modified' ),
+                       keys = {
+                               seconds: 
'mobile-frontend-last-modified-seconds',
+                               minutes: 
'mobile-frontend-last-modified-minutes',
+                               hours: 'mobile-frontend-last-modified-hours',
+                               days: 'mobile-frontend-last-modified-days',
+                               months: 'mobile-frontend-last-modified-months',
+                               years: 'mobile-frontend-last-modified-years'
+                       },
                        pageTimestamp = parseInt( $lastModified.data( 
'timestamp' ), 10 ),
                        currentTimestamp = Math.round( new Date().getTime() / 
1000 ),
                        delta = timeAgo( currentTimestamp - pageTimestamp ),
-                       message = mw.msg( 'mobile-frontend-last-modified-' + 
delta.unit, delta.value );
+                       message = mw.msg( keys[ delta.unit ], delta.value );
 
                $lastModified.text( message );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/52917
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7009cbe7aea33eb4e739827da403bc843de1816a
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Shirayuki <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Shirayuki <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to