Cordova text/javascript block grayed out

24 views Asked by At

I was developing a mobile application using Cordova/Phonegap and on html there is a cordova script but it was grayed out. I checked and it was not commented out. Because of this, my application can't load the cordova plugins and it cant run properly.

Here is the webforms2.html code that has the grayed out part under the script section.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
<!-- <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'"> -->
<meta http-equiv="Content-Security-Policy" content="default-src * gap://ready file:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *">
<title>Test App</title>

<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<script src="js/angular.min.js" type="text/javascript"></script>
<script src="js/appController.js" type="text/javascript"></script>
<script src="js/angular-cookies.min.js" type="text/javascript"></script>
<script src="js/angular-sanitize.min.js" type="text/javascript"></script>

<script src="js/cordova.js"></script>


    <script type="text/javascript" charset="utf-8">
    // Wait for Cordova to load
    //
    function onLoad(){
         document.addEventListener("deviceready", onDeviceReady, false);
    }

    // Cordova is ready
    function onDeviceReady() {
        document.addEventListener("backbutton", onBackKeyDown, false);
        //navigator.splashscreen.hide();
        
        window.FirebasePlugin.getToken(function(token) {
            // save this server-side and use it to push notifications to this device
            // alert("token is - " + token);
            window.localStorage.setItem('token', token);
        }, function(error) {
            console.error(error);
        });
        //alert('device is ready');
        
        var success = function(status) {
            //alert('Cache cleared successfully!');
            window.localStorage.setItem('timesLogged', 0);
        };
        
        var error = function(status) {
            //alert('Failed to clear cache.');
        };

        window.localStorage.setItem('timesLogged', parseInt(window.localStorage.getItem('timesLogged'))+1);
        
        //Clear Caches if this page has been visited 300 times
        if(window.localStorage.getItem('timesLogged')>300){
            window.CacheClear(success, error);
        }
    }
    
    
    function onBackKeyDown() {
        var r=confirm("Are you sure you want to exit?"); 
        if (r==true)
        { 
            navigator.app.exitApp();
        }
        else
        {
            return false;
        }
    }
    
    </script>

</head>

Because it was grayed out the following code block do not seem to have the proper details to use the functions like onLoad() and loadIFrame2()


<body data-ng-app="App" data-ng-controller="appController" onLoad="onLoad();" data-ng-init="loadIFrame2()" data-ng-cloak>
<!--<header>
    <div class="container-fluid header">
    <div class="row text-center">
        <div class="col-xs-2 col-sm-1 backBtn" data-ng-click="goBackWebForm()">
            <i class="glyphicon glyphicon-menu-left "></i>
        </div>


        <div class="col-xs-8  col-sm-10 headerPad">
            <h3 class="header-text"><img src="img/logo.png" class="logo"/>
                <span>{{langObj['Profile']}}</span>
            </h3>
        </div>

        <div class="col-xs-2 col-sm-1 glyphicon glyphicon-remove bell" data-ng-click="returnToApp()">
        </div>
    </div>
</div>
</header>-->

<iframe src="about:blank" class="webFormFrame webFormFrame2" id="iframe" ng-hide="error" onLoad="checkURL();">
    
</iframe>
<div class="container" data-ng-show="error">
    <div class="col-xs-12 col-sm-8 col-sm-offset-2 alert-danger" ng-bind="applicationError">
    </div>
</div>
</body>
</html>

I've checked on my cordova plugins, and had already used the latest and also the current cordova plugins to the application but it still does not work.

I've checked on console log cat and it returns these two logs that concerns me, and I am not sure on how to resolve it;

"2023-04-25 12:27:55.419 24498-24585/com.baxter.myapp I/App: WARNING: Back Button Default Behavior will be overridden.  The backbutton event will be fired!
2023-04-25 12:27:55.422 24498-24498/com.baxter.myapp D/SystemWebChromeClient: file:///android_asset/www/webforms2.html: Line 34 : Uncaught TypeError: Cannot read property 'getToken' of undefined
2023-04-25 12:27:55.422 24498-24498/com.baxter.myapp I/chromium: [INFO:CONSOLE(34)] "Uncaught TypeError: Cannot read property 'getToken' of undefined", source: file:///android_asset/www/webforms2.html (34)
2023-04-25 12:27:55.975 24498-24498/com.baxter.myapp D/SystemWebChromeClient: file:///android_asset/www/webforms2.html: Line 98 : Uncaught ReferenceError: checkURL is not defined
2023-04-25 12:27:55.975 24498-24498/com.baxter.myapp I/chromium: [INFO:CONSOLE(98)] "Uncaught ReferenceError: checkURL is not defined", source: file:///android_asset/www/webforms2.html (98)"
0

There are 0 answers