Tags:
create new tag
view all tags

SID-01608: Problem setting initial time & date in JSCalendarContrib

Status: Unanswered Unanswered TWiki version: 5.1.0 Perl version: 5.8.8
Category: JSCalendarContrib Server OS: SLC5.8, kernel 2.6.18-308.20.1.el5, x86_64 Last update: 12 years ago

I am unable to set a initial date+time in the JSCalendarContribInline as described in the documentation. Instead the the default option of the current time is always presented.

-- TomCrane - 2012-12-08

Discussion and Answer

Warning: Can't find topic TWiki06x01.JSCalendarContribInline

Demonstrate problem of setting the initial date/time in JSCalendarContribInline.

The pop-up calendar should start with an initial date+time of Sep 09 2001... specified via Javascript's Calendar.setup({date: anotherdate}) setup function as described in https://twiki.org/p/pub/TWiki06x01/JSCalendarContrib/doc/html/reference.html#node_sec_2.3 but does not. Instead the initial date+time presented is always the default value which is the current date+time.

Click in this field to activate the pop-up calendar

<input type="text" name="f_date" id="f_date" size="30" value="%URLPARAM{"f_date" encode="entity"}%" />

Then click on the date to continue.

Tested and problem reproduced on TWiki-5.1.0, Sat, 20 Aug 2011, build 22128, Plugin API version 1.4 & Firefox 2.0.0.5 on Linux/Slackware 11.0, IE 6.0.2800 1106 on Win2k, IE 8.0.6001 18702 on Win XPPro, Firefox 10.0.11 on Linux/SLC5.8,

Addendum: Problem reproduced on twiki.org TWIki version TWiki-5.1.0.

<script type="text/javascript"> <!--
     // Globol scope variables
     var anotherdate = new Date(1000000000000); // Sep 09 2001

     // This function should get called with the initial date set to anotherdate
     function catcalc(cal) {
     var date = cal.date;
     log("anotherdate is"); log(anotherdate); log("date from calendar is"); log(date);
     }

Calendar.setup({
       inputField     :    "f_date",      // id of the input field
       ifFormat       :    "%Y-%m-%d %H:%M:%S",   // format of the input field
       showsTime      :    true,
       timeFormat     :    "24",
       onUpdate       :    catcalc,
            date      :   anotherdate
       });
//--> </script>

<script type="text/javascript"> <!--
// Simple Debug, written by Chris Klimas
// licensed under the GNU LGPL.
// http://www.gnu.org/licenses/lgpl.txt
//
// There are three functions defined here:
//
// log (message)
// Logs a message. Every second, all logged messages are displayed
// in an alert box. This saves you from having to hit Return a ton
// of times as your script executes.
//
// inspect (object)
// Logs the interesting properties an object possesses. Skips functions
// and anything in CAPS_AND_UNDERSCORES.
//
// inspectValues (object)
// Like inspect(), but displays values for the properties. The output
// for this can get very large -- for example, if you are inspecting
// a DOM element.


function log (message)
{
   if (! _log_timeout)
      _log_timeout = window.setTimeout(dump_log, 1000);
   
   _log_messages.push(message);


   function dump_log()
   {
      var message = '';
      
      for (var i = 0; i < _log_messages.length; i++)
         message += _log_messages[i] + '\n';
            
      alert(message);
      
      _log_timeout = null;
      delete _log_messages;
      _log_messages = new Array();
   }
}


function inspect (obj)
{
    var message = 'Object possesses these properties:\n';
   
    if (obj)
   {
       for (var i in obj)
      {
          if ((obj[i] instanceof Function) || (obj[i] == null) ||
         (i.toUpperCase() == i))
         continue;
         
          message += i + ', ';
      }
      
       message = message.substr(0, message.length - 2);
   }
    else
   message = 'Object is null';
   
    log(message);
}

function inspectValues (obj)
{
   var message = '';
   
   if (obj)
      for (var i in obj)
      {
         if ((obj[i] instanceof Function) || (obj[i] == null) ||
               (i.toUpperCase() == i))
            continue;
         
         message += i + ': ' + obj[i] + '\n';
      }
   else
      message = 'Object is null';
   
   log(message);
}

var _log_timeout;
var _log_messages = new Array();
//--> </script>

-- TomCrane - 2012-12-08

Why not simply specify 2001-09-09 in the text field? That value is taken and shown as the active date.

-- PeterThoeny - 2012-12-10

Solution

Here is a solution to the problem which works for me. It uses a slightly modified version of https://twiki.org/p/pub/TWiki06x01/JSCalendarContrib/calendar-setup.js saved as https://twiki.org/p/pub/TWiki06x01/JSCalendarContrib/calendar-setup-initial-datetime_mod.js. See the attached patch here.

To use it the original include header

%INCLUDE{"%SYSTEMWEB%.JSCalendarContribInline"}%

is replaced by,

<style type='text/css' media='all'>@import url('%PUBURLPATH%/%SYSTEMWEB%/JSCalendarContrib/calendar-blue.css');.calendar {z-index:2000;}</style><script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JSCalendarContrib/calendar.js'></script><script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JSCalendarContrib/lang/calendar-en.js'></script><script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JSCalendarContrib/calendar-setup-initial-datetime_mod.js'></script>

-- TomCrane - 2012-12-13

Closing this question after more than 30 days of inactivity. Feel free to reopen if needed. Consider engaging one of the TWiki consultants if you need timely help. We invite you to get involved with the community, it is more likely you get community support if you support the open source project!

-- Peter Thoeny - 2013-03-05

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Unanswered
Title Problem setting initial time & date in JSCalendarContrib
SupportCategory JSCalendarContrib
TWiki version 5.1.0
Server OS SLC5.8, kernel 2.6.18-308.20.1.el5, x86_64
Web server Apache 2.2.3
Perl version 5.8.8
Browser & version Firefox 2.0.0.5.
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2013-03-05 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.