Page 1 of 2

Set variable in local storage? (New update)

Posted: Sun Mar 01, 2015 11:53 pm
by David Lewis

Since the update, some of the features for setting local variable are not working. For example, I try to set a variable using the Events area, but the Value input only has a dropdown menu with no options.

I only ask because all of the tutorials are from over a year ago, and the UI has changed considerably.


Set variable in local storage? (New update)

Posted: Mon Mar 02, 2015 5:48 am
by Yurii Orishchuk

Hi David,

Please show us more details about this problems.
Some screen shots will be great.

Thanks.


Set variable in local storage? (New update)

Posted: Mon Mar 02, 2015 1:08 pm
by David Lewis

Sure. Here is the relevant code, then the screenshot (see other reply) of the Event window. My app is a basic calculator, so it needs to pull in user input. I could just be coding wrong (new to Javascript).

var majd = Number(Apperyio("majd").val());

if (majd === 0) {
alert ("Please enter number 0.");
return;
}

var decmd = eval(majd);

var TPI = Number(Apperyio("TPI").val());

if (TPI === 0) {
alert ("Please enter number 0.");
return;
}

var n = Number(Apperyio("n").val());

if (n === 0) {
alert ("Please enter number 0.");
return;
}

var tlength = Number(Apperyio("tlength").val());

if (tlength === 0) {
alert ("Please enter number 0.");
return;
}

var offset = Number(Apperyio("offset").val());

if (offset === 0) {
alert ("Please enter number 0.");
return;
}

var feed = 1/TPI ;
var k = 0.759/TPI;
var mind = majd-(kval2);
var d = kval/(n0.5);
var xcham = mind-0.005;
var zcham = 0-feed;
var g54x = majd+0.05;
var g54z = 3feed;
var zthread = tlength+offset;

Apperyio('feed').text(feed.toFixed(2)+'in./rev');
Apperyio('kval').text(kval.toFixed(2));
Apperyio('mind').text(mind.toFixed(2)+'in.');
Apperyio('xcham').text(xcham.toFixed(2)+'in.');
Apperyio('zcham').text(zcham.toFixed(2)+'in.');
Apperyio('code').text('G00 G54 x'+g54x.toFixed(2)+'z'+g54z.toFixed(2));
Apperyio('code2').text('G76 F'+feed.toFixed(2)+' X'+majd.toFixed(2)+' Z'+zthread.toFixed(2)+' K'+k.toFixed(2)+' D'+d.toFixed(2));


Set variable in local storage? (New update)

Posted: Mon Mar 02, 2015 1:09 pm
by David Lewis

Set variable in local storage? (New update)

Posted: Tue Mar 03, 2015 5:53 am
by Yurii Orishchuk

Hi David,

Unfortunatly i can not see using local storage in your given code.

It still not clear about your problem please try to explain it to clarify.

Also - please check if you have any errors in browser console.

Thanks.


Set variable in local storage? (New update)

Posted: Tue Mar 03, 2015 4:00 pm
by David Lewis

As I said, I'm new to JavaScript. I'm trying to pull user input into basic calculations, then print the results to another page in the app. I tried copying your site's basic tip calculator format, but the output does not appear on the screen.


Set variable in local storage? (New update)

Posted: Wed Mar 04, 2015 4:54 am
by Yurii Orishchuk

Hi David,

For this goal you don't need this lot of code.

Here is a brief plan:

  1. On first page (where are your components) on some event(for example button click) you need to place following JS code(with your modifications):

    pre

    //Where "firstNameInputName" is your input component name.
    var firstName = Apperyio("firstNameInputName");

    //Where "lastNameInputName" is your input component name.
    var lastName = Apperyio("lastNameInputName");

    var name = firstName + " " + lastName;

    alert("name = " + name);

    //Store name value to "name" lsv
    localStorage.setItem("name", name);

    /pre

  2. On second page(where you want to see data from first page) you can use following js code(with your modifications):

    pre

    //Where "labelName" is your label component name.
    var nameLabel = Apperyio("labelName");

    //Get value from LSV
    var name = localStorage.getItem("name");

    //set value to the label.
    nameLabel.text(name);

    /pre

    Note, it just an example of what you want to implement that shows how to work with local storage and appery.io components. You should modify it in accordance to your needs.

    Regards.


Set variable in local storage? (New update)

Posted: Mon Mar 23, 2015 5:36 pm
by David Lewis

It is still getting stuck with a gray, swirling loading icon now. My code pretty much matches yours, but the final page will not load for some reason


Set variable in local storage? (New update)

Posted: Tue Mar 24, 2015 1:56 pm
by Alena Prykhodko

Hello David,

Please try to debug your project http://devcenter.appery.io/documentat...
Are there any errors in browser console?


Set variable in local storage? (New update)

Posted: Wed Mar 25, 2015 5:16 pm
by David Lewis

No errors. It's simple math code in JS. It keeps getting stuck on the loading icon in between the input page and output page.