There was a problem with a Velocity script
Page/schedule-filter-template
ErrorInvocation of method 'substring' in class java.lang.String threw exception java.lang.StringIndexOutOfBoundsException: String index out of range: 11 at schedule-filter-template[line 41, column 16]
Page source:
1: <head>
2: ## <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/themes/base/jquery-ui.css" type="text/css" media="all" />
3: <link rel="stylesheet" type="text/css" href="/overcast/overcast.css" />
4: <script type="text/javascript" src="/jquery-datepicker-min.js"></script>
5: <style type="text/css">
6: .schedule-filter {
7:   position: relative;
8:   padding-bottom: 5px;
9: }
10: .filter-nav {
11:   float: left;
12:   margin-right: 15px;
13: }
14: #calendar-container {
15:   float: left;
16: }
17: #calendar-button {
18:   height: 15px;
19:   padding-left: 22px;
20:   background: url(/images/redesign/calendar_icon.png) no-repeat 0 0;
21:   cursor: pointer;
22: }
23: #datepicker {
24:   display: none;
25:   position: absolute;
26:   left: 0px;
27:   top: 16px;
28: }
29: </style>
30: </head>
31: 
32: #set ($qs = $request.getQueryString())
33: #set ($current_date = $now)
34: #set ($long_date = $current_date.time)
35: 
36: #set ($ms = 24 * 60 * 60 *1000)
37: 
38: 
39: #if ($qs)
40: #set ($y = $qs.substring(5, 9))
41: #set ($m = $qs.substring(9, 11))
42: #set ($d = $qs.substring(11))
43: #set ($current_date = "${y}-${m}-${d}")
44: 
45: #set ($current_date = $tool.date.toDate("yyyy-M-d", $current_date))
46: #set ($cal = $tool.date.toCalendar($current_date.time))
47: #set ($long_date = $cal.getTimeInMillis())
48: 
49: #end  ## querystring
50: 
51: #set ($next_date = $tool.math.add($long_date, $ms))
52: #set ($next_date = $tool.date.toDate($next_date))
53: 
54: #set ($prev_date = $tool.math.sub($long_date, $ms))
55: #set ($prev_date = $tool.date.toDate($prev_date))
56: 
57: #set ($ny = $tool.date.getYear($next_date))
58: #set ($nm = $tool.date.getMonth($next_date))
59: #set ($nd = $tool.date.getDay($next_date))
60: 
61: #set ($py = $tool.date.getYear($prev_date))
62: #set ($pm = $tool.date.getMonth($prev_date))
63: #set ($pd = $tool.date.getDay($prev_date))
64: 
65: #set ($nm = $tool.math.add($nm, 1))
66: #if ($nm < 10)
67:   #set ($nm = "0${nm}")
68: #end
69: #set ($pm = $tool.math.add($pm, 1))
70: #if ($pm < 10)
71:   #set ($pm = "0${pm}")
72: #end
73: 
74: #set ($next_qs = "?date=${ny}${nm}${nd}")
75: #set ($prev_qs = "?date=${py}${pm}${pd}")
76: 
77: <div class="schedule-filter">
78: #if ($page.title.length() > 0)<h1>$page.title</h1>#end
79: 
80: <div class="filter-nav">
81: <a href="${page.url}${prev_qs}">$formatter.formatLongDate($prev_date)</a>
82: <span> | <b>$formatter.formatLongDate($current_date)</b> | </span>
83: <a href="${page.url}${next_qs}">$formatter.formatLongDate($next_date)</a>
84: </div>
85: <div id="calendar-container"><div id="calendar-button">Pick a Date</div><div id="datepicker"></div></div>
86: <div class="clear"></div>
87: </div>
88: 
89: #set ($cy = $tool.date.getYear($current_date))
90: #set ($cm = $tool.date.getMonth($current_date))
91: #set ($cd = $tool.date.getDay($current_date))
92: 
93: #set ($cm = $tool.math.add($cm, 1))
94: #if ($cm < 10)
95:   #set ($cm = "0${cm}")
96: #end
97: 
98: #set ($includeURL = "$page.url?tmpl=custom-daily-template&r=${cy}-${cm}-${cd}")
99: $website.include($includeURL)
100: 
101: <script type="text/javascript">
102:         var url = "http://${request.serverName}${page.url}?date=";
103: 	$(function() {
104: 		$( "#datepicker" ).datepicker({
105:                         dateFormat: 'yy-mm-dd',
106: 			showOn: "button",
107: 			buttonImage: "/images/setup/calendar_icon.png",
108: 			buttonImageOnly: true,
109:                         numberOfMonths: 3,
110:                         showCurrentAtPos: 1,
111:                         onSelect: function(dateText, inst) {
112:                             for (var i=0; i < dateText.length; i++) {
113:                               var c = dateText.substring(i, i+1);
114:                               if (c  != "-") url += c;
115:                             } window.location.assign(url); return false;
116:                         }
117: 		});
118:                 $("#calendar-button").click( function(e) {
119:                     if (e.target == this) {
120:                         if ($("#datepicker").css("display") == "none") {
121:                             $("#datepicker").slideDown(200);
122:                             $(this).text('Close');
123:                         } else {
124:                             $("#datepicker").slideUp(200);
125:                             $(this).text('Pick a Date');
126:                         }
127:                     }
128:                 });
129: 	});
130: </script>
131: 
132: $wiki