2013-08-19 2 views
0

У меня в основном есть две страницы в приложении для телефонных разговоров, которые я строю с помощью PGB (index.html и main.html), которые оба используют angular.js. Index.html - это логин для приложения, который впоследствии перенаправляется на main.html. Все мои плагины и phonegap.js вносятся в основную часть, но ни один из встроенных JS (предупреждения о готовке документа, готовность к устройству, загрузка окна) не запускаются, не говоря уже о загрузке phonegap.js.Phonegap.js на второй странице html

Любые советы будут оценены.

Сценарий включает в себя:

<script src="phonegap.js"></script> 
<script src="cdv-plugin-fb-connect.js"></script> 
<script src="facebook-js-sdk.js"></script> <script>alert("inside pg");</script> 
<script src="childbrowser.js"></script> 
<script src="js/jquery.js"></script> 
<script src="js/angular.min.js"></script> 
<script>alert("here");</script> 
<script src="js/controllers.js"></script> 
<script src="js/klass.min.js"></script> 
<script src="js/code.photoswipe.jquery-3.0.5.min.js"></script> 
<script src="js/maskedInput.js" type="text/javascript"></script> 
<script src="js/jquery.joyride.js"></script> 
<script src="js/jquery.fancybox.pack.js"></script> 
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script> 

Сценарии:

alert("p2 adding") 
document.addEventListener("deviceready", onDeviceReady, false); 

// PhoneGap is loaded and it is now safe to make calls PhoneGap methods 
// 
function onDeviceReady() { 
    alert("main.html: device is ready"); 
} 

$(window).load(function(){ 
    alert("window.load happening"); 
}) 
</script> 

<script> 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-42023187-1']); 

    _gaq.push(['_trackPageview']); 

    (function() { 
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
    })(); 

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 

    ga('create', 'UA-42023187-1', 'openvino.com'); 
    ga('send', 'pageview'); 

</script> 

<script type="text/javascript"> 
    var objectToLike = window.location; 
    var FBactivated = false; 

    FB.init({ 
     appId  : '659381964079214', // App ID 
     channelURL : '', // Channel File, not required so leave empty 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     oauth  : true, 
     xfbml  : true // parse XFBML 
    }); 
    FB.Event.subscribe('auth.authResponseChange', function(response) { 
     // Here we specify what we do with the response anytime this event occurs. 
     if (response.status === 'connected') { 
     getFriends(); 
     testAPI(); 
     FBactivated = true; 
     } 
    }); 

    function getFriends() { 
    var fbUserIDs = [] 
    FB.api('/me/friends', function(response) { 
     if(response.data) { 
      $.each(response.data,function(index,friend) { 
       var id = friend.id; 
       fbUserIDs.push(id); 
      }); 
      var dataString = "fbUserIDs="+fbUserIDs.join(); 
      $.ajax({ 
      type: "POST", 
      data: dataString, 
      async: false, 
      url: "http://m.openvino.com/Scripts/faveMatch.php" 
      }).done(function(data){ 
      console.log(data); 
      window.localStorage.setItem("fbFriends", data); 
      console.log("Saved"); 
      }); 
     } else { 
      alert("Error!"); 
     } 
    }); 
    } 

    function testAPI() { 
    FB.api('/me', function(response) { 
     //console.log(response, response.email); 
     var dataString2 = "id=" + response.id; 
     dataString2 += "&first_name=" + response.first_name; 
     dataString2 += "&last_name=" + response.last_name; 
     dataString2 += "&email=" + response.email; 
     console.log(dataString2); 
     $.ajax({ 
     type: "POST", 
     url: "http://m.openvino.com/Scripts/fbconnect.php", 
     data: dataString2 
     }).done(function(data){ 
     var dataJSON = $.parseJSON(data); 
     if (dataJSON[0].STATUS == "FAILURE") { 
      //console.log(dataJSON[0].MESSAGE); 
      return false; 
     } else if (dataJSON[0].STATUS == "SUCCESS") { 
      window.localStorage.setItem('email',dataJSON[0].COOKIE.email); 
      window.localStorage.setItem('password',dataJSON[0].COOKIE.password); 
      window.localStorage.setItem('name_first',dataJSON[0].COOKIE.name_first); 
      window.localStorage.setItem('name_last',dataJSON[0].COOKIE.name_last); 
      window.localStorage.setItem('uID',dataJSON[0].COOKIE.uID); 
      window.localStorage.setItem('phone',dataJSON[0].COOKIE.phone); 
      window.localStorage.setItem('firstTime',dataJSON[0].COOKIE.firstTime); 
     } 
     }); 
    }); 
    } 

    function fbLogout() { 
    if (FBactivated) { 
     try { 
     FB.logout(function(response) { 
      window.location.href = "index.html"; 
     }); 
     } catch (err) { 
     window.location.href = "index.html"; 
     } 
    } else { 
     window.location.href = "index.html"; 
    } 
    } 

    $(document).ready(function() { 
    alert("document.ready loaded"); 

    $("#logmeout").click(function(e){ 
     e.preventDefault(); 
     window.localStorage.clear(); 

     fbLogout(); 
     return false; 
    }); 

    $('.back_btn').click(function(e) { 
     $('.profile_menu').hide(); 
     history.back(); 
    }); 

    $(document).click(function(e) { 
     $('.profile_menu').hide(); 
    }) 

    $('.profile_btn').click(function(e) { 
     $('.profile_menu').slideToggle(); 
     e.stopPropagation(); 
     e.preventDefault(); 
     return false; 
    }); 

    $('.profile_menu a').each(function() { 
     $(this).click(function(e) { 
     $('.profile_menu').hide(); 
     }); 
    }); 
    }); 

HTML:

<body ng-app="OpenVino"> 
<div id="fb-root"></div> 
<div class="header-wrap"> 
    <header> 
    <div ng-show="(page != 'list')" class="back_btn"></div> 
    <a href="#" onclick="launchBrowser(http://facebook.com)"><img src="imgs/logo_only.png" alt="OpenVino" /></a> 
    <div class="profile_btn"></div> 
    </header> 
</div> 
<div class="profile_menu"> 
    <a href="#/users/">My Favorites</a> 
    <a href="#/aboutus/">Contact OpenVino</a> 
    <a href="#/lifestyle/">Images</a> 
    <a href="#" id="logmeout">Logout</a> 
</div> 
<div class="content {{page}}" ng-view></div> 

ответ

0

Я установил его с простым, но обескураживает решение: Вы должны превратить свою му приложение ltipage в одностраничном приложении. К сожалению, как телефонная реклама рекламирует, что вы можете взять свой HTML, CSS и JS и построить его изначально. Все .js, загруженные на вторую страницу, не будут работать, пока я не изменю свой логин на частичный и не обманут с помощью маршрутизации.

Смежные вопросы