Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/119.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Cordova/Phonegap日历插件iOS创建事件_Javascript_Ios_Cordova - Fatal编程技术网

Javascript Cordova/Phonegap日历插件iOS创建事件

Javascript Cordova/Phonegap日历插件iOS创建事件,javascript,ios,cordova,Javascript,Ios,Cordova,我使用的是Cordova/Phonegap插件,可以在这里找到: 我的应用程序是一个每天都有不同事件的RSS提要,我想更改javascript代码,以便用户能够添加到日历中,并且函数至少读取标题日期 在my main.js中,函数是: function Calendar_Add(){ // prep some variables var startDate = new Date("March 18, 2014 13:00:00"); var endDate = new Da

我使用的是Cordova/Phonegap插件,可以在这里找到:

我的应用程序是一个每天都有不同事件的RSS提要,我想更改javascript代码,以便用户能够添加到日历中,并且函数至少读取标题日期

在my main.js中,函数是:

 function Calendar_Add(){
  // prep some variables

   var startDate = new Date("March 18, 2014 13:00:00");
   var endDate = new Date("March 18, 2014 14:30:00");
   var title = "Event Added!";
   var location = "Home";
   var notes = "Some notes about this event.";

   var success = function(message) { alert("Success: " + JSON.stringify(message)); };
   var error = function(message) { alert("Error: " + message); };

   // create
  window.plugins.calendar.createEventWithCalendar(title,location,notes,startDate,endDate,success,error);    
 }
这是在创建一个事件,但我在创建变量时又遇到了麻烦。这是我尝试的全部javascript页面:

//jQuery get target page
function IE_navigate(index) {

Bindex = index;

$.mobile.changePage('#eventPage', 'slidefade');

$.each(data, function(i,item){
    if (i == Bindex) {
          //Clear if page was previously populated


          //Populate page
          $('#page-title').html(item.title + "<br />");
          $('#page-region').html(item.Region + "<br />");
          $('#page-content').html(item.fullInfo + "<br />");

            /*                  
             startDate = new Date(item.Date);
             endDate = new Date(item.Date);
             title = item.title;
             place = item.Region;

             */
          $(this).ready(function(e) {
              $('#page-content').on('click','a', function(e){
                e.preventDefault();
                currentPage = $(this).attr('href');
               window.open(currentPage, '_system', 'location=yes')
           });
          });
         // return false;

          return false
    }
});
};

 var Aindex = "";
var Bindex = "";
var data = [];

$(function () { Load_Content() });

function Load_Content() {

    $('#feed').empty(); 
    data = [];
$.ajax({
        type: 'GET',
        url:'http://www.e-grid.net/BayAreaTech/wp-rss2.php?cat=1',
        dataType: 'xml',
        success: function (xml) {
            $('#header-title').html("e-Grid Mobile");
                $(xml).find("item:lt(60)").each(function () {

                var dateText = $(this).find("Date").text().toString();
                var eventDate = moment(dateText,"YYYY-MM-DD");
                var title = $(this).find("title").text();
                var region = dateText.substr(8).toUpperCase();
                  if (region == "SCV") { region = "Santa Clara  Valley";}
                  if (region == "OEB") { region = "Oakland/East Bay";}
                  if (region == "SF") { region = "San Francisco";}
                  if (region == "ALL") { region = "All regions";} 
                var description = $(this).find("description").text();
                var infoDisplay = description.substr(0,     description.indexOf(",")+120) + "..."; //Parsed DATE from description
                var fullDescription = $(this).find('encoded').text();    
                var category = $(this).find("category").text();
                var linkUrl = $(this).find("link").text();
                var displayTitle = title; 

                var item = {title: displayTitle, 
                            link: linkUrl, 
                            infoDescription: infoDisplay, 
                            Date: new Date(eventDate), 
                            Region: region, 
                            fullInfo: fullDescription,}

                var now = moment().subtract('days', 1);
                if (item.Date >= now){ data.push(item); }

                });

                 data.sort(function (a, b) {
                    a = new Date(a.Date);
                    b = new Date(b.Date);
                    return a<b ? -1 : a>b ? 1 : 0;
                 });

                 if (data.length > 0) {
                    $.each(data, function (index, item) {

                          Aindex = data.indexOf(this)

                          var h_feedList =  '<li';
                          h_feedList += '><a href="#" onclick="IE_navigate(' + Aindex + ')" target="_blank">';
                          h_feedList += '<h3>';                             // Start  Title Text
                          h_feedList += item.title;                     // Title Text
                          h_feedList += '</h3><p>';                         // End the title text - start the description text
                          h_feedList += item.infoDescription;           // Description text
                          h_feedList += '</p>';                         // End description text
                          h_feedList += '</a>';                         // End list link
                          h_feedList += '</li>';                            // End List Item

                         $('#feed').append(h_feedList);

                     });
                 }
                 else
                 {
                     var message = "No upcoming events within your selection; check back soon!";
                     $('#feed').append('<h3>' + message + '</h3>');
                 }
        }
    });
};


function next_event() {
Bindex++;
if (Bindex > data.length){ Bindex = 0; }

$('#page-title').html(data[Bindex].title);
$('#page-region').html(data[Bindex].Region);
$('#page-content').html(data[Bindex].fullInfo); 


 startDate = new Date(data[Bindex].Date);
 endDate = new Date(data[Bindex].Date);
 title = data[Bindex].title;
 place = data[Bindex].Region;
}
function previous_event() {
Bindex--;
if (Bindex <= 0){ Bindex = data.length; }

$('#page-title').html(data[Bindex].title);
$('#page-region').html(data[Bindex].Region);
$('#page-content').html(data[Bindex].fullInfo);

startDate = new Date(data[Bindex].Date);
endDate = new Date(data[Bindex].Date);
title = data[Bindex].title;
place = data[Bindex].Region;

}


$(document).ajaxStart(function() {
  $.mobile.loading('show', {text: 'Loading BayArea Events...', textVisible: true, textonly: true});
});

$(document).ajaxStop(function() {
  $.mobile.loading('hide');
});






$( document ).on( "pagecreate", "#home", function() {
  $( document ).on( "swipeleft swiperight", "#home", function( e ) {
    // We check if there is no open panel on the page because otherwise
    // a swipe to close the left panel would also open the right panel (and v.v.).
    // We do this by checking the data that the framework stores on the page element (panel: open).
    if ( $( ".ui-page-active" ).jqmData( "panel" ) !== "open" ) {
        if ( e.type === "swipeleft" ) {
            $( "#settingspanel" ).panel( "open" );
        } else if ( e.type === "swiperight" ) {
            $( "#fieldpanel" ).panel( "open" );
        }
    }
 });
});
$( document ).on( "pagecreate", "#eventPage", function() {
 $( document ).on( "swipeleft swiperight", "#eventPage", function( e ) { 
         if ( e.type === "swipeleft" ) {
            next_event();
        } else if ( e.type === "swiperight" ) {
            previous_event();
        }
});
});

function Calendar_Add(){
 // prep some variables

 var startDate = new Date(item.Date);
 var endDate = new Date(item.Date);
 var title = item.title;
 var location = item.region;
 var notes = "";

 var success = function(message) { alert("Success: " + JSON.stringify(message)); };
 var error = function(message) { alert("Error: " + message); };

 // create
  window.plugins.calendar.createEventWithCalendar(title,location,notes,startDate,endDate,success,error);    
}
//jQuery获取目标页面
功能IE_导航(索引){
Bindex=指数;
$.mobile.changePage('eventPage','slidefade');
$。每个(数据、功能(i、项){
如果(i==Bindex){
//清除以前是否填充了页面
//填充页面
$('#页面标题').html(item.title+“
”); $(“#页面区域”).html(item.region+”
); $(“#页面内容”).html(item.fullInfo+”
); /* 开始日期=新日期(项目日期); endDate=新日期(项目日期); title=item.title; 地点=项目区域; */ $(此).ready(函数(e){ $(“#页面内容”)。在('click','a',函数(e)上{ e、 预防默认值(); currentPage=$(this.attr('href'); 打开(当前页面,“\u系统”,“位置=是”) }); }); //返回false; 返回错误 } }); }; var Aindex=“”; var Bindex=“”; var数据=[]; $(函数(){Load_Content()}); 函数加载_内容(){ $('#feed').empty(); 数据=[]; $.ajax({ 键入:“GET”, 网址:'http://www.e-grid.net/BayAreaTech/wp-rss2.php?cat=1', 数据类型:“xml”, 成功:函数(xml){ $(“#标题”).html(“电子网格移动”); $(xml).find(“项:lt(60)”).each(函数(){ var dateText=$(this.find(“Date”).text().toString(); var eventDate=时刻(日期文本,“YYYY-MM-DD”); var title=$(this.find(“title”).text(); var region=dateText.substr(8.toUpperCase(); 如果(region==“SCV”){region=“Santa Clara Valley”;} 如果(地区==“OEB”){region=“奥克兰/东湾”;} 如果(region==“SF”){region=“San Francisco”;} 如果(region==“ALL”){region=“ALL regions”;} var description=$(this.find(“description”).text(); var infoDisplay=description.substr(0,description.indexOf(“,”+120)+“…”;//从描述中解析的日期 var fullDescription=$(this.find('encoded').text(); var category=$(this.find(“category”).text(); var linkUrl=$(this.find(“link”).text(); var displayTitle=标题; var item={title:displayTitle, 链接:linkUrl, infoDescription:infoDisplay, 日期:新日期(eventDate), 地区:地区,, fullInfo:fullDescription,} var now=力矩()。减去('days',1); 如果(item.Date>=now){data.push(item);} }); 数据排序(函数(a,b){ a=新日期(a.日期); b=新日期(b.日期); 返回ab?1:0; }); 如果(data.length>0){ $。每个(数据、功能(索引、项目){ Aindex=data.indexOf(this) var h_feedList='';//结束列表链接 h_feedList+='';//结束列表项 $(“#提要”).append(h#u提要列表); }); } 其他的 { var message=“您选择的范围内没有即将发生的事件;请稍后再试!”; $('#提要')。追加(''+message+''); } } }); }; 函数next_event(){ Bindex++; 如果(Bindex>data.length){Bindex=0;} $('#页面标题').html(数据[Bindex].title); $('#page region').html(数据[Bindex].region); $('#页面内容').html(数据[Bindex].fullInfo); startDate=新日期(数据[Bindex].Date); endDate=新日期(数据[Bindex].Date); title=数据[Bindex]。title; 地点=数据[Bindex]。区域; } 函数上一个事件(){ 宾得--;
如果(Bindex日历插件不存在createEventWithCalendar函数。您应该使用具有相同参数的createEvent

如果在某个地方有这样一个函数,您可能会收到Javascript错误的警告: window.onerror=函数(a、b、c){ 警报(a); 警报(b); 警报(c); }

希望这能帮助你让我的插件工作, 涡流