Fieldpine Logo Documentation Home  
Library
» Overview
» eLink API
» Gds API

Mobile Application Read Product Example

This example is primarily intended for programmers and other technical users


Mobile applications for Android, iOS, Windows can be made using Visual Studio and the Apache Cordova App template. This creates what is commonly called a hybrid app and allows the majority of the development in HTML and Javascript while still permitting access to device specific features not normally available to Javascript

Cordova based hybrid apps are relatively easy and cost effective to create. They are suitable for site specific requirements

This code is deliberately simple and would need enhancing before use in production level code

Code

Download Visual Studio Project (660Kb) This project will build and operate in the emulators. To create a version that can be installed on a mobile phone will require some more steps around deployment and code signing. These are not difficult steps, but are environment specific.
function CheckPid() {
    var x = document.getElementById("thePid").value;
    var o = document.getElementById("OutArea");
    if (o) o.innerHTML = "Scanning for " + x;

    var srv = document.getElementById("theServer").value;
    var port = document.getElementById("thePort").value;

    if ((srv.length == 0) || (port.length == 0)) {
        if (o) o.innerHTML = "Unable to scan, server and port both required";
        return;
    }

    var t = new XMLHttpRequest;
    if (port == 80) var req = "http://" + srv + "/gnap/J/buck?3=retailmax.elink.products&9=f100,0," + x;
    else var req = "http://" + srv + ":" + port + "/gnap/J/buck?3=retailmax.elink.products&9=f100,0," + x;
    
	t.open("GET", req, true);

    t.onreadystatechange = function () {
        if (t.readyState == t.DONE) {
            if (t.status == 200) {
                var jj = JSON.parse(t.responseText);
                if (o) {
                    var w = new Array;
                    if ((jj.RootType == "ARAY") && (typeof jj.DATS != 'undefined')) {
                        w.push("Description=");
                        w.push(jj.DATS[0].Description);
                        w.push("<br>Price=");
                        w.push(jj.DATS[0].Price);
                    } else w.push(t.responseText);
                    o.innerHTML = w.join("");
                }
            }
        }
    };
    t.send();
};