Salesforce 1上的FullCalendar间歇性加载错误

时间:2018-11-09 09:28:22

标签: fullcalendar

我使用的是“完整日历”,并且有一个启用了Classic和Salesforce 1的visualforce页面,它在Classic上可以正常使用,但是有时我们的工程师报告他们在尝试加载页面或单击时出错。页面中的记录链接之一。

错误是: 净额:err_blocked_by-_Resource 和 解析JSON响应“意外令牌<”已登录时出错?未定义

由于这是一个间歇性问题,我似乎根本无法调试它。我想知道是否有人可以提供有关错误的任何见解? 我的代码在下面。

<apex:page controller="UserCalendarController" readOnly="true" >
<link href="{!$Resource.fullBasicCalendarMinCSS}" rel="stylesheet" />
<link href="{!$Resource.fullBasicCalendarPrintMinCSS}" rel="stylesheet" media="print" />

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="{!$Resource.MomentMin}"></script>
<script src="{!$Resource.fullBasicCalendarMinJS}"></script>
<script>
var WOTag = '{!WOTag}';
var PHTag = '{!PHTag}';
var PSTag = '{!PSTag}';
var TOINFINITY = moment().add(10, "days");
var TODAY = moment().add(1, "days");
var NOW = moment();
window.$userId = "{!$User.Id}";

function htmlEncode(value)
{
    return $('<div/>').html(value).text();
}

function newLineToBR(value)
{
    return value.replace(/(\n)+/g, '<br />'); 
}

$(document).ready(function() 
                  {
                      //Call the fullCallendar method. 
                      $('#calendar').fullCalendar(
                          {
                              schedulerLicenseKey: '0760513013-fcs-1521451920',
                              editable: false,
                              aspectRatio: 0.75,
                              eventOrder: 'displayOrder',
                              eventRender: function (event, element, view) 
                              {
                                  var title = element.find('.fc-title, .fc-list-item-title');   
                                  var titleNode = title[0].childNodes[0];
                                  var encoded = htmlEncode(titleNode.innerHTML);
                                  titleNode.innerHTML = encoded;
                                 //title.html(title.text());
                              },
                              eventMouseover: function(calEvent, jsEvent) 
                              {
                                  var tooltip = '';
                                  if (calEvent.tag == WOTag)
                                  {
                                      tooltip = '<div class=" tooltipevent WO-tooltipevent">'
                                      + calEvent.toolTipTitle +'<h3><br/>' + calEvent.toolTipContent + '<br/>'
                                      + '</div>';
                                  }
                                  else if (calEvent.tag == PHTag)
                                  {
                                      tooltip = '<div class="tooltipevent PH-tooltipevent">'
                                      + '<h3>' + calEvent.toolTipTitle +'<h3><br/>' + calEvent.toolTipContent + '<br/>'
                                      + '</div>';
                                  }
                                      else if (calEvent.tag == PSTag)
                                      {
                                          tooltip = '<div class="tooltipevent PS-tooltipevent">'
                                          + calEvent.toolTipTitle +'<h3><br/>' + calEvent.toolTipContent + '<br/>'
                                          + '</div>';
                                      }

                                  $("body").append(tooltip);
                                  $(this).mousemove(function(e) 
                                                    {
                                                        $('.tooltipevent').css('top', e.pageY + 1);
                                                        $('.tooltipevent').css('left', e.pageX + 2);
                                                    });
                              },                                 
                              eventMouseout: function(calEvent, jsEvent) 
                              {
                                  $(this).css('z-index', 8);
                                  $('.tooltipevent').remove();
                              }, 
                              eventClick: function(calEvent)
                              {
                                 /* alert('Event url: ' + calEvent.url);
                                  if (calEvent.url)
                                  {
                                      window.open(calEvent.url, '_parent');
                                      return false;
                                  }*/
                              },
                              header: 
                              {
                                  left: 'prev,next today',
                                  center: 'title',
                                  right: 'listToday, listNext10Days, month'
                              },
                              defaultView: 'listToday',
                              views: 
                              {             
                                  month: 
                                  {
                                      weekends: false,
                                      fixedWeekCount: false,
                                      buttonText: 'Month'
                                  },
                                  listNext10Days:
                                  {
                                      type: 'list',
                                      duration: {days:TOINFINITY.diff(NOW, 'days')},
                                      buttonText: 'Next 10 days',
                                      weekends: false,
                                      displayEventTime: false
                                  },
                                  listToday:
                                  {
                                      type: 'list',
                                      duration: {days:TODAY.diff(NOW, 'days')},
                                      buttonText: 'Today',
                                      weekends: false,
                                      displayEventTime: false
                                  }
                              },
                              events: function(start, end, timezone, callback)
                              {
                                  console.log('Getting events for ' + start.toDate() + ' - ' + end.toDate());
                                  $('.loader').toggle();
                                  Visualforce.remoting.Manager.invokeAction(
                                      '{!$RemoteAction.UserCalendarController.CalendarEvents}',
                                      start.toDate().toUTCString(),
                                      end.toDate().toUTCString(),
                                      function(result, event)
                                      {
                                          if (event.status)
                                          {
                                              for (var i = 0; i < result.length; i++)
                                              {
                                                  var r= result[i];
                                                  r.start = new Date(r.starts);
                                                  r.end = new Date(r.ends);
                                                  //r.toolTipContent = r.toolTipContent.replace(/(\n)+/g, '<br />');
                                                  //r.title = r.title.replace(/(\n)+/g, '<br />'); 
                                                  r.title = newLineToBR(htmlEncode(r.title));
                                                  r.toolTipContent = newLineToBR(htmlEncode(r.toolTipContent));
                                              }
                                              console.log(result);
                                              callback(result);
                                          }
                                          else
                                          {
                                              alert('ERROR:\n' + event.message + '\n' + event.where);
                                          }
                                          $('.loader').toggle();
                                      });                                     
                              }                                 
                          });                        
                  });
</script>

<style>
    .loader{display:none; position:fixed; top:50%; left:50%; border: 16px solid #f3f3f3; border-top: 16px solid #3498db; border-radius: 50%; width: 120px; height: 120px; animation: spin 2s linear infinite;}
    @keyframes spin {0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
    }

     <!--Scheduled event classes-->
    .workOrder-scheduled{background:red ;border-color:red; color: white !important;}
    <!--.workOrder-scheduled td{background:red ;border-color:red; color: white !important;}-->
    .psWork-scheduled-liveDay{background:green ;border-color:green;}
    .psWork-scheduled-liveDay .fc-list-item-title{color: white !important;}
    .psWork-scheduled-installDay{background:yellow ;border-color:yellow;}
    .psWork-scheduled-regDay{background:violet ;border-color:violet;}
    .psWork-scheduled-remoteInstall{background:teal ;border-color:teal;}
    .psWork-scheduled-remoteInstall .fc-list-item-title{color: white !important;}
    .psWork-scheduled-iDStoreFlip{background:sienna ;border-color:sienna;}
    .psWork-scheduled-training{background:SpringGreen ;border-color:SpringGreen;}
    .placeholder-scheduled-holidayHalf{background:skyBlue; border-color:SkyBlue; color: black !important;}
    .placeholder-scheduled-holidayFull{background:blue; border-color:blue;}
    .placeholder-scheduled-holidayFull .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-bankHoliday{background:DarkBlue; border-color:DarkBlue; }
    .placeholder-scheduled-bankHoliday .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-sickness{background:green; border-color:green; color: white !important;}
    .placeholder-scheduled-sickness .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-fs{background:red; border-color:red;}
    .placeholder-scheduled-fs .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-ps{background:orchid; border-color:orchid; color: black !important;}
    .placeholder-scheduled-support{background:darkViolet; border-color:darkViolet;}
    .placeholder-scheduled-support .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-training{background:orangeRed; border-color:orangeRed; color: black !important;}
    .placeholder-scheduled-unavailableAM{background:khaki; border-color:khaki; color: black !important;}
    .placeholder-scheduled-unavailablePM{background:khaki; border-color:khaki; color: black !important;}
    .placeholder-scheduled-office{background:DarkSeaGreen; border-color:DarkSeaGreen; color: black !important;}
    .placeholder-scheduled-garage{background:DarkSlateGray; border-color:DarkSlateGray;}
    .placeholder-scheduled-garage .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-shadowFS{background:DarkRed; border-color:DarkRed;}
    .placeholder-scheduled-shadowFS .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-shadowPS{background:PaleVioletRed; border-color:PaleVioletRed;}
    .placeholder-scheduled-shadowPS .fc-list-item-title{color: white !important;}
    .placeholder-scheduled-reminder{background:Gray border-color:Gray; color: white !important;}

    <!--Tooltip classes-->
    .tooltipevent {border-radius: 25px; padding: 20px; background:#98AFC7; position:absolute;z-index:10001;}
    .WO-tooltipevent {min-width:150px; min-height:100px; width:auto;  height:auto;}
    .PH-tooltipevent {min-width:150px; min-height:20px; max-width:150px;  height:auto; }
    .PS-tooltipevent {min-width:150px; min-height:50px; width:auto;  height:auto; }
</style>
<div id='calendar-container'>
    <div id='calendar'></div>
</div> 
<div class="loader"></div>

非常感谢您的协助

0 个答案:

没有答案