Events
Dec 12
There was a problem with a Velocity script
Pagescoreboard-slider-template
ErrorInvocation of method 'substring' in class java.lang.String threw exception java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at scoreboard-slider-template[line 135, column 29]
Page source:
1: #set ($id = "scoreboard-slider")
2: #if ($request.getParameter("id"))
3:   #set ($idParam = $request.getParameter("id"))
4:   #set ($id = "${id} ${idParam}")
5: #end
6: 
7: ## PICK UP OPTIONS
8: $website.include("options")
9: #set ($options = $request.getAttribute("options"))
10: 
11: #set ($hideExhibition = false)
12: #if ($options.get("schedule_hide_exhibition_events") == true)
13:   #set ($hideExhibition = true)
14: #end
15: 
16: #if ($request.getParameter("hideExhibition"))
17:   #set ($hideExhibition = $request.getParameter("hideExhibition"))
18: #end
19: 
20: #set ($linksOrder = ["RC", "BS", "RE", "GA", "AU", "VI", "LS", "DI", "TI", "PR"])
21: #set ($excludeLinksWhenEventIsFinished = ["LS", "DI", "TI", "PR"])
22: 
23: #set ($showVsAt = true)
24: #if ($options.get("schedule_hide_vs_at") == true)
25:   #set ($showVsAt = false) 
26: #end
27: 
28: #set ($includeTimeZone = false)
29: #if ($options.get("calendarIncludeTimeZone"))
30:   #set ($includeTimeZone = $options.get("calendarIncludeTimeZone").toLowerCase())
31: #end
32: 
33: #set ($showTeamLogo = false)
34: #if ($request.getParameter("showTeamLogo") == true)
35:   #set ($showTeamLogo = true)
36: #end
37: 
38: #set ($showJustOpponent = false)
39: #if ($request.getParameter("showJustOpponent") == true)
40:   #set ($showJustOpponent = true)
41: #end
42: 
43: #set ($resultFormat = "AP1")
44: #if ($options.get("schedule_result_format").equals("L, 1-2"))
45:   #set ($resultFormat = "AP2")
46: #end
47: 
48: #set ($dateFormat = "'<span>'EEE'</span> <span>'MMM'</span> <span>'dd'</span>'")
49: #if ($request.getParameter("dateFormat"))
50:   #set ($dateFormat = $request.getParameter("dateFormat"))
51: #end
52: 
53: #set ($restrictLinks = true)
54: #if ($options.get("schedule_restrict_links") == false)
55:   #set ($restrictLinks = false)
56: #end
57: 
58: #set ($linksAbbreviations = { "Preview": "PR", "Box Score": "BX", "Results": "R", "Recap": "RC", "Live stats": "LS", "Video": "V", "Audio": "A", "Photos": "PH", "Tickets": "T", "Directions": "DR" })
59: 
60: #set ($showLinkIcons = false)
61: #if ($request.getParameter("showLinkIcons") == true)
62:   #set ($showLinkIcons = true)
63: #end
64: 
65: #set ($abbreviatedLinks = false)
66: #if ($request.getParameter("abbreviatedLinks") == true)
67:   #set ($abbreviatedLinks = true)
68: #end
69: 
70: #set ($autoScroll = false)
71: #if ($request.getParameter("autoScroll") == true)
72:   #set ($autoScroll = true)
73: #end
74: 
75: #set ($showNavi = false)
76: #if ($request.getParameter("showNavi") == true)
77:   #set ($showNavi = true)
78: #end
79: 
80: #set ($autoInterval = 4000)
81: #if ($tool.math.toInteger($request.getParameter("autoInterval")) > 0)
82:   #set ($autoInterval = $tool.math.mul($request.getParameter("autoInterval", 1000)))
83: #end
84: 
85: #set ($circularScroll = false)
86: #if ($request.getParameter("circularScroll") == true)
87:   #set ($circularScroll = true)
88: #end
89: 
90: #set ($colLimit = 5)
91: #if ($tool.math.toInteger($request.getParameter("colLimit")))
92:   #set ($colLimit = $tool.math.toInteger($request.getParameter("colLimit")))
93: #end
94: 
95: #set ($showPlayPause = false)
96: #if ($request.getParameter("showPlayPause") == true)
97: 	#set ($showPlayPause = true)
98: #end
99: 
100: #set ($fullSchedulePos = "bottom")
101: #set ($fullSchedulePos = $request.getParameter("fullSchedulePos"))
102: 
103: #set ($today = $tool.date.format("MMMM dd yyyy", $now, $tool.date.getLocale(), $website.profile.timeZone))
104: #set ($today = $tool.date.toDate("MMMM dd yyyy", $today))
105: 
106: ################################ MACROS #####################################
107: #macro (printTeamLogo $team)
108:   #if ($showTeamLogo)
109:     #if ($team.teamId)
110:       <span class="team-logo"><img src="${website.teamLogo($team.teamId)}" alt="" /></span>
111:     #end
112:   #end
113: #end
114: 
115: #macro (printVa $event)
116:   #if ($event.neutralSite.length() > 0) 
117:     <span class="va">vs.</span>
118:   #else 
119:     #if (!$event.home)<span class="va">at</span>#end 
120:   #end
121: #end
122: 
123: #macro (printSport $event)
124:   #set ($feedURL = $event.feedURL)
125:   
126:   #set ($feedURL = $event.feedURL) ## in the form http://www.somedomain.com/sports/mbkb/2014-15/schedule?tmpl=sfs-template
127:   #if ($feedURL.indexOf("://") >= 0)
128:     #set ($feedURL = $feedURL.split("//").get(1)) ## remove the http:// bit from the URL
129:   #end
130:   #set ($startIndex = $feedURL.indexOf("/"))
131:   #set ($endIndex = $feedURL.length())
132:   #if ($feedURL.lastIndexOf("?") >= 0)
133:     #set ($endIndex = $feedURL.lastIndexOf("?"))
134:   #end
135:   #set ($feedURL = $feedURL.substring($startIndex, $endIndex)) ## remove the domain and tmpl parts
136: 
137:   #if ($website.exists($feedURL))
138: 	#set ($ariaLabel = "${event.sport}: schedule")
139:     #if ($feedURL.matches("/sports/.*/\d{4}-\d{2}/.*"))
140:       #set ($seasonStr = $feedURL.split("/").get(3))
141:       #set ($ariaLabel = "${event.sport}: ${seasonStr} schedule") ## aria-label would be something like Men's Basketball 2017-18 schedule
142:     #end
143: 	
144:     <a href="${feedURL}" aria-label="$ariaLabel">$event.sport</a>
145:   #else
146:     <span>$event.sport</span>
147:   #end
148: #end
149: 
150: #macro (printLinkAriaLabel $event $link)
151: 	#set ($ariaLabel = "${event.sport} event: ${formatter.formatDate($event.date, 'MMMM d hh:mm a:')}")
152: 	#if ($event.neutralSite.length() > 0 || $event.home)
153: 		#set ($vsOrAt = "vs.")
154: 	#else
155: 		#set ($vsOrAt = "at")
156: 	#end
157: 	#if ($event.teams.size() > 1)
158: 		#set ($ariaLabel = "${ariaLabel} ${event.teams.get(0).name} ${vsOrAt} ${event.teams.get(1).name}:")
159: 	#elseif ($event.teams.size() == 1)
160: 		#set ($ariaLabel = "${ariaLabel} ${event.teams.get(0).name}:")
161: 	#end
162: 	#if ($event.neutralSite.length() > 0)
163: 		#set ($ariaLabel = "${ariaLabel} @ ${event.neutralSite}:")
164: 	#end
165: 	#set ($ariaLabel = "${ariaLabel} ${link.name}")
166: 	aria-label="$ariaLabel"
167: #end
168: 
169: #macro (printEvent $event)
170:   
171: #set ($eventClass = "event")
172: #if ($event.inProgress)
173:   #set ($eventClass = "event in-progress")
174: #end
175: 
176: #if ($event.scheduleTeamId.length() > 0)
177:   #set ($teamSchedule = true)
178: #else
179:   #set ($teamSchedule = false)
180: #end
181:   
182: <div class="${eventClass}">
183: 
184:   <div class="date clearfix">$formatter.formatDate($event.date, $dateFormat)</div>
185:         
186:   #if ($event.sport)
187:     <div class="sport">
188: 		#printSport($event)
189:     </div>
190:   #end
191:   
192:   <div class="status clearfix">
193:   #if ($includeTimeZone)
194:     #if ($includeTimeZone.contains("local"))
195:       <span>$formatter.formatStatus($event).setTimeFormat("h:mm a z").useEventTimeZone()</span>  
196:     #elseif ($includeTimeZone.contains("site"))
197:       <span>$formatter.formatStatus($event).setTimeFormat("h:mm a z")</span>
198:     #end
199:   #else
200:     <span>$formatter.formatStatus($event)</span>
201:   #end
202:   </div>
203:   
204:   #if ($showJustOpponent && $teamSchedule) 
205:     <div class="opponent clearfix">
206:       #printTeamLogo($event.opponent)
207:       #printVa($event)
208:       <span class="name">$event.opponent.name</span>
209:     
210:       #set ($APResult = "")      
211:       #if ($resultFormat.equals("AP1"))
212:         #set ($APResult = $event.APResult)
213:       #elseif ($resultFormat.equals("AP2"))
214:         #set ($APResult = $event.AP2Result)
215:       #end
216: 
217:       #if (!$event.inProgress && $APResult.length() > 0)
218:         <span class="result">$APResult</span>
219:       #else
220:         #if ($event.result.toString().length() > 0)
221:             <span class="result">$event.result</span>
222:         #end
223:       #end
224:     </div>
225:   #else
226:     #foreach ($team in $event.teams)
227:   	  #set ($teamClass = "team")
228:   	  #if ($event.winner.name.length() > 0)
229:     	#if ($event.winner.name == $team.name)
230:       		#set ($teamClass = "${teamClass} winner")
231:     	#else
232:       		#set ($teamClass = "${teamClass} loser")
233:     	#end
234:   	  #end 
235:   	  #if ($event.teams.size() == 2 && $teamSchedule)
236:   	  	#if ($team.teamId == $event.scheduleTeamId)
237:   	  		#set ($teamClass = "${teamClass} site-team")  	  
238:   	  	#end
239:   	  #end
240:       <div class="$teamClass clearfix">
241:         #if ($team.result.length() > 0 && $event.teams.size() > 1) ## ideally this should check if the event is associated to a schedule with numeric results
242:           <span class="score">$team.result</span>
243:         #end
244:         
245:         #printTeamLogo($team)
246:         
247:         #if ($event.teams.size() == 1 && $showVsAt) 
248:           #printVa($event)
249:         #else
250:           #if ($velocityCount == 2)
251:             #printVa($event)
252:           #end
253:         #end
254:         
255:         <span class="name">$team.name</span>
256:         
257:         #if ($event.teams.size() == 1 && $event.result.toString().length() > 0)
258:           <span class="result">$event.result</span>
259:         #end
260:       </div>
261:     #end
262:   #end
263:         
264:   #if ($event.neutralSite.length() > 0 || $event.notes.length() > 0)
265:     <div class="neutralsite-notes">
266:       #if ($event.neutralSite.length() > 0)
267:         <span class="neutral-site">@ $event.neutralSite</span>
268:       #end
269:       #if ($event.notes.length() > 0)
270:         <span class="notes">$event.notes</span>
271:       #end
272:     </div>
273:   #end
274: 
275:   #set ($eventLinks = $event.links)
276:   #if ($restrictLinks)
277:     #set ($eventLinks = [])
278:     #foreach ($link in $event.links)
279:       #if (($event.statusCode >= 0 || $event.date.before($today)) && $excludeLinksWhenEventIsFinished.contains($link.mapType))
280:       #else
281:         #set ($ignoreme = $eventLinks.add($link))
282:       #end
283:     #end
284:   #end
285: 
286:   <div #if ($eventLinks.size() > 0) class="links" #else class="links empty" #end>
287:   #set ($linksCounter = 0)
288:   #foreach ($mapType in $linksOrder)
289:     #foreach ($link in $eventLinks)
290:       #if ($mapType == $link.mapType)
291:         #set ($linksCounter = $linksCounter + 1)
292:         #if ($linksCounter > 1)
293:           <span class="sep"> | </span>
294:         #end
295:         #set ($linkText = $link.name)
296:         #if ($abbreviatedLinks)
297:           #foreach ($l in $linksAbbreviations.entrySet())
298:             #if ($link.name.equalsIgnoreCase($l.key))
299:               #set ($linkText = $l.value)
300:             #end
301:           #end
302:         #end
303:         <a #printLinkAriaLabel($event, $link) href="$link.url" #if ($website.isExternalLink($link.url)) target="_blank" #end>
304:           #if ($showLinkIcons)
305:              <i class="icon gicon-${link.mapType.toLowerCase()}" title="$link.name"></i>
306:           #end
307:           <span class="text">$linkText</span>
308:         </a>
309:       #end
310:     #end
311:   #end
312:   </div>
313: </div>
314: #end ## printEvent
315: 
316: #macro (printEventBox $event)
317:   #set ($eventBoxClass = "event-box")
318:   #if ($event.date.before($today))
319:     #set ($eventBoxClass = "${eventBoxClass} result")
320:   #else
321:     #set ($eventBoxClass = "${eventBoxClass} upcoming")
322:   #end
323:   #if ($event.inProgress)
324:     #set ($eventBoxClass = "${eventBoxClass} inprogress")
325:   #end
326:   #if ($event.neutralSite.length() > 0)
327:     #set ($eventBoxClass = "${eventBoxClass} neutral")
328:   #elseif ($event.home) 
329:     #set ($eventBoxClass = "${eventBoxClass} home")
330:   #else
331:     #set ($eventBoxClass = "${eventBoxClass} away")
332:   #end  
333:   
334:   ## CODE TO EXTRACT SPORT SECTION FROM $event.feedURL 
335:   #set ($feedURL = $event.feedURL)
336:   #if ($feedURL.startsWith("http://"))
337:     #set ($feedURL = $feedURL.substring(7, $feedURL.length())) ## remove http://
338:   #elseif ($feedURL.startsWith("https://"))
339:     #set ($feedURL = $feedURL.substring(8, $feedURL.length())) ## remove https://
340:   #end
341:   #set ($startIndex = $feedURL.indexOf("/"))
342:   #set ($endIndex = $feedURL.length())
343:   #set ($feedURL = $feedURL.substring($startIndex, $endIndex))
344:   #set ($feedURL = $feedURL.split("/"))
345:   #if ($feedURL.size() >= 3)
346:     #set ($eventBoxClass = "${eventBoxClass} ${feedURL.get(2)}")
347:   #end
348:   
349:   <div class="${eventBoxClass}">
350:     #printEvent($event)
351:   </div>
352: #end ## printEventBox
353: 
354: #macro (printEmptyEventBox)
355: <div class="event-box empty">
356:   <div class="event">
357:     <span class="no-event">No Event</span>
358:   </div>
359: </div>
360: #end
361: 
362: ############################### END MACROS #############################################
363: 
364: #set ($events = [])
365: #set ($prevCount = 0)
366: #set ($upcomingCount = 0)
367: #set ($eventCount = 0)
368: 
369: ## filter out exhibition events and count the number of previous and upcoming events
370: #foreach ($event in $schedule.events)
371:   #if ($event.date && ($event.overall || !$hideExhibition))
372:     #if ($event.date.before($today))
373:       #if ($events.add($event))
374:         #set ($prevCount = $prevCount + 1)
375:       #end
376:     #else
377:       #if ($events.add($event)) ## upcoming events include events for today
378:         #set ($upcomingCount = $upcomingCount + 1)
379:       #end
380:     #end
381:   #end
382: #end
383: 
384: #set ($eventCount = $events.size())
385: #if ($eventCount > 0)
386:   #set ($events = $tool.sorter.sort($events, "date")) ## sort dates chronologically
387: #end
388: 
389: #set ($slideCount = $tool.math.ceil($tool.math.div($eventCount, $colLimit))) ## total number of slides based on the available number of events
390: #set ($emptyCount = $tool.math.sub($tool.math.mul($slideCount, $colLimit), $eventCount)) ## total number of items possible - total number of events available
391: #set ($emptyCountStart = 0)
392: #set ($emptyCountEnd = 0)
393: 
394: #if ($prevCount > 0 && $upcomingCount > 0) ## when both previous and upcoming events are available, the layout should preferably show a default slide that contains both previous and upcoming events
395:   #set ($desiredPrevEventsInFocusedSlide = $colLimit / 2)
396:   #set ($availablePrevEventsInFocusedSlide = $prevCount % $colLimit)
397:   
398:   #if ($availablePrevEventsInFocusedSlide < $desiredPrevEventsInFocusedSlide)
399:     #set ($emptyCountStart = $desiredPrevEventsInFocusedSlide - $availablePrevEventsInFocusedSlide)  
400:   #elseif ($availablePrevEventsInFocusedSlide > $desiredPrevEventsInFocusedSlide)
401:     #set ($emptyCountStart = ($colLimit - $availablePrevEventsInFocusedSlide) + $desiredPrevEventsInFocusedSlide)
402:   #end
403:   
404:   #if ($emptyCountStart > 0) ## re-count the number of slides
405:     #set ($slideCount = $tool.math.ceil($tool.math.div($tool.math.add($eventCount, $emptyCountStart), $colLimit)))
406:   #end
407:   
408:   #set ($emptyCountEnd = $tool.math.sub($tool.math.mul($slideCount, $colLimit), $tool.math.add($eventCount, $emptyCountStart)))
409:   #set ($focusedIndex = $tool.math.ceil($tool.math.div($tool.math.add($prevCount, $emptyCountStart), $colLimit)))
410:   
411: #elseif ($prevCount > 0) ## only previous events are available
412:   #set ($focusedIndex = $slideCount) ## focused slide is the last slide in the list that have most recent past events
413:   #set ($emptyCountStart = $emptyCount)
414: #elseif ($upcomingCount > 0) ## only upcoming events are available
415:   #set ($focusedIndex = 1)
416:   #set ($emptyCountEnd = $emptyCount)
417: #end
418: 
419: #if ($slideCount <= 1)
420:     #set ($autoScroll = false)
421:     #set ($circularScroll = false)
422: #end
423: 
424: <div class="${id}"  data-module="jslider" data-focus="$tool.math.sub($focusedIndex, 1)" data-auto="$autoScroll" data-interval="${autoInterval}" data-circular="$circularScroll" data-navi="${showNavi}" data-items=".slides">
425: 
426: #if ($eventCount == 0)
427:   <div class="no-events">No events to show.</div>
428: #else
429: 
430: #if ($fullSchedulePos == "top")
431:     <a href="$page.url" class="full-schedule-btn">View Full Schedule</a>
432: #end
433: 
434: <a href="javascript:void(0)" role="button" aria-label="move to previous slide" class="prev">Previous</a>
435: <a href="javascript:void(0)" role="button" aria-label="move to next slide" class="next">Next</a>
436: #if ($showPlayPause)
437: 	#set ($ppClass = "pp play")
438: 	#if ($autoScroll)
439: 		#set ($ppClass = "pp pause")
440: 	#end
441: 	<a href="javascript:void(0)" role="button" class="${ppClass}">pp</a>
442: #end
443: 
444: <div class="slider">
445: <div class="slides clearfix">
446:   
447: ## #set ($slideIndex = 1)
448: #set ($colIndex = 0)
449:   
450: <div class="slide">
451: <div class="slide-content clearfix">
452:   
453: #if ($emptyCountStart > 0)
454:   #foreach ($i in [1..$emptyCountStart])
455:     #set ($colIndex = $colIndex + 1)
456:     #printEmptyEventBox
457:   #end
458: #end
459:   
460: #foreach ($event in $events)
461:   #set ($colIndex = $colIndex + 1)
462:   #if ($colIndex > $colLimit)
463:     ## #set ($slideIndex = $slideIndex + 1)
464:     #set ($colIndex = 1)
465:     </div></div>
466:     <div class="slide">
467:     <div class="slide-content clearfix">
468:   #end
469:   #printEventBox($event)
470: #end
471: 
472: #if ($emptyCountEnd > 0)
473:   #foreach ($i in [1..$emptyCountEnd])
474:     #set ($colIndex = $colIndex + 1)
475:     #printEmptyEventBox
476:   #end
477: #end
478:     
479: </div> ## slide-content
480: </div> ## slide
481: 
482:     
483: </div> ## slides
484: </div> ## slider
485: 
486: #if ($showNavi)
487: 	<div class="navi"></div>
488: #end
489: #if ($fullSchedulePos == "bottom")
490:     <a href="$page.url" class="full-schedule-btn">View Full Schedule</a>
491: #end
492:   
493: #end ## total events check
494: </div> ## scoreboard-slider
495: 
496: $wiki
497: 
498: #if ($request.getParameter("ajax") == true)
499:   $website.decorate("")
500: #end

Results
Oct 25
There was a problem with a Velocity script
Pagescoreboard-slider-template
ErrorInvocation of method 'substring' in class java.lang.String threw exception java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at scoreboard-slider-template[line 135, column 29]
Page source:
1: #set ($id = "scoreboard-slider")
2: #if ($request.getParameter("id"))
3:   #set ($idParam = $request.getParameter("id"))
4:   #set ($id = "${id} ${idParam}")
5: #end
6: 
7: ## PICK UP OPTIONS
8: $website.include("options")
9: #set ($options = $request.getAttribute("options"))
10: 
11: #set ($hideExhibition = false)
12: #if ($options.get("schedule_hide_exhibition_events") == true)
13:   #set ($hideExhibition = true)
14: #end
15: 
16: #if ($request.getParameter("hideExhibition"))
17:   #set ($hideExhibition = $request.getParameter("hideExhibition"))
18: #end
19: 
20: #set ($linksOrder = ["RC", "BS", "RE", "GA", "AU", "VI", "LS", "DI", "TI", "PR"])
21: #set ($excludeLinksWhenEventIsFinished = ["LS", "DI", "TI", "PR"])
22: 
23: #set ($showVsAt = true)
24: #if ($options.get("schedule_hide_vs_at") == true)
25:   #set ($showVsAt = false) 
26: #end
27: 
28: #set ($includeTimeZone = false)
29: #if ($options.get("calendarIncludeTimeZone"))
30:   #set ($includeTimeZone = $options.get("calendarIncludeTimeZone").toLowerCase())
31: #end
32: 
33: #set ($showTeamLogo = false)
34: #if ($request.getParameter("showTeamLogo") == true)
35:   #set ($showTeamLogo = true)
36: #end
37: 
38: #set ($showJustOpponent = false)
39: #if ($request.getParameter("showJustOpponent") == true)
40:   #set ($showJustOpponent = true)
41: #end
42: 
43: #set ($resultFormat = "AP1")
44: #if ($options.get("schedule_result_format").equals("L, 1-2"))
45:   #set ($resultFormat = "AP2")
46: #end
47: 
48: #set ($dateFormat = "'<span>'EEE'</span> <span>'MMM'</span> <span>'dd'</span>'")
49: #if ($request.getParameter("dateFormat"))
50:   #set ($dateFormat = $request.getParameter("dateFormat"))
51: #end
52: 
53: #set ($restrictLinks = true)
54: #if ($options.get("schedule_restrict_links") == false)
55:   #set ($restrictLinks = false)
56: #end
57: 
58: #set ($linksAbbreviations = { "Preview": "PR", "Box Score": "BX", "Results": "R", "Recap": "RC", "Live stats": "LS", "Video": "V", "Audio": "A", "Photos": "PH", "Tickets": "T", "Directions": "DR" })
59: 
60: #set ($showLinkIcons = false)
61: #if ($request.getParameter("showLinkIcons") == true)
62:   #set ($showLinkIcons = true)
63: #end
64: 
65: #set ($abbreviatedLinks = false)
66: #if ($request.getParameter("abbreviatedLinks") == true)
67:   #set ($abbreviatedLinks = true)
68: #end
69: 
70: #set ($autoScroll = false)
71: #if ($request.getParameter("autoScroll") == true)
72:   #set ($autoScroll = true)
73: #end
74: 
75: #set ($showNavi = false)
76: #if ($request.getParameter("showNavi") == true)
77:   #set ($showNavi = true)
78: #end
79: 
80: #set ($autoInterval = 4000)
81: #if ($tool.math.toInteger($request.getParameter("autoInterval")) > 0)
82:   #set ($autoInterval = $tool.math.mul($request.getParameter("autoInterval", 1000)))
83: #end
84: 
85: #set ($circularScroll = false)
86: #if ($request.getParameter("circularScroll") == true)
87:   #set ($circularScroll = true)
88: #end
89: 
90: #set ($colLimit = 5)
91: #if ($tool.math.toInteger($request.getParameter("colLimit")))
92:   #set ($colLimit = $tool.math.toInteger($request.getParameter("colLimit")))
93: #end
94: 
95: #set ($showPlayPause = false)
96: #if ($request.getParameter("showPlayPause") == true)
97: 	#set ($showPlayPause = true)
98: #end
99: 
100: #set ($fullSchedulePos = "bottom")
101: #set ($fullSchedulePos = $request.getParameter("fullSchedulePos"))
102: 
103: #set ($today = $tool.date.format("MMMM dd yyyy", $now, $tool.date.getLocale(), $website.profile.timeZone))
104: #set ($today = $tool.date.toDate("MMMM dd yyyy", $today))
105: 
106: ################################ MACROS #####################################
107: #macro (printTeamLogo $team)
108:   #if ($showTeamLogo)
109:     #if ($team.teamId)
110:       <span class="team-logo"><img src="${website.teamLogo($team.teamId)}" alt="" /></span>
111:     #end
112:   #end
113: #end
114: 
115: #macro (printVa $event)
116:   #if ($event.neutralSite.length() > 0) 
117:     <span class="va">vs.</span>
118:   #else 
119:     #if (!$event.home)<span class="va">at</span>#end 
120:   #end
121: #end
122: 
123: #macro (printSport $event)
124:   #set ($feedURL = $event.feedURL)
125:   
126:   #set ($feedURL = $event.feedURL) ## in the form http://www.somedomain.com/sports/mbkb/2014-15/schedule?tmpl=sfs-template
127:   #if ($feedURL.indexOf("://") >= 0)
128:     #set ($feedURL = $feedURL.split("//").get(1)) ## remove the http:// bit from the URL
129:   #end
130:   #set ($startIndex = $feedURL.indexOf("/"))
131:   #set ($endIndex = $feedURL.length())
132:   #if ($feedURL.lastIndexOf("?") >= 0)
133:     #set ($endIndex = $feedURL.lastIndexOf("?"))
134:   #end
135:   #set ($feedURL = $feedURL.substring($startIndex, $endIndex)) ## remove the domain and tmpl parts
136: 
137:   #if ($website.exists($feedURL))
138: 	#set ($ariaLabel = "${event.sport}: schedule")
139:     #if ($feedURL.matches("/sports/.*/\d{4}-\d{2}/.*"))
140:       #set ($seasonStr = $feedURL.split("/").get(3))
141:       #set ($ariaLabel = "${event.sport}: ${seasonStr} schedule") ## aria-label would be something like Men's Basketball 2017-18 schedule
142:     #end
143: 	
144:     <a href="${feedURL}" aria-label="$ariaLabel">$event.sport</a>
145:   #else
146:     <span>$event.sport</span>
147:   #end
148: #end
149: 
150: #macro (printLinkAriaLabel $event $link)
151: 	#set ($ariaLabel = "${event.sport} event: ${formatter.formatDate($event.date, 'MMMM d hh:mm a:')}")
152: 	#if ($event.neutralSite.length() > 0 || $event.home)
153: 		#set ($vsOrAt = "vs.")
154: 	#else
155: 		#set ($vsOrAt = "at")
156: 	#end
157: 	#if ($event.teams.size() > 1)
158: 		#set ($ariaLabel = "${ariaLabel} ${event.teams.get(0).name} ${vsOrAt} ${event.teams.get(1).name}:")
159: 	#elseif ($event.teams.size() == 1)
160: 		#set ($ariaLabel = "${ariaLabel} ${event.teams.get(0).name}:")
161: 	#end
162: 	#if ($event.neutralSite.length() > 0)
163: 		#set ($ariaLabel = "${ariaLabel} @ ${event.neutralSite}:")
164: 	#end
165: 	#set ($ariaLabel = "${ariaLabel} ${link.name}")
166: 	aria-label="$ariaLabel"
167: #end
168: 
169: #macro (printEvent $event)
170:   
171: #set ($eventClass = "event")
172: #if ($event.inProgress)
173:   #set ($eventClass = "event in-progress")
174: #end
175: 
176: #if ($event.scheduleTeamId.length() > 0)
177:   #set ($teamSchedule = true)
178: #else
179:   #set ($teamSchedule = false)
180: #end
181:   
182: <div class="${eventClass}">
183: 
184:   <div class="date clearfix">$formatter.formatDate($event.date, $dateFormat)</div>
185:         
186:   #if ($event.sport)
187:     <div class="sport">
188: 		#printSport($event)
189:     </div>
190:   #end
191:   
192:   <div class="status clearfix">
193:   #if ($includeTimeZone)
194:     #if ($includeTimeZone.contains("local"))
195:       <span>$formatter.formatStatus($event).setTimeFormat("h:mm a z").useEventTimeZone()</span>  
196:     #elseif ($includeTimeZone.contains("site"))
197:       <span>$formatter.formatStatus($event).setTimeFormat("h:mm a z")</span>
198:     #end
199:   #else
200:     <span>$formatter.formatStatus($event)</span>
201:   #end
202:   </div>
203:   
204:   #if ($showJustOpponent && $teamSchedule) 
205:     <div class="opponent clearfix">
206:       #printTeamLogo($event.opponent)
207:       #printVa($event)
208:       <span class="name">$event.opponent.name</span>
209:     
210:       #set ($APResult = "")      
211:       #if ($resultFormat.equals("AP1"))
212:         #set ($APResult = $event.APResult)
213:       #elseif ($resultFormat.equals("AP2"))
214:         #set ($APResult = $event.AP2Result)
215:       #end
216: 
217:       #if (!$event.inProgress && $APResult.length() > 0)
218:         <span class="result">$APResult</span>
219:       #else
220:         #if ($event.result.toString().length() > 0)
221:             <span class="result">$event.result</span>
222:         #end
223:       #end
224:     </div>
225:   #else
226:     #foreach ($team in $event.teams)
227:   	  #set ($teamClass = "team")
228:   	  #if ($event.winner.name.length() > 0)
229:     	#if ($event.winner.name == $team.name)
230:       		#set ($teamClass = "${teamClass} winner")
231:     	#else
232:       		#set ($teamClass = "${teamClass} loser")
233:     	#end
234:   	  #end 
235:   	  #if ($event.teams.size() == 2 && $teamSchedule)
236:   	  	#if ($team.teamId == $event.scheduleTeamId)
237:   	  		#set ($teamClass = "${teamClass} site-team")  	  
238:   	  	#end
239:   	  #end
240:       <div class="$teamClass clearfix">
241:         #if ($team.result.length() > 0 && $event.teams.size() > 1) ## ideally this should check if the event is associated to a schedule with numeric results
242:           <span class="score">$team.result</span>
243:         #end
244:         
245:         #printTeamLogo($team)
246:         
247:         #if ($event.teams.size() == 1 && $showVsAt) 
248:           #printVa($event)
249:         #else
250:           #if ($velocityCount == 2)
251:             #printVa($event)
252:           #end
253:         #end
254:         
255:         <span class="name">$team.name</span>
256:         
257:         #if ($event.teams.size() == 1 && $event.result.toString().length() > 0)
258:           <span class="result">$event.result</span>
259:         #end
260:       </div>
261:     #end
262:   #end
263:         
264:   #if ($event.neutralSite.length() > 0 || $event.notes.length() > 0)
265:     <div class="neutralsite-notes">
266:       #if ($event.neutralSite.length() > 0)
267:         <span class="neutral-site">@ $event.neutralSite</span>
268:       #end
269:       #if ($event.notes.length() > 0)
270:         <span class="notes">$event.notes</span>
271:       #end
272:     </div>
273:   #end
274: 
275:   #set ($eventLinks = $event.links)
276:   #if ($restrictLinks)
277:     #set ($eventLinks = [])
278:     #foreach ($link in $event.links)
279:       #if (($event.statusCode >= 0 || $event.date.before($today)) && $excludeLinksWhenEventIsFinished.contains($link.mapType))
280:       #else
281:         #set ($ignoreme = $eventLinks.add($link))
282:       #end
283:     #end
284:   #end
285: 
286:   <div #if ($eventLinks.size() > 0) class="links" #else class="links empty" #end>
287:   #set ($linksCounter = 0)
288:   #foreach ($mapType in $linksOrder)
289:     #foreach ($link in $eventLinks)
290:       #if ($mapType == $link.mapType)
291:         #set ($linksCounter = $linksCounter + 1)
292:         #if ($linksCounter > 1)
293:           <span class="sep"> | </span>
294:         #end
295:         #set ($linkText = $link.name)
296:         #if ($abbreviatedLinks)
297:           #foreach ($l in $linksAbbreviations.entrySet())
298:             #if ($link.name.equalsIgnoreCase($l.key))
299:               #set ($linkText = $l.value)
300:             #end
301:           #end
302:         #end
303:         <a #printLinkAriaLabel($event, $link) href="$link.url" #if ($website.isExternalLink($link.url)) target="_blank" #end>
304:           #if ($showLinkIcons)
305:              <i class="icon gicon-${link.mapType.toLowerCase()}" title="$link.name"></i>
306:           #end
307:           <span class="text">$linkText</span>
308:         </a>
309:       #end
310:     #end
311:   #end
312:   </div>
313: </div>
314: #end ## printEvent
315: 
316: #macro (printEventBox $event)
317:   #set ($eventBoxClass = "event-box")
318:   #if ($event.date.before($today))
319:     #set ($eventBoxClass = "${eventBoxClass} result")
320:   #else
321:     #set ($eventBoxClass = "${eventBoxClass} upcoming")
322:   #end
323:   #if ($event.inProgress)
324:     #set ($eventBoxClass = "${eventBoxClass} inprogress")
325:   #end
326:   #if ($event.neutralSite.length() > 0)
327:     #set ($eventBoxClass = "${eventBoxClass} neutral")
328:   #elseif ($event.home) 
329:     #set ($eventBoxClass = "${eventBoxClass} home")
330:   #else
331:     #set ($eventBoxClass = "${eventBoxClass} away")
332:   #end  
333:   
334:   ## CODE TO EXTRACT SPORT SECTION FROM $event.feedURL 
335:   #set ($feedURL = $event.feedURL)
336:   #if ($feedURL.startsWith("http://"))
337:     #set ($feedURL = $feedURL.substring(7, $feedURL.length())) ## remove http://
338:   #elseif ($feedURL.startsWith("https://"))
339:     #set ($feedURL = $feedURL.substring(8, $feedURL.length())) ## remove https://
340:   #end
341:   #set ($startIndex = $feedURL.indexOf("/"))
342:   #set ($endIndex = $feedURL.length())
343:   #set ($feedURL = $feedURL.substring($startIndex, $endIndex))
344:   #set ($feedURL = $feedURL.split("/"))
345:   #if ($feedURL.size() >= 3)
346:     #set ($eventBoxClass = "${eventBoxClass} ${feedURL.get(2)}")
347:   #end
348:   
349:   <div class="${eventBoxClass}">
350:     #printEvent($event)
351:   </div>
352: #end ## printEventBox
353: 
354: #macro (printEmptyEventBox)
355: <div class="event-box empty">
356:   <div class="event">
357:     <span class="no-event">No Event</span>
358:   </div>
359: </div>
360: #end
361: 
362: ############################### END MACROS #############################################
363: 
364: #set ($events = [])
365: #set ($prevCount = 0)
366: #set ($upcomingCount = 0)
367: #set ($eventCount = 0)
368: 
369: ## filter out exhibition events and count the number of previous and upcoming events
370: #foreach ($event in $schedule.events)
371:   #if ($event.date && ($event.overall || !$hideExhibition))
372:     #if ($event.date.before($today))
373:       #if ($events.add($event))
374:         #set ($prevCount = $prevCount + 1)
375:       #end
376:     #else
377:       #if ($events.add($event)) ## upcoming events include events for today
378:         #set ($upcomingCount = $upcomingCount + 1)
379:       #end
380:     #end
381:   #end
382: #end
383: 
384: #set ($eventCount = $events.size())
385: #if ($eventCount > 0)
386:   #set ($events = $tool.sorter.sort($events, "date")) ## sort dates chronologically
387: #end
388: 
389: #set ($slideCount = $tool.math.ceil($tool.math.div($eventCount, $colLimit))) ## total number of slides based on the available number of events
390: #set ($emptyCount = $tool.math.sub($tool.math.mul($slideCount, $colLimit), $eventCount)) ## total number of items possible - total number of events available
391: #set ($emptyCountStart = 0)
392: #set ($emptyCountEnd = 0)
393: 
394: #if ($prevCount > 0 && $upcomingCount > 0) ## when both previous and upcoming events are available, the layout should preferably show a default slide that contains both previous and upcoming events
395:   #set ($desiredPrevEventsInFocusedSlide = $colLimit / 2)
396:   #set ($availablePrevEventsInFocusedSlide = $prevCount % $colLimit)
397:   
398:   #if ($availablePrevEventsInFocusedSlide < $desiredPrevEventsInFocusedSlide)
399:     #set ($emptyCountStart = $desiredPrevEventsInFocusedSlide - $availablePrevEventsInFocusedSlide)  
400:   #elseif ($availablePrevEventsInFocusedSlide > $desiredPrevEventsInFocusedSlide)
401:     #set ($emptyCountStart = ($colLimit - $availablePrevEventsInFocusedSlide) + $desiredPrevEventsInFocusedSlide)
402:   #end
403:   
404:   #if ($emptyCountStart > 0) ## re-count the number of slides
405:     #set ($slideCount = $tool.math.ceil($tool.math.div($tool.math.add($eventCount, $emptyCountStart), $colLimit)))
406:   #end
407:   
408:   #set ($emptyCountEnd = $tool.math.sub($tool.math.mul($slideCount, $colLimit), $tool.math.add($eventCount, $emptyCountStart)))
409:   #set ($focusedIndex = $tool.math.ceil($tool.math.div($tool.math.add($prevCount, $emptyCountStart), $colLimit)))
410:   
411: #elseif ($prevCount > 0) ## only previous events are available
412:   #set ($focusedIndex = $slideCount) ## focused slide is the last slide in the list that have most recent past events
413:   #set ($emptyCountStart = $emptyCount)
414: #elseif ($upcomingCount > 0) ## only upcoming events are available
415:   #set ($focusedIndex = 1)
416:   #set ($emptyCountEnd = $emptyCount)
417: #end
418: 
419: #if ($slideCount <= 1)
420:     #set ($autoScroll = false)
421:     #set ($circularScroll = false)
422: #end
423: 
424: <div class="${id}"  data-module="jslider" data-focus="$tool.math.sub($focusedIndex, 1)" data-auto="$autoScroll" data-interval="${autoInterval}" data-circular="$circularScroll" data-navi="${showNavi}" data-items=".slides">
425: 
426: #if ($eventCount == 0)
427:   <div class="no-events">No events to show.</div>
428: #else
429: 
430: #if ($fullSchedulePos == "top")
431:     <a href="$page.url" class="full-schedule-btn">View Full Schedule</a>
432: #end
433: 
434: <a href="javascript:void(0)" role="button" aria-label="move to previous slide" class="prev">Previous</a>
435: <a href="javascript:void(0)" role="button" aria-label="move to next slide" class="next">Next</a>
436: #if ($showPlayPause)
437: 	#set ($ppClass = "pp play")
438: 	#if ($autoScroll)
439: 		#set ($ppClass = "pp pause")
440: 	#end
441: 	<a href="javascript:void(0)" role="button" class="${ppClass}">pp</a>
442: #end
443: 
444: <div class="slider">
445: <div class="slides clearfix">
446:   
447: ## #set ($slideIndex = 1)
448: #set ($colIndex = 0)
449:   
450: <div class="slide">
451: <div class="slide-content clearfix">
452:   
453: #if ($emptyCountStart > 0)
454:   #foreach ($i in [1..$emptyCountStart])
455:     #set ($colIndex = $colIndex + 1)
456:     #printEmptyEventBox
457:   #end
458: #end
459:   
460: #foreach ($event in $events)
461:   #set ($colIndex = $colIndex + 1)
462:   #if ($colIndex > $colLimit)
463:     ## #set ($slideIndex = $slideIndex + 1)
464:     #set ($colIndex = 1)
465:     </div></div>
466:     <div class="slide">
467:     <div class="slide-content clearfix">
468:   #end
469:   #printEventBox($event)
470: #end
471: 
472: #if ($emptyCountEnd > 0)
473:   #foreach ($i in [1..$emptyCountEnd])
474:     #set ($colIndex = $colIndex + 1)
475:     #printEmptyEventBox
476:   #end
477: #end
478:     
479: </div> ## slide-content
480: </div> ## slide
481: 
482:     
483: </div> ## slides
484: </div> ## slider
485: 
486: #if ($showNavi)
487: 	<div class="navi"></div>
488: #end
489: #if ($fullSchedulePos == "bottom")
490:     <a href="$page.url" class="full-schedule-btn">View Full Schedule</a>
491: #end
492:   
493: #end ## total events check
494: </div> ## scoreboard-slider
495: 
496: $wiki
497: 
498: #if ($request.getParameter("ajax") == true)
499:   $website.decorate("")
500: #end