FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Do you think this will work?

 


chiragpatnaik
Code:
var firstExecutionString = widget.preferenceForKey('first_execution');

// if first execute flag doesn't exist set date
if (!firstExecutionString) {
   var setdate = new Date().toString();
   
   widget.setPreferenceForKey(setdate, 'first_execution')
}
// else set compare dates
else {
   var firstExecutionDate = new Date(firstExecutionString);

// set date offset
var offsetDate = new Date();
offsetDate.setDate(firstExecutionDate.getDate()+3);

var now = new date()   
   
   if (now > offsetDate) {
      var exp = 1
      widget.setPreferenceForKey(exp, 'expire')
   }
}   

// Check for expire flag
var exp1 = widget.preferenceForKey('expire')
   

if (exp1 = 1) {
      alert('The widget has expired. Please download the full version');
      setInterval('window.close()', 1000);
   }


Just ignore the widget.statements. I am reading and writing data from persistent storage. This is for the WRT platform BTW and aism to expire the app 3 days after it was first run.
Marcuzzo
did you test is yourself?
chiragpatnaik
Marcuzzo wrote:
did you test is yourself?


yeah. I finally got it. There were some minor errors. Here is the final code. It works.


Code:



var firstExecutionString = widget.preferenceForKey('first_execution');

// if first execute flag doesn't exist set date
if (!firstExecutionString) {
   var setdate = new Date().toString();
   
   widget.setPreferenceForKey(setdate, 'first_execution')
}
// else set compare dates
else {
   var firstExecutionDate = new Date(firstExecutionString);

// set date offset
var offsetDate = new Date();
offsetDate.setDate(firstExecutionDate.getDate()+3);

var now = new Date();   
   
   if (now > offsetDate) {
      var exp = 1;
      widget.setPreferenceForKey(exp, 'expire');
   }
}   

// Check for expire flag
var exp1 = widget.preferenceForKey('expire');
   

if (exp1 == 1) {
      alert('The widget has expired. Please download the full version');
      setInterval('window.close()', 1000);
   }

rajpk
ok thanx for telling
we are now free
mean not to think for soloution Very Happy
Related topics

Question: How long does it take for the subdomain to work?
ftp wont work
Do you give 100% at work ?
my cpanel is not work it ask me that password is wrong
Do You Know My Work

Want a day off work?
Capturing multiple USB cams to an AVI or MPEG file.
When it'll work?
Programmers/Designers - work and get paid (I am already)
How to Work Out Smarter, Not Harder

Is it possible to make ALL BBCode work?
Admins help please, My domain wont work! (its my domain.)
prefix www doesn't work.
My Sql does not work at all.
To all of the Admin staff here at FriHosting...

How many time this free space work??
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.