// // no_session > 0 - session found, 1 - no session // test_cookie > 0 - test for cookie, 1 - tested // cookies_allowed > 0 - not accepted, 1 - accepted // signed_in > 0 - no, 1 - yes // member_id > // member_name > // member_access_type > 'cookie' or 'session' // staff > 0 - no, 1 - yes // refresh > // error_msg > // dash_loaded > 0 - not yet, 1 - non-member, 2 - member, 3 - staff // dash_bg_width > 0 // dash_clock_time > // in_the_works > alert message // var tracking_settings = { no_session: -1, test_cookie: -1, cookies_allowed: -1, signed_in: -1, member_id: -1, member_name: '', member_access_type: '', staff: 0, refresh: 0, error_msg: '', dash_loaded: 0, dash_bg_width: 0, dash_clock_time: '', in_the_works: 'This is in the works!\nSorry for any inconvienence!' }; function tracking_apply_value(n,v) { tracking_settings[n] = v; } var User_Tracking = new Class({ Implements: [Options, Events], options: { }, initialize: function (options) { }, Make_Request: function () { var opt = (arguments[0] ? arguments[0] : ""); if (this.options.refresh == 1) { opt = "members"; } var start = new Request({ method: 'get', url: 'http://www.pictoucounty.ca/x/utility/user_tracking.php', onSuccess: function(html) { var resp = html.split("|"); if (resp[0] == "error") { tracking_apply_value('error_msg',resp[1]); User_Tracking.Process_Results(); } else if (resp[0] == "no_session") { tracking_apply_value('no_session',1); Tracking.Process_Results(); } else if (resp[0] == "test_cookie") { tracking_apply_value('test_cookie',0); tracking_apply_value('no_session',0); Tracking.Make_Request('cookie'); } else if (resp[0] == "cookie_accepted") { tracking_apply_value('cookies_allowed',resp[1]); tracking_apply_value('test_cookie',1); Tracking.Make_Request('members'); } else { tracking_apply_value('error_msg','Unable to complete processing of tracking procedures. - '+html); Tracking.Process_Results(); } }, onFailure: function (xhr) { tracking_apply_value('error_msg','Unable to test for cookies & sessions. - '+xhr.status+': '+xhr.statusText); User_Tracking.Process_Results(); } }); var cookie = new Request({ method: 'get', url: 'http://www.pictoucounty.ca/x/utility/user_tracking.php?ckt=1', onSuccess: function(html) { var resp = html.split("|"); Tracking.options.test_cookie = 1; if (resp[0] == "error") { tracking_apply_value('error_msg',resp[1]); Tracking.Process_Results(); } else if (resp[0] == "no_session") { tracking_apply_value('no_session',1); tracking_apply_value('error_msg','Session appears to have been lost.'); Tracking.Process_Results(); } else if (resp[0] == "cookie_accepted") { tracking_apply_value('cookies_allowed',resp[1]); Tracking.Make_Request('members'); } else { tracking_apply_value('error_msg','Unable to complete processing of tracking procedures. - '+html); Tracking.Process_Results(); } }, onFailure: function(xhr) { tracking_apply_value('error_msg','Failed to test for cookies. - '+xhr.status+': '+xhr.statusText); Tracking.Process_Results(); } }); var members = new Request({ method: 'get', url: 'http://www.pictoucounty.ca/x/utility/user_tracking.php?mem=1', onSuccess: function(html) { var resp = html.split("|"); if (resp[0] == "error") { tracking_apply_value('error_msg',resp[1]); Tracking.Process_Results(); } else if (resp[0] == "no_session") { tracking_apply_value('no_session',1); tracking_apply_value('error_msg','Session appears to have been lost.'); Tracking.Process_Results(); } else if (resp[0] == "cookie_accepted") { tracking_apply_value('cookies_allowed',resp[1]); if (resp[2] == "not_signed_in") { tracking_apply_value('signed_in',0); tracking_apply_value('member_id',0); tracking_apply_value('member_name',resp[3]); tracking_apply_value('member_access_type','session'); tracking_apply_value('refresh',1); window.setTimeout('Tracking.Make_Request()',30000); } else if (resp[2] == "error") { tracking_apply_value('error_msg',resp[3]); } else { tracking_apply_value('signed_in',1); tracking_apply_value('member_id',resp[3]); tracking_apply_value('member_name',resp[4]); tracking_apply_value('staff',resp[5]); tracking_apply_value('member_access_type',resp[6]); tracking_apply_value('refresh',1); window.setTimeout('Tracking.Make_Request()',20000); } Tracking.Process_Results(); } else { tracking_apply_value('error_msg','Unable to complete processing of tracking procedures. - '+html); Tracking.Process_Results(); } }, onFailure: function(xhr) { tracking_apply_value('error_msg','Failed to check member access. - '+xhr.status+': '+xhr.statusText); Tracking.Process_Results(); } }); switch (opt) { case "cookie": cookie.send(); break; case "members": members.send(); break; default: start.send(); } }, Process_Results: function () { var rez = Utility.rez(); // Dashboard (background) // ---------------------------- if (!$('user_dashboard_bg')) { var dash_bg = PageX.Item('div',{ 'id': 'user_dashboard_bg', 'html': ' ' },document.body,1); dash_bg.style.zIndex = "1101"; dash_bg.style.position = "fixed"; dash_bg.style.visibility = "visible"; dash_bg.style.display = "inline"; dash_bg.style.bottom = "0px"; dash_bg.style.left = "0px"; dash_bg.style.borderStyle = "solid"; dash_bg.style.borderWidth = "1px 0px 0px 0px"; dash_bg.style.borderColor = "#DDDDDD"; dash_bg.style.width = (1*rez[0])+"px"; dash_bg.style.height = "25px"; dash_bg.style.backgroundImage = "url(http://x.pictoucounty.ca/members/dash_bg.png)"; //tracking_settings.dash_bg_width = (1*rez[0]); //Tracking.Dashboard_BG(); } else { var dash_bg = $('user_dashboard_bg'); } // Dashboard - Welcome [name] // ---------------------------- if (!$('user_dashboard_welcome')) { var dash_welcome = PageX.Item('div',{ 'id': 'user_dashboard_welcome', 'html': 'Welcome '+tracking_settings.member_name+'! ~ We hope you enjoy your visit..' },document.body,1); dash_welcome.style.zIndex = "1102"; dash_welcome.style.position = "fixed"; dash_welcome.style.visibility = "visible"; dash_welcome.style.display = "inline"; dash_welcome.style.bottom = "4px"; dash_welcome.style.left = "6px"; } else { var dash_welcome = $('user_dashboard_welcome'); } var show_error = 0; if (tracking_settings.no_session == 1) { tracking_settings.error_msg = "Session lost or unable to access. Please refresh!"; show_error = 1; } else if (tracking_settings.error_msg != "") { show_error = 1; } else { // Setup which dash? (non-member, member or staff?) // ---------------------------- if (tracking_settings.signed_in == -1) { tracking_settings.error_msg = "Opps. Unable to display the dashboard at this time!"; show_error = 1; } else { // If no change, no update // -------------------------- var dash_type = (tracking_settings.signed_in > 0 ? 2 : 1); dash_type = (dash_type == 2 && tracking_settings.staff == 1 ? 3 : dash_type); var dash_change = (tracking_settings.dash_loaded == 0 ? 1 : 0); dash_change = (dash_change == 0 && tracking_settings.dash_loaded != dash_type ? 1 : dash_change); if (dash_change == 1) { // Right Menu if (!$('user_dashboard_left') && !$('user_dashboard_right')) { var left = PageX.Item('div',{ 'id': 'user_dashboard_left', 'html': '', 'styles': { 'zIndex': '1104','position': 'fixed','visibility': 'visible','display': 'inline','bottom': '6px','left': '6px' } },document.body,1); var right = PageX.Item('div',{ 'id': 'user_dashboard_right', 'html': '', 'styles': { 'zIndex': '1103','position': 'fixed','visibility': 'visible','display': 'inline','bottom': '6px','right': '6px' } },document.body,1); if (dash_type == 2 || dash_type == 3) { // Left Dashboard left.innerHTML = left.innerHTML + ''+tracking_settings.member_name; // Chat right.innerHTML = right.innerHTML + 'Chat with.. ' +'' +'Public' +' / ' +'' +'Friends'; // Logout right.innerHTML = right.innerHTML + '  |   Logout'; } else { // Public Chat right.innerHTML = '' +'Public Chat  '; } } else { var left = $('user_dashboard_left'); var right = $('user_dashboard_right'); } switch (dash_type) { case 2: // Member (be sure to re-confirm account) break; case 3: // Staff (be sure to re-confirm account) Utility.display(dash_welcome,0); // Left Dashboard left.innerHTML = left.innerHTML + ' . Send Email?'; break; default: // Non-member } tracking_settings.dash_loaded = dash_type; } } } if (show_error == 1) { //dash.innerHTML = ""; var e = PageX.Item('div',{ 'id': 'tracking_session_error', 'html': 'Error: '+tracking_settings.error_msg },document.body,1); e.style.zIndex = "1150"; e.style.position = "fixed"; e.style.visibility = "visible"; e.style.display = "inline"; e.style.bottom = "0px"; e.style.left = "0px"; e.style.borderStyle = "solid"; e.style.borderWidth = "1px 1px 0px 0px"; e.style.borderColor = "#CE533E"; e.style.padding = "5px"; e.style.backgroundColor = "#FFDCC8"; e.style.color = "#960000"; } } }); var Tracking = new User_Tracking(); // Check for session, cookies & member access // ------------------------------------------- window.addEvent('domready', function() { Tracking.Make_Request(); });