Friday, 25 May 2018

Phonegap Status bar styleDefault & fall back for android below 6

I want to set my android app status bar to light background and dark text. It is working perfectly when I view my app in Phonegap mobile app. But after building the app and installing in mobile it's not working. I'm using Android 7.

I used below code in config

<preference name="StatusBarBackgroundColor" value="#F1F1F1" />
<preference name="StatusBarStyle" value="default" />

I've also tried using javascript in index.js after the device ready

StatusBar.backgroundColorByHexString("#F1F1F1");
StatusBar.styleDefault();

I tried removing the plugin and installed the latest code from github as suggested by related posts in StackOverflow. Nothing is working. Any suggestions?

Also, Is there any fallback code to handle android versions below 6? I came to know that those versions doesn't support dark text in status bar.



from Phonegap Status bar styleDefault & fall back for android below 6

Tuesday, 11 July 2017

Get Youtube Video Total Views, comments,like.unlike,favourate [PHP and json]

 <?php 
$video_ID = "D8Mlj39Mpyo";
$jsonURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$video_ID}&key=YOUR_KEY_HERE&part=statistics");
$json = json_decode($jsonURL);
$views = $json->{'items'}[0]->{'statistics'}->{'viewCount'};
echo number_format($views,0,'.',',');
echo json_encode($json);
 ?> 

Friday, 30 June 2017

Change Browser URL without reloading (refreshing) page using HTML5 in JavaScript and jQuery

Change Browser URL without reloading using JavaScript
<script type="text/javascript">
function ChangeUrl(title, url) {
    if (typeof (history.pushState) != "undefined") {
        var obj = { Title: title, Url: url };
        history.pushState(obj, obj.Title, obj.Url);
    } else {
        alert("Browser does not support HTML5.");
    }
}
</script>
<input type="button" value="Page1" onclick="ChangeUrl('Page1', 'Page1.htm');" />
<input type="button" value="Page2" onclick="ChangeUrl('Page2', 'Page2.htm');" />
<input type="button" value="Page3" onclick="ChangeUrl('Page3', 'Page3.htm');" />



Change Browser URL without reloading using jQuery

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    function ChangeUrl(page, url) {
        if (typeof (history.pushState) != "undefined") {
            var obj = { Page: page, Url: url };
            history.pushState(obj, obj.Page, obj.Url);
        } else {
            alert("Browser does not support HTML5.");
        }
    }
    $(function () {
        $("#button1").click(function () {
            ChangeUrl('Page1', 'Page1.htm');
        });
        $("#button2").click(function () {
            ChangeUrl('Page2', 'Page2.htm');
        });
        $("#button3").click(function () {
            ChangeUrl('Page3', 'Page3.htm');
        });
    });
</script>
<input type="button" value="Page1" id="button1" />
<input type="button" value="Page2" id="button2" />
<input type="button" value="Page3" id="button3" />