Software development, photography, jokes, ....


noyb-logo

Sites by me

 
sds82-logo
tas-logoTransportation Administration System
snoezelkussen-logo-kleinstSnoezelen Pillows for Dementia
ikzoekeenbegeleider-logoBegeleiders voor gehandicapten
Laat uw hond het jaarlijkse vuurwerk overwinnen
Betuweroute en Kunst
logo 50x50Hey Vos! Je eigen naam@vos.net emailadres?
Kunst in huis? Nicole Karrèr maakt echt bijzonder mooie dingen
nettylogo2Kunst in huis? Netty Franssen maakt ook bijzonder mooie dingen

Hosting Favorites

 
ANU Internet Services
Netim
GoDaddy
XEL Media

Blogroll

 
Bomenstichting
Google Translate
PHP
MySQL
jQuery
jQuery UI
YourHead Stacks API
Favicon Generator.
Password Generator.
Check HTTPS problems




Categories

Archives

Marc's Place


 

Photo-blog


Alle getoonde foto's zijn (c) MHE Vos, Nederland.

All shown photo's are (c) MHE Vos, Netherlands.


Below blog is created with the Blogspot.stack using the Categories-filter.

mv_timeMenu

 Permalink
I just edited the tag mv_timeMenu on tagSwap. Because copy/paste on tagSwap does something with line endings that makes much code end up all being on one line, I post the routine here too. Simply copy & paste.

/*
  Creates a list of time values inside a <select></select>. Example:
  <select name="xyz" class="abc" id="def">
  [mv_timeMenu(-fromHour=800, -toHour=2300, -minutes=25, -selected=$db_value]
  </select>
*/
define_tag('mv_timeMenu', -optional='fromhour', -copy, -optional='tohour', -copy, -optional='minutes', -copy, -optional='selected', -copy, -optional='firstblank', -EncodeNone);
  local('result' = '', 'p' = 0, 'z' = 0, 'h' = 0, 'm' = 0, 'y' = 0, 'f' = false);

  if(! local_defined('firstblank'));
    local('firstblank' = 0);
  else(integer(#firstblank) <= 0);
    #firstblank = 0;
  /if;
  #firstblank = integer(#firstblank);

  if(! local_defined('fromhour'));
    local('fromhour' = 0);
  else(integer(#fromhour) <= 0);
    #fromhour = 0;
  /if;
  #fromhour = integer(#fromhour);

  if(! local_defined('tohour'));
    local('tohour' = 2359);
  else(integer(#tohour) <= 0 || integer(#tohour) >= 2400);
    #tohour = 2359;
  /if;
  #tohour = integer(#tohour);

  if(! local_defined('minutes'));
    local('minutes' = 15);
  else(integer(#minutes) <= 0);
    #minutes = 15;
  /if;
  #minutes = integer(#minutes);
  
  if(#firstblank);
    #result = '<option value="" ';
    if(local_defined('selected'));
      if(#selected == '');
        #result += ' selected="selected"';
      /if;
    /if;
    #result += '></option>';
  /if;
  
  // Calculate correct starting point
  #z = #fromhour;
  #h = integer(#z / 100);      // Take hours-part
  #m = #z - (#h * 100);      // Take minutes-part
  #y = integer(#m / #minutes);  // Calculate how many times the frequency fits

  // Calculate new minutes-starting-point
  if(#m == (#y * #minutes));
    #m = #y * #minutes;
  else;
    #m = (#y + 1) * #minutes;
  /if;
  
  #y = integer(#m / 60);      // Calculate how many hours minutes-starting-point contains
  #h += #y;            // Add those hours to the hours-part
  #m -= (#y * 60);        // Subtract the hours from minutes-starting-point
  #z = (#h * 100) + #m;      // Construct new time

  #p = 0;
  #f = false;
  while(#z <= #tohour);
    #result += '<option value="' + mv_fmtnum(#z, '####', 'R') + '" ';
    if(local_defined('selected'));
      if(!#f && #selected != '' && #selected >= #p && #selected <= #z);
        #result += ' selected="selected"';
        #f = true;
      /if;
    /if;
    #result += '>' + mv_fmtnum(#z, '##:##', 'R') + '</option>';

    #p = #z;        // Save previous time
    
    #h = integer(#z / 100);  // Take hours-part
    #m = #z - (#h * 100);  // Take minutes-part
    #m += #minutes;      // Add interval to the minutes to get total-minutes
    #y = integer(#m / 60);  // Calculate how many hours total-minutes contains
    #h += #y;        // Add those hours to the hours-part
    #m -= (#y * 60);    // Subtract the hours from total-minutes
    #z = (#h * 100) + #m;  // Construct new time
  /while;

  return(#result);
/define_tag;

Alle getoonde foto's zijn (c) MHE Vos, Nederland.

All shown photo's are (c) MHE Vos, Netherlands.


© 1997- Marc Vos (and others)   -   Privacy Statement   -    Contact Me

On this website, Google Analytics is used to track visitor statistics. These are anonymised data about the number of visitors, which pages they visit on this site, from which regions they visit, which web browsers they use, etc.. You will also see non-personalised ads via Google AdSense. Cookies from Paddle or Paypal are placed when you click on a 'Buy now!' or 'Donate!' button, and possible cookies from Disqus when you use that system to comment on one or more blogposts.
Privacy Statement