2016-05-31 15 views
0

Ich habe eine jquery mobile phonegap mobile Anwendung der Technologien aus einem RSS-Feed zu zeigen. Auf einem Web-Navigator funktioniert es richtig, aber wenn ich die APK-Datei den Titel und der Inhalt nicht angezeigt wird auf der Liste erstellenjQuery Mobile dynamische listview

My app on web navigator

My app .apk installed on mobile

den Code der App:

<html> 
    <head> 
     <meta charset="utf-8"> 
     <title>Technologia</title> 
     <link rel="stylesheet" type="text/css" href="css/jquery.mobile-1.4.5.css"> 
     <link rel="stylesheet" type="text/css" href="css/theme.css"> 
     <link rel="stylesheet" type="text/css" href="css/custom.css"> 
    </head> 
    <body> 
     <script type="text/javascript" src="js/jquery.js"></script> 
     <script type="text/javascript" src="js/jquery.mobile-1.4.0-rc.1.js"></script> 
     <script type="text/javascript" src="cordova.js"></script> 
     <script> 
      // ISCPA added search filter, home icon, updated CDN-Hosted links 
// forked from sumukh1's "forked: RSS Reader with jQuery Mobile" http://jsdo.it/sumukh1/4Ton 
      /* configuration */ 
      var maxLength = 20; 
      /* writing HTML */ 
      document.write(
        '<div data-role="page" id="list">' + 
        '<div data-role="panel" data-theme="b" id="menu" data-position="left" data-display="overlay" >' + 
        '<ul data-role="listview" data-theme="c">' + 
        '<li data-icon="false"><a href="actu.html" rel="external"> <img src="img/actu.png" class="ui-li-icon ui-corner-none"> Acualités</a></li>' + 
        '<li data-icon="false"><a href="logiciel.html" rel="external"> <img src="img/logiciel.png" class="ui-li-icon ui-corner-none"> Applis,Logiciels</a></li>' + 
        '<li data-icon="false"><a href="jeux.html" rel="external"> <img src="img/jeux.png" class="ui-li-icon ui-corner-none"> Jeux</a></li>' + 
        '<li data-icon="false"><a href="pc.html" rel="external"> <img src="img/pc.png" class="ui-li-icon ui-corner-none"> PC Périphériques</a></li>' + 
        '<li data-icon="false"><a href="smartphone.html" rel="external"> <img src="img/mobile.png" class="ui-li-icon ui-corner-none"> Smartphone</a></li>' + 
        '<li data-icon="false"><a href="tablette.html" rel="external"> <img src="img/tablet.png" class="ui-li-icon ui-corner-none"> Tablette</a></li>' + 
        '<li data-icon="false"><a href="objets.html" rel="external"> <img src="img/objets.png" class="ui-li-icon ui-corner-none"> Objets connectés</a></li>' + 
        '<li data-icon="false"><a href="media.html" rel="external"> <img src="img/media.png" class="ui-li-icon ui-corner-none"> Culture, médias</a></li>' + 
        '<li data-icon="false"><a href="politique.html" rel="external"> <img src="img/politique.png" class="ui-li-icon ui-corner-none"> Politique, Droits</a></li>' + 
        '<li data-icon="false"><a href="propos.html" rel="external"> <img src="img/propos.png" class="ui-li-icon ui-corner-none"> À propos</a></li>' + 
        '</ul>' + 
        '</div>' + 
        ' <div data-role="header" data-position="fixed">' + 
        ' <a data-iconpos="notext" href="#menu" data-display="overlay" data-role="button" data-icon="bars"></a>' + 
        ' <h1>Actualités</h1>' + 
        ' </div>' + 
        ' <div data-role="content">' + 
        ' <ul data-role="listview" data-theme="b" data-filter="true" data-filter-placeholder="Chercher" data-inset="true" id="articleList">' 
        ); 
      for (var i = 1; i <= maxLength; i++) { 
       document.write(
         '<li data-icon="false" id="list' + i + '"><a href="#article' + i + '" id="link' + i + '">&nbsp;</a></li>' 
         ); 
      } 
      document.write(
        ' </ul>' + 
        ' </div>' + 
        '</div>' 
        ); 
      for (i = 1; i <= maxLength; i++) { 
       document.write(
         '<div data-role="page" id="article' + i + '">' + 
         ' <div data-role="header" data-position="inline">' + 
         ' <a href="#list" data-role="button" data-icon="carat-l" data-iconpos="notext" data-back="true">Home</a>' + 
         ' <h1 id="articleHeader' + i + '">&nbsp;</h1>' + 
         ' </div>' + 
         ' <div data-role="content">' + 
         ' <div id="articleContent' + i + '" class="articleContent"></div>' + 
         ' <div data-role="controlgroup" data-type="horizontal">' + 
         '  <a href="#article' + String(i - 1) + '" data-role="button" data-icon="arrow-l"' + 
         '  data-inline="true" class="prevButton">Précident</a>' + 
         '  <a href="#article' + String(i + 1) + '" data-role="button" data-icon="arrow-r"' + 
         '  data-inline="true" class="nextButton" data-iconpos="right">Suivant</a>' + 
         ' </div>' + 
         ' </div>' + 
         '</div>' 
         ); 
      } 
      /* JSONP */ 
      $(function() { 

       getOnlineFeed('http://www.01net.com/rss/info/flux-rss/flux-toutes-les-actualites/'); 


      }); 
      /* functions */ 
      var listEntries = function (json) { 
       if (!json.responseData.feed.entries) 
        return false; 

       var articleLength = json.responseData.feed.entries.length; 
       articleLength = (articleLength > maxLength) ? maxLength : articleLength; 
       for (var i = 1; i <= articleLength; i++) { 
        var entry = json.responseData.feed.entries[i - 1]; 

        var des = entry.content; 
        var ctn; 
        var lnn = des.length; 
        var fn = des.indexOf("<img"); 
        ctn = des.substr(0, fn - 1); 

        var start = des.indexOf("src="); 
        var end = lnn - (start + 5); 

        var imgs = des.substr(start + 5, end - 2); 

        var date = entry.publishedDate.substr(5, 11); 

        var liste = { 
         Jan: 'Janvier', 
         Feb: 'Février', 
         Mar: 'Mars', 
         Apr: 'Avril', 
         May: 'Mai', 
         Jun: 'juin', 
         Jul: 'juillet', 
         Aug: 'août', 
         Sep: 'septembre', 
         Oct: 'octobre', 
         Nov: 'novembre', 
         Dec: 'décembre' 
        }; 

        var jour = date.substr(0, 2); 
        var bl = date.indexOf(" 2"); 
        var xs = date.substr(3, 3); 
        var annes = date.substr(bl, date.length); 
        var mois = liste[xs]; 

        $('#link' + i).html("<h5>" + entry.title + "</h5>" + "<p>" + ctn + "</p>"); 
        $('#articleHeader' + i).text("Actualités"); 
        $('#openButton' + i).attr('href', entry.link); 
        $('#articleContent' + i).append("<strong>" + entry.title + "</strong><br><br>" + ctn); 
        $('#articleContent' + i).append('<img class="pic" src="' + imgs + '">'); 
        $('#articleContent' + i).append("<br> Date de publication : " + jour + " " + mois + annes); 
        $('#articleContent' + i).append('<br><br><center><a class="ui-btn ui-icon-search ui-btn-icon-left" href="' + entry.link + '" onclick="window.open(this.href); return false;" >Voir plus</a></center>'); 



       } 
       $('#article1 .prevButton').remove(); 
       $('#article' + articleLength + ' .nextButton').remove(); 
       if (articleLength < maxLength) { 
        for (i = articleLength + 1; i <= maxLength; i++) { 
         $('#list' + i).remove(); 
         $('#article' + i).remove(); 
        } 
       } 
      }; 
      var getOnlineFeed = function (url) { 
       var script = document.createElement('script'); 
       script.setAttribute('src', 'http://ajax.googleapis.com/ajax/services/feed/load?callback=listEntries&hl=ja&output=json-in-script&q=' 
         + encodeURIComponent(url) 
         + '&v=1.0&num=' + maxLength); 
       script.setAttribute('type', 'text/javascript'); 
       document.documentElement.firstChild.appendChild(script); 
      }; 
      var getOfflineFeed = function (url) { 
       var script = document.createElement('script'); 
       script.setAttribute('src', url); 
       script.setAttribute('type', 'text/javascript'); 
       document.documentElement.firstChild.appendChild(script); 
      }; 
      $(document).on('click', ".external", function (e) { 
       e.preventDefault(); 
       var targetURL = $(this).attr("href"); 

       window.open(targetURL, "_system"); 
      }); 
     </script> 

    </body> 
</html> 

Antwort

0

Sieht so aus, als könnte es sich nicht mit Ihrer API verbinden, mit der Möglichkeit, dass Sie Ihre Remote-Verbindungen nicht auf die weiße Liste setzen?

Wenn nicht die cordova whitelist plugin herunterladen und die folgenden auf Ihre config.xml

<access origin="*"/> 
<access origin="tel:*" launch-external="yes"/> 
<allow-navigation href="*"/> 
<allow-navigation href="http://*/*"/> 
<allow-navigation href="https://*/*"/> 
<allow-navigation href="data:*"/> 
<allow-intent href="*"/> 
<access origin="*"/> 
hinzufügen