{"id":516,"date":"2019-05-30T17:28:12","date_gmt":"2019-05-30T15:28:12","guid":{"rendered":"https:\/\/asdw.de\/laufende-aktuelle-zeit-in-scriptcase-menu-applikation\/"},"modified":"2019-05-30T17:37:41","modified_gmt":"2019-05-30T15:37:41","slug":"laufende-aktuelle-zeit-in-scriptcase-menu-applikation","status":"publish","type":"post","link":"https:\/\/asdw.de\/en\/laufende-aktuelle-zeit-in-scriptcase-menu-applikation\/","title":{"rendered":"Display current time in a Scriptcase menu application"},"content":{"rendered":"<h2>Show the current time refreshing in a menu application (Scriptcase)<\/h2>\n<p>In <a href=\"https:\/\/scriptcase.net\" target=\"_blank\" rel=\"noopener noreferrer\">Scriptcase<\/a> projects you can show the current time interactive.<br \/>\nBest to use is the menu application, cause it usually wraps the other applications of a project.<\/p>\n<h3>1. Define the position of the timer<\/h3>\n<p>Fist you have to define the position where to display the time.<br \/>\nAs sample we&#8217;re setting the value in the menu structur as the short\u00a0 HTML code <span class=\"lang:php decode:true crayon-inline\">&lt;div id=&#8217;my_time&#8217;&gt;timer&lt;\/div&gt;<\/span><\/p>\n<p><a href=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-511 size-large\" src=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-1024x292.png\" alt=\"Platzieren des Timers im Men\u00fc\" width=\"605\" height=\"173\" srcset=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-1024x292.png 1024w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-300x86.png 300w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-768x219.png 768w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-600x171.png 600w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-100x29.png 100w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-150x43.png 150w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-200x57.png 200w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-450x128.png 450w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1-900x257.png 900w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_1.png 1503w\" sizes=\"(max-width: 605px) 100vw, 605px\" \/><\/a><\/p>\n<p>The element where the time is to be shown is named <em>my_time<\/em>.<\/p>\n<h3>2. Code to show the time<\/h3>\n<p>The menu-Application currently do not have \u00a0<em>Programming &gt; JavaScript Methods<\/em><\/p>\n<p>Therefore we add the code in the menu&#8217;s onLoad event:<\/p>\n<pre class=\"lang:php decode:true\" title=\"Code zum Aktualisieren der Zeit-Anzeige\">?&gt;\r\n&lt;script&gt;\r\nwindow.onload = function(){\t\r\n\tfunction startTime() {\r\n\t  var today = new Date();\r\n\t  var h = today.getHours();\r\n\t  var m = today.getMinutes();\r\n\t  var s = today.getSeconds();\r\n\t  m = checkTime(m);\r\n\t  s = checkTime(s);\r\n\t  document.getElementById('my_time').innerHTML =\r\n\t  h + \":\" + m + \":\" + s;\r\n\t  var t = setTimeout(startTime, 500);\r\n\t}\r\n\tfunction checkTime(i) {\r\n\t  if (i &lt; 10) {i = \"0\" + i};  \/\/ add zero in front of numbers &lt; 10\r\n\t  return i;\r\n\t}\r\n\t\r\n\tstartTime();\r\n}\r\n\t\r\n&lt;\/script&gt;\r\n\r\n&lt;?php<\/pre>\n<p>Hint:<\/p>\n<p>Using\u00a0<span class=\"lang:php decode:true crayon-inline \">window.onload = function(){<\/span> ensures that the functions will not be started untill the entire window is displayed. Not doing so would possibly start the functions when the &lt;div&gt; element is not existient.<\/p>\n<p>Executing the menu application shows the current time:<\/p>\n<p><a href=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-513\" src=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2.png\" alt=\"Timer-Anzeige rechts im Men\u00fc\" width=\"522\" height=\"122\" srcset=\"https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2.png 522w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2-300x70.png 300w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2-100x23.png 100w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2-150x35.png 150w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2-200x47.png 200w, https:\/\/asdw.de\/wp-content\/uploads\/2019\/05\/timer_in_scriptcase_menu_2-450x105.png 450w\" sizes=\"(max-width: 522px) 100vw, 522px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Show the current time refreshing in a menu application (Scriptcase) In Scriptcase projects you can show the current time interactive. Best to use is the menu application, cause it usually wraps the other applications of a project. 1. Define the<span class=\"ellipsis\">&hellip;<\/span><\/p>\n<div class=\"read-more\"><a href=\"https:\/\/asdw.de\/en\/laufende-aktuelle-zeit-in-scriptcase-menu-applikation\/\">Read more &#8250;<\/a><\/div>\n<p><!-- end of .read-more --><\/p>\n","protected":false},"author":2,"featured_media":514,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[170,168,172,171,50,173,169],"_links":{"self":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/516"}],"collection":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/comments?post=516"}],"version-history":[{"count":3,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/posts\/516\/revisions\/519"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/media\/514"}],"wp:attachment":[{"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/asdw.de\/en\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}