home *** CD-ROM | disk | FTP | other *** search
-
- function handleUpdateDialog()
- {
- // if cookies are disabled by user don't show nag dialog, ever
- if ( !window.navigator.cookieEnabled )
- return;
-
- // if no cookie create one. User deleted or first time app run.
- if ( document.cookie == "" )
- createCookie();
-
- // read cookie and parse out fields
- var reminder_date;
- var dialogShown;
- var shouldShowDialog;
- var WS_cookie = document.cookie;
- var WS_cookie_array = WS_cookie.split(",");
- reminder_date = WS_cookie_array[1];
- dialogShown = WS_cookie_array[2];
- shouldShowDialog = WS_cookie_array[3];
-
- var current_date = getCurrentDate();
-
- // see if we need to show dialog. If so, show it
- if ( need_to_show_dialog( current_date, reminder_date, dialogShown, shouldShowDialog ))
- {
- var args = new dialogArgs();
- var strFeatures = "dialogWidth:585px;dialogHeight:300px;" +
- "help:no;maximize:no;minimize:no;scrollbars:no;status:no";
-
- var cRetValue=showModalDialog( "update.htm", args, strFeatures );
-
- // get user results
- shouldShowDialog = ( args.showFlag == true ) ? "true" : "false";
- dialogShown = "true";
-
- // set next show date
- var reminder_date = getReminderDate();
-
- // write cookie
- writeCookie( reminder_date, dialogShown, shouldShowDialog );
-
- // navigate to local SmartUpdate page
- if ( cRetValue == true )
- {
- window.top.navigate( "update_confirm.htm" );
- }
- }
- }
-
- function need_to_show_dialog( current_date, reminder_date, dialogShown, shouldShowDialog )
- {
- if ( shouldShowDialog == "true")
- return evalDate( current_date, reminder_date ); // see if time interval has elapsed
-
- return false;
- }
-
- function evalDate( current, datetoeval )
- {
- if ( datetoeval == "" || current == "" )
- return false;
-
- var currentyear = current.substring(4,8);
- var currentmonth = current.substring(0,2);
- var currentdate = current.substring(2,4);
- var datetoevalyear = datetoeval.substring(4,8);
- var datetoevalmonth = datetoeval.substring(0,2);
- var datetoevaldate = datetoeval.substring(2,4);
-
- //alert("Current\r" + currentyear + "\r" + currentmonth + "\r" + currentdate + "\r\r" + "Date to Eval\r" + datetoevalyear + "\r" + datetoevalmonth + "\r" + datetoevaldate + "\r")
-
- if (currentyear > datetoevalyear)
- return true;
-
- if (currentyear < datetoevalyear)
- return false;
-
- if (currentyear == datetoevalyear)
- {
- if (currentmonth > datetoevalmonth)
- return true;
- if (currentmonth == datetoevalmonth)
- {
- if (currentdate >= datetoevaldate)
- return true;
- }
- }
- return false;
- }
-
- // If the Cookie doesn't exist, create it and write it out
- function createCookie()
- {
- var reminder_date = getReminderDate();
- var dialogShown = "false";// Set up first time this instance flag
- var shouldShowDialog = "true";// Set up ok with user to show flag
-
- writeCookie( reminder_date, dialogShown, shouldShowDialog );
-
- } // createCookie
-
- // Set up reminder date
- function getReminderDate()
- {
- var reminder = new Date();
- var remind_month = (reminder.getMonth() + 2);
- var remind_date = (reminder.getDate());
- var remind_year = (reminder.getYear());
- if ((remind_year>"97") && (remind_year<"2000"))
- remind_year = remind_year + 1900;
-
- if (remind_month > 12)
- {
- remind_month = remind_month - 12;
- remind_year = remind_year + 1;
- }
-
- if (remind_month<"10")
- remind_month="0" + remind_month;
-
- if (remind_date<"10")
- remind_date="0" + remind_date;
-
- var reminder_date=(remind_month + "" + remind_date + "" + remind_year);
-
- return reminder_date;
-
- }
-
- function writeCookie( reminder_date, dialogShown, shouldShowDialog )
- {
- // Set up expiration date
- var the_date = new Date("December 31, 2032");
- var expirationDate = the_date.toGMTString();
-
- // Set up cookie and write it
- var WS_cookie = "workshop_cookie=," + reminder_date + "," + dialogShown + "," + shouldShowDialog;
- WS_cookie = WS_cookie + ";expires=" + expirationDate;
- document.cookie = WS_cookie;
-
- //alert ( "writing cookie: " + WS_cookie );
- }
-
- // set up normalized current date
- function getCurrentDate()
- {
- var reminder = new Date();
- var addyear = "";
- var remind_month = (reminder.getMonth() + 1);
- var remind_date = reminder.getDate();
- var remind_year = reminder.getYear();
-
- if ((remind_year > "97") && (remind_year < "2000")) //Sets year to 4 digits
- addyear=19;
-
- if (remind_month < "10") //Makes the month a 2 digit if it isn't
- remind_month = "0" + remind_month;
-
- if (remind_date < "10") //Makes the day a 2 digit if it isn't
- remind_date = "0" + remind_date;
-
- var current_date = (remind_month + "" + remind_date + "" + addyear + remind_year);
-
- return current_date;
- }
-
- // Create dialogArgs object & initialize
- function dialogArgs()
- {
- this.showFlag = true;
- }
-
-