Sunday, October 12, 2014

Alpha Build

I just got my personal framework to Alpha build.  It works... mostly but there is not much to it.

The main focus of it is to make fast and easy web applications that scale.  It will be the base framework for my web games. If your into web applications and want to check out a cool Common JS framework, I am offering the Alpha Build free on my site.www.fracturednations.com

If you want to see it working, its not much, but it works.  Here are two demo sites that I am putting together.

www.fracturednations.info
system.fracturednations.info

Joseph Tveter
www.fracturednations.com


Wednesday, July 30, 2014

Geolocation woes

Apparently HTML5 has an api to get me exactly where I am on the planet.  But it can't tell me what country I am in.  Google will tell me. Google knows all.

    this.getGeoLocation = function()
    {
        var deferred = $.Deferred();
        if(navigator.geolocation)
        {
            navigator.geolocation.getCurrentPosition(function(position)
            {
                deferred.resolve(position);
                //position: {"coords":{"speed":null,"accuracy":65,"altitudeAccuracy":10,"altitude":1410.8349609375,"longitude":-111.72789187811416,"heading":null,"latitude":40.332329714635044},"timestamp":1406740874211}
            });
        }
        else
        {
            deferred.reject({error: "FAIL"});
        }
     return deferred.promise();
    };

Wednesday, July 2, 2014

Wait for it....

Deferred Objects with jquery.  Great for when you are waiting for data to process or servers to reply.

var deferredData = $.Deferred();
deferredData.done(function(result)
{
     //do stuff
}).fail(function(errorObj)
{
     //handel error
}).always(function(result)
{
     //whatever is returned comes here as well.
});

// when the data is done simply call
deferredData.resolve(result);

//or if you want to fail
deferredData.reject(errorObj);

Tuesday, January 7, 2014

Web page scaling to the device!

Web page scaling to the device! Even with different pixel ratios! Will work with android, iPhone and web!

var dpi = window.devicePixelRatio || 1;
var width = $(window).width();
var ratio = 52; //Ratio of target font size to screen width screenWidth/idealFontSize
var font = Math.ceil((width / dpi / ratio)+dpi*3);
if(font < 15)
    font = 15;
// any less is not useable.

$("html").css({"fontSize": font});

Enjoy!