App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.



If you are facing this issue when you are using IONIC(PhoneGap) and run the app on iPhone/iPad(IOS)

the add the following lines at the end of your info.plist file (It must be before the last  </dict> tag):


    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>

    </dict>

Splash preferences



Manage Splash Screen in IONIC(PhoneGap) or Native Project


  <preference name="SplashScreen" value="screen"/>
  <preference name="SplashScreenDelay" value="5000"/>
  <preference name="AutoHideSplashScreen" value="true" />
  <preference name="ShowSplashScreenSpinner" value="true"/>
  <preference name="FadeSplashScreen" value="true"/>
  <preference name="FadeSplashScreenDuration" value="1000"/>


For Manage Orientation

  <preference name="Orientation" value="portrait"/>

Capitalize in Javascript

You can Capitalise a string by core Javascript. I've write a function for this :

String.prototype.capitalize = function() {
return this.replace(/(?:^|\s)\S/g, function(a) {
return a.toUpperCase();
});

};

Show console.log in different colours in javascript

I've write a function for this :


function log(msg, color) {
    color = color || "black";
    bgc = "White";
    switch (color) {
        case "success":  color = "Green";      bgc = "White";       break;
        case "info":     color = "DodgerBlue"; bgc = "Turquoise";       break;
        case "error":    color = "Red";        bgc = "White";           break;
        case "start":    color = "OliveDrab"bgc = "PaleGreen";       break;
        case "warning":  color = "Tomato";     bgc = "Black";           break;
        case "end":      color = "Orchid";     bgc = "MediumVioletRed"; break;
        default: color = color;
    }

    if (typeof msg == "object") {
        console.log(msg);
    } else if (typeof color == "object") {
        console.log("%c" + msg, "color: PowderBlue;font-weight:bold; background-color: RoyalBlue;");
        console.log(color);
    } else {
        console.log("%c" + msg, "color:" + color + ";font-weight:bold; background-color: " + bgc + ";");
    }

}


You can use it like:

log("This is a Message", "error");

Sort JSON array in javascript

I've write a function for this :


function sortJson(arr, prop, dir) {
    return arr.sort(function(a,b) {       
        var propA = a[prop],propB = b[prop];
        
        if (dir=='asc') {
            return propA - propB;
        } else {
            return propB - propA;
        }
    });

}

Replace all in Javascript

I was notice that when you want to replace a string-1 to the another string-2 and the string-1 present on more the one place the the js replace function is not work properly, so here I've write a js prototype function for this :

String.prototype.replaceAll = function (find, replace) {
    var str = this;
    return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);

};