Software Archive
Read-only legacy content
17061 Discussions

Intel XDK and cookie

Adam_t_1
Beginner
504 Views

I need code for saveing my apk. I find this https://software.intel.com/en-us/node/492874 and https://software.intel.com/en-us/node/492856 how i put in to my code ? I need save click ... pleas help :/

<script type="text/javascript">
    var clicks = 0;
    var pocetDniPreUchovanieCookies = 31;
    function onClick() {
        clicks += 1;
        document.getElementById("clicks").innerHTML = clicks;

        if(clicks === 1000){
           document.location = "win.html";
        }
    };
    </script>

<center><p style="color:#fff; font-family:clicker";>Clicks: <a id="clicks">0</a> / <a style="color:#560606;">1000</a></p></center>

<center><img src="img/chest.png" onClick="onClick() , intel.xdk.cache.getCookie('clicks');"></img></center>

 

0 Kudos
2 Replies
SithLord
New Contributor I
504 Views
//Saves the value of clicks to a cookie var called clickCke
var cookieTimeout = 15;

intel.xdk.cache.setCookie("clickCke", clicks, cookieTimeout);

//Read back the value
intel.xdk.cache.getCookie("clickCke");

Don't try and access the cookie before the app.Ready event fires.

0 Kudos
Adam_t_1
Beginner
504 Views

SithLord wrote:

//Saves the value of clicks to a cookie var called clickCke
var cookieTimeout = 15;

intel.xdk.cache.setCookie("clickCke", clicks, cookieTimeout);

//Read back the value
intel.xdk.cache.getCookie("clickCke");

Don't try and access the cookie before the app.Ready event fires.

I add to my script but but it does not work. Pleas help.

<script type="text/javascript">
    var clicks = 0;
	var cookieTimeout = 15;
    function onClick() {
        clicks += 1;
        document.getElementById("clicks").innerHTML = clicks;
		intel.xdk.cache.setCookie("clickCke", clicks, cookieTimeout);
		intel.xdk.cache.getCookie("clickCke");
	
        if(clicks === 1000){
           document.location = "win.html";
        }
    };
    </script>

 

0 Kudos
Reply