Title: Re: [WIP] Live Time Addon
Post by: ahrasis on December 21, 2014, 03:13:33 am
I noticed that ElkArte does not have time and date in the header and thus, I wish to add them via mod. I think that can simply be achieved by adding a template layer specifically a new template_th_time_bar. The code:
echo ' ' . date('l, d F Y,') . ' <span id="masa"></span><script type="text/javascript">//<![CDATA[ function JamHidup() { var t=new Date(); var j=t.getHours(); var d=t.getMinutes(); var s=t.getSeconds(); var kala; if (j<=9) {j="0" + j} if (d<=9) {d="0" + d} if (s<=9) {s="0" + s} if (j>=13) {j-=12;kala = " ' . $txt['time_pm'] . '"} else {kala=" ' . $txt['time_am'] . '"} document.getElementById("masa").innerHTML=j + ":" + d + ":" + s + kala; setTimeout("JamHidup()",1000); } JamHidup(); //]]></script>'; }
If I were to put it inside the th_search_bar template (without using its own template function), the code work just fine. But if the suggested code is applied directly before th_search_bar template, however, doesn't seem to work. I was thinking that it supposed to be called together with the callback for th template, but it wasn't called at all.
I will try to pack it and add that after th_login_bar and see how it goes. I will update later.
Title: Re: [WIP] Live Time Addon
Post by: emanuele on December 21, 2014, 04:17:00 am
All these templates are not called "just by themselves". You have to add them to an array in $context.
I thought I added some comment here and there, but apparently I forgot... O:-) Well, you can search for "call_template_callbacks", this function takes as first argument the "bit" that identifies the template that will be called (for example "th") and as second argument the array that will be used to find the functions to call.
Title: Re: [ADDON] Masa - Surfer's Local Live Time
Post by: ahrasis on December 28, 2014, 02:40:43 am
Updated for the following reason(s):
#Change Logs
@Version 1.0.1 - Fix language string error due to language not loaded.
Title: Re: [ADDON] Masa - Surfer's Local Live Time
Post by: ahrasis on August 11, 2016, 04:19:17 am
#Change Logs
@Version 1.0.2 - Cleaning up unused code. - Reorganize so that css can be minified together with other css. - Restructure addon's files' directories and locations.
Title: Re: Masa: Surfer's Local Live Time
Post by: shaitan on February 05, 2017, 07:09:38 am
Is it possible to place all just near the search box ?
(I use chromium tools for responsive emulation)
Title: Re: Masa: Surfer's Local Live Time
Post by: ahrasis on February 05, 2017, 11:43:37 am
You can remove $txt['time_am'] and $txt['time_pm'] in the source code (Masa.template.php) if you don't like the am/pm thingy. Though technically the am/pm should follow your forum language.
I already noted the mobile view problem but haven't got a chance to fix it before. I already added up v.103 in the first post.
Title: Re: Masa: Surfer's Local Live Time
Post by: shaitan on February 05, 2017, 12:02:37 pm
Thank you Ahrasis,
QuoteYou can remove $txt['time_am'] and $txt['time_pm'] in the source code (Masa.template.php) if you don't like the am/pm thingy.
Ok, but I will keep it for the moment. (waiting people reaction)
QuoteThough technically the am/pm should follow your forum language.
Hmm, Am/pm don't exist in french, we have 24 hours format only.
QuoteI already noted the mobile view problem but haven't got a chance to fix it before. I already added up v.103 in the first post.
Understand.
I will update.
Many thank for your work and support. :)
Title: Re: Masa: Surfer's Local Live Time
Post by: shaitan on February 05, 2017, 01:26:55 pm
Ahrasis,
I tried 1.03 version on my mobile and on my wife Mobile. Note 2 and Galaxy grand Prime. Perfect ! the hour is exactly near the search box, Same if I emulate: (nexus 5 for example in attachments)
QuoteI already noted the mobile view problem but haven't got a chance to fix it before. I already added up v.103 in the first post.
Hmm, it was a joke, you fixed it ;)
Title: Re: Masa: Surfer's Local Live Time
Post by: ahrasis on February 08, 2017, 12:26:39 pm
There is a bad code inside the last v.103 so I updated it to version v.104 with option to hide date in mobile view (show only clock) and option to remove pm/am.
#Change Logs
@Version 1.0.4 - Cleaning up and remove bad code. - Add option to remove pm/am. - Add option to hide date in mobile view.
@Version 1.0.3 - Fixing mobile view - Restore sources as addons main folder
Title: Re: Masa: Surfer's Local Live Time
Post by: ahrasis on September 01, 2017, 11:42:49 pm
#Change Logs
@Version 1.0.5 - Fixing up css for small screen / mobile view. - Fixing up css for 1.1x.
Title: Re: Masa: Surfer's Local Live Time
Post by: mgrde on February 01, 2019, 06:32:16 pm
Quote from: ahrasis – Thank you. Haven't visited this for quite some times. Will see what can be done.
something new ???
still not ??? :'(
Title: Re: Masa: Surfer's Local Live Time
Post by: ahrasis on July 23, 2019, 04:26:41 am
Sorry, I totally forgot about it. I finished doing some testing. However, I need to confirm something that is even in 24 hours format, time below 12:00:00
This can be done easily. I can change this but there still be issue as in 24 hours format morning sessions will be seen similar to 12 hours format morning and night session.
Quote from: mgrde – @ahrasis Like 08:00:00 without am/pm does make no sense, likewise 20:00:00 with am/pm is also useless.
Not really. it is the visitors' time and currently they are set to 12 hours format. Some may want am/pm, some may not, so the current option seems fine to me.
Anyway, I have prepared a draft for 1.0.6 version where morning session will display am for both formats but afternoon session will only display pm for 12 hours format. To test replace Masa.template.php with the attached below.