diff --git a/spanghurt.user.js b/spanghurt.user.js index 6674f69..d566e76 100644 --- a/spanghurt.user.js +++ b/spanghurt.user.js @@ -6,8 +6,21 @@ // @icon http://kwah.org/images/SpanghurtScriptIcon.png // ==/UserScript== + //var tl8strings = {}; +var alert_counter = 0; + +function modalCheckpoint(arg_context) +{ + if(document.location.href === "http://www.neobux.com/c/rl/?ss3=1") + { + arg_context = (arg_context) ? arg_context : "unknown context"; +// alert(alert_counter + ": \n" + arg_context); + alert_counter++; + } +} + /** * Compatibility functions @@ -25,7 +38,7 @@ if('undefined' === typeof console) { if(arguments.length>1){ location.href = "javascript:void(console.group());"; } for(var i=0; i tl8_counter) { console.info('arg_originalString = ', arg_originalString); - console.info('tmp_translationStringsNeeded[arg_originalString] = ',tmp_translationStringsNeeded[arg_originalString]); - console.info('JSON.stringify(tmp_translationStringsNeeded) = ',JSON.stringify(tmp_translationStringsNeeded)); + console.info('tmp_translationStringsNeeded[arg_originalString] = ', tmp_translationStringsNeeded[arg_originalString]); + console.info('JSON.stringify(tmp_translationStringsNeeded) = ', JSON.stringify(tmp_translationStringsNeeded)); console.info(JSON.parse(getValue('translationStringsNeeded'))); } console.groupEnd(); @@ -382,7 +555,7 @@ function debugLog() console.groupEnd(); } } - +//debugger; function errorLog() { addToLoggerBox("ERROR!\n"); @@ -420,7 +593,7 @@ function docEvaluate(arg_xpath) } // Append zeros to the _input until the _desiredStringLength is reached -function padZeros(arg_input,arg_desiredStringLength) +function padZeros(arg_input, arg_desiredStringLength) { var currentLength = arg_input.toString().length; var output = arg_input; @@ -512,7 +685,7 @@ function ModalDialog(arg_dialogId) { shadowBackdrop = document.createElement('div'); shadowBackdrop.id = 'shadowBackdrop_'+arg_dialogId; - shadowBackdrop.setAttribute('class',"overlay"); + shadowBackdrop.setAttribute('class', "overlay"); shadowBackdrop.innerHTML = ''; @@ -588,16 +761,16 @@ loggerBox.create( //loggerBox.show(); -document.getElementById('loggerBox_Clear').addEventListener('click',function() { +document.getElementById('loggerBox_Clear').addEventListener('click', function() { var tmpLoggerOutput = document.getElementById('loggerBox_Output'); for(var i=0, tmp_loggerOutputLength = tmpLoggerOutput.children.length; i<+=;\s]+/g,''); + return arg_element.textContent.replace(/mk_tt\(.*\)/, '').replace(/[><+=;\s]+/g, ''); } var tmp_currentTd; @@ -1574,11 +1754,10 @@ function getMembershipType() /\w+/); setPref('membershipType', tmp_membershipType_name, { prefType: 'string' }); } - tmp_membershipType_name = getPref('membershipType','unableToFetchNameFromStorage',{ prefType: 'string' }); + tmp_membershipType_name = getPref('membershipType', 'unableToFetchNameFromStorage', { prefType: 'string' }); return tmp_membershipType_name; } -; function getClickValues(arg_memberType) { @@ -1789,7 +1968,7 @@ var userAccount = new function () var preferences = new function() { - this.preferredExtensionLength = getPref('renewalsLength',90, { prefType: 'string' }); + this.preferredExtensionLength = getPref('renewalsLength', 90, { prefType: 'string' }); } var currentUser = new function() @@ -1845,7 +2024,7 @@ var currentUser = new function() // If the accountType info was on the page, the stored copy will have been updated // (else we'll just be grabbing the cached version) - tmp_accountType = getPref('accountType',{numerical:0, verbose:'unknown'},{ prefType: 'JSON' }); + tmp_accountType = getPref('accountType', {numerical:0, verbose:'unknown'}, { prefType: 'JSON' }); this.numerical = tmp_accountType.numerical; this.verbose = tmp_accountType.verbose; @@ -1854,7 +2033,7 @@ var currentUser = new function() this.isUltimate = 6 === tmp_accountType.numerical; this.isStandard = 0 === tmp_accountType.numerical; - this.cost = getPref('accountTypeCost',Neobux.accountDefaults.goldenPackCost[this.verbose], { prefType: 'float' }); + this.cost = getPref('accountTypeCost', Neobux.accountDefaults.goldenPackCost[this.verbose], { prefType: 'float' }); return this; }; @@ -1864,34 +2043,34 @@ var currentUser = new function() this.directReferralClickValue = clickValues[this.accountType.verbose].Fixed.commission.direct; this.numberOfRefs = { - Rented: getPref('numberOfRentedReferrals',defaultSettings.numberOfRefs['Rented'], { prefType: 'integer' }), - Direct: getPref('numberOfDirectReferrals',defaultSettings.numberOfRefs['Direct'], { prefType: 'integer' }) + Rented: getPref('numberOfRentedReferrals', defaultSettings.numberOfRefs['Rented'], { prefType: 'integer' }), + Direct: getPref('numberOfDirectReferrals', defaultSettings.numberOfRefs['Direct'], { prefType: 'integer' }) }; - this.recycleFee = getPref('recycleFee',Neobux.accountDefaults['recycleCost'][this.accountType.verbose], { prefType: 'float' }); + this.recycleFee = getPref('recycleFee', Neobux.accountDefaults['recycleCost'][this.accountType.verbose], { prefType: 'float' }); - this.autopayFee = getPerAutoPayFee(this.accountType,this.numberOfRefs.Rented); + this.autopayFee = getPerAutoPayFee(this.accountType, this.numberOfRefs.Rented); - this.renewalsLength = getPref('renewalsLength',90, { prefType: 'string' }); + this.renewalsLength = getPref('renewalsLength', 90, { prefType: 'string' }); this.renewalFees = getRenewalFees(this.accountType.verbose, this.numberOfRefs.Rented, this.renewalsLength); this.preferences = new function () { -// this.columnPrefixes = getPref(tmp_prefs[i],defaultSettings['columnPrefixes'], { prefType: 'JSON' }); -// this.numeriseDate = getPref(tmp_prefs[i],defaultSettings['numeriseDate'], { prefType: 'JSON' }); -// this.shortFormatTimer = getPref(tmp_prefs[i],defaultSettings['shortFormatTimer'], { prefType: 'JSON' }); -// this.showColumn = getPref(tmp_prefs[i],defaultSettings['showColumn'], { prefType: 'JSON' }); -// this.shrinkColumnContents = getPref(tmp_prefs[i],defaultSettings['shrinkColumnContents'], { prefType: 'JSON' }); -// this.timePeriods = getPref(tmp_prefs[i],defaultSettings['timePeriods'], { prefType: 'JSON' }); +// this.columnPrefixes = getPref(tmp_prefs[i], defaultSettings['columnPrefixes'], { prefType: 'JSON' }); +// this.numeriseDate = getPref(tmp_prefs[i], defaultSettings['numeriseDate'], { prefType: 'JSON' }); +// this.shortFormatTimer = getPref(tmp_prefs[i], defaultSettings['shortFormatTimer'], { prefType: 'JSON' }); +// this.showColumn = getPref(tmp_prefs[i], defaultSettings['showColumn'], { prefType: 'JSON' }); +// this.shrinkColumnContents = getPref(tmp_prefs[i], defaultSettings['shrinkColumnContents'], { prefType: 'JSON' }); +// this.timePeriods = getPref(tmp_prefs[i], defaultSettings['timePeriods'], { prefType: 'JSON' }); //JSON vars - var tmp_prefs = ['columnPrefixes','numeriseDates','shortFormatTimer','showColumn','shrinkColumnContents','timePeriods']; + var tmp_prefs = ['columnPrefixes', 'numeriseDates', 'shortFormatTimer', 'showColumn', 'shrinkColumnContents', 'timePeriods']; for(var i=0; i' + locationToInsertTimeString.innerHTML; + locationToInsertTimeString.innerHTML = '
  Local time: ' + localTime + ' -- Server time: ' + serverTime + '
' + locationToInsertTimeString.innerHTML; locationToInsertTimeString.setAttribute('valign', ''); } @@ -2736,7 +2915,7 @@ function insertLocalServerTime() location.href = "javascript:(" + function () { // Append zeros to the _input until the _desiredStringLength is reached - function padZeros(arg_input,arg_desiredStringLength) + function padZeros(arg_input, arg_desiredStringLength) { var currentLength = arg_input.toString().length; var output = arg_input; @@ -2761,7 +2940,7 @@ function insertLocalServerTime() var chart = new Highcharts.Chart({ chart: { renderTo: 'containerDiv_timer', - margin: [20,20,80,20], + margin: [20, 20, 80, 20], backgroundColor: '#eeeeee' }, title: { @@ -2820,9 +2999,9 @@ function insertLocalServerTime() //todo: look into passing parameters into the () } + ")()"; - document.getElementById('localServerTimeText').addEventListener('click',function localServerTime_onClick() { + document.getElementById('localServerTimeText').addEventListener('click', function localServerTime_onClick() { document.getElementById('containerDiv_timer').style.display = ('none' == document.getElementById('containerDiv_timer').style.display) ? '' : 'none' ; - },false); + }, false); }; @@ -2911,14 +3090,13 @@ function ntl(arg_langString) { // function REFERRAL(arg_refId, arg_referralProperties) { -// console.info('arg_refId = ',arg_refId); +// console.info('arg_refId = ', arg_refId); var tmp_currentDateString = dates_array[0]; - + function createBlankReferral() { var tmp_blankReferral = { referralType: "R", - referralSince: "2001/01/01 00:01", lastSeen: 0, goldenGraphClickData: { }, ultimateClickData: { }, @@ -2940,14 +3118,16 @@ function REFERRAL(arg_refId, arg_referralProperties) }; return tmp_blankReferral; } - + var tmp_CurrentReferral = new createBlankReferral(); tmp_CurrentReferral.referralListingsData = tmp_CurrentReferral.referralListingsData || {}; tmp_CurrentReferral.referralListingsData[tmp_currentDateString] = tmp_CurrentReferral.referralListingsData[tmp_currentDateString] || {}; + tmp_CurrentReferral.lastSeen = dateToday; + var tmp_crToday = tmp_CurrentReferral.referralListingsData[tmp_currentDateString]; - //arg_referralSince, arg_nextPayment, arg_lastClick, arg_totalClicks, arg_average, arg_flagColourId + //arg_referralSince, arg_lastClick, arg_totalClicks, arg_average, arg_flagColourId tmp_CurrentReferral.refId = arg_refId; tmp_crToday.referralSince_raw = arg_referralProperties['referralSince'] || null; tmp_crToday.lastClick_raw = arg_referralProperties['lastClick'] || null; @@ -2957,6 +3137,9 @@ function REFERRAL(arg_refId, arg_referralProperties) //Ultimate mini click graph values tmp_crToday.ultimateClickValues_raw = ('undefined' !== typeof arg_referralProperties['ultimateClickValues']) ? arg_referralProperties['ultimateClickValues'] : null; +// console.info("arg_referralProperties = ", arg_referralProperties); +// console.info("arg_referralProperties['referralType'] = ", arg_referralProperties['referralType']); + if('R' === arg_referralProperties['referralType']) { //Rented referral properties tmp_crToday.flagColour_Id = (0 <= arg_referralProperties['flagColour_Id']) ? arg_referralProperties['flagColour_Id'] : null; @@ -2979,6 +3162,8 @@ function REFERRAL(arg_refId, arg_referralProperties) function flagIdToColour(arg_flagId) { +// console.info('arg_flagId = ', arg_flagId); + if(arg_flagId === null) { return null; } var flagLookup = { 0: 'White', 1: 'Red', @@ -2988,40 +3173,45 @@ function REFERRAL(arg_refId, arg_referralProperties) 5: 'Blue' }; +// console.info('flagLookup[arg_flagId] = ', flagLookup[arg_flagId]); + if("undefined" === typeof tl8) { - return "Unkwown_no_tl8"; + return "Unknown_no_tl8"; } return tl8(flagLookup[arg_flagId] || "Unknown"); } function referralSinceToDateObject(arg_referralSinceString) { -// console.info('arg_referralSinceString = ',arg_referralSinceString); + if(arg_referralSinceString === null) { return null; } +// console.info('arg_referralSinceString = ', arg_referralSinceString); //'2011/04/25 11:20' - var tmp_breakdown = arg_referralSinceString.replace(tl8_today,dates_array[0]).replace(tl8_yesterday,dates_array[1]).match(/([0-9]+)\/([0-9]+)\/([0-9]+) ([0-9]+):([0-9]+)/); + var tmp_breakdown = arg_referralSinceString.replace(tl8_today, dates_array[0]).replace(tl8_yesterday, dates_array[1]).match(/([0-9]+)\/([0-9]+)\/([0-9]+) ([0-9]+):([0-9]+)/); //new Date(year, month, day, hours, minutes, seconds, milliseconds) // NB:: month is zero-indexed thus needs to be reduced by 1 - return new Date(tmp_breakdown[1],tmp_breakdown[2]-1,tmp_breakdown[3],tmp_breakdown[4],tmp_breakdown[5],0,0); + return new Date(tmp_breakdown[1], tmp_breakdown[2]-1, tmp_breakdown[3], tmp_breakdown[4], tmp_breakdown[5], 0, 0); } function lastClickToDateObject(arg_lastClickString) { -// console.info('arg_lastClickString = ',arg_lastClickString); + if(arg_lastClickString === null) { return null; } +// console.info('arg_lastClickString = ', arg_lastClickString); //'Today' or 'Yesterday' or '2011/04/25' var tmp_lastClickBreakdown_regex = /([0-9]+)\/([0-9]+)\/([0-9]+)/ - var tmp_breakdown = arg_lastClickString.replace(tl8_today,dates_array[0]).replace(tl8_yesterday,dates_array[1]).match(tmp_lastClickBreakdown_regex); -// console.info('lastClickToDateObject - arg_lastClickString: ',arg_lastClickString); -// console.info('lastClickToDateObject - tmp_breakdown: ',tmp_breakdown); + var tmp_breakdown = arg_lastClickString.replace(tl8_today, dates_array[0]).replace(tl8_yesterday, dates_array[1]).match(tmp_lastClickBreakdown_regex); +// console.info('lastClickToDateObject - arg_lastClickString: ', arg_lastClickString); +// console.info('lastClickToDateObject - tmp_breakdown: ', tmp_breakdown); //new Date(year, month, day, hours, minutes, seconds, milliseconds) // NB:: month is zero-indexed thus needs to be reduced by 1 - return new Date(tmp_breakdown[1],tmp_breakdown[2]-1,tmp_breakdown[3],0,0,0,0); + return new Date(tmp_breakdown[1], tmp_breakdown[2]-1, tmp_breakdown[3], 0, 0, 0, 0); } function nextPaymentToDateObject(arg_nextPaymentString) { -// console.info('arg_nextPaymentString = ',arg_nextPaymentString); + if(arg_nextPaymentString === null) { return null; } +// console.info('arg_nextPaymentString = ', arg_nextPaymentString); //'171 days and 20:47' // NB: .+ is greedy and tries to include any digits in the hours difference, hence whitespace either side var tmp_breakdown = arg_nextPaymentString.match(/([0-9]+) .+ ([+-]?[0-9]+):([0-9]+)/); @@ -3039,6 +3229,7 @@ function REFERRAL(arg_refId, arg_referralProperties) } function calculateRealAverage(arg_referralSince, arg_totalClicks) { + if(arg_referralSince === null) { return null; } var tmp_timeOwned_days = (dateToday - arg_referralSince) / (1000*60*60*24); //Number of days owned return (arg_totalClicks / tmp_timeOwned_days).toFixed(5) * 1; } @@ -3046,6 +3237,7 @@ function REFERRAL(arg_refId, arg_referralProperties) function dateToDHMObject(arg_date) { + if(arg_date === null) { return null; } var oneSecond = 1000; var oneMinute = oneSecond * 60; var oneHour = oneMinute * 60; @@ -3069,7 +3261,7 @@ function REFERRAL(arg_refId, arg_referralProperties) var diff_secs = Math.floor(remaining_time / oneSecond); remaining_time -= diff_secs * oneSecond; -// debugLog('diff_secs: ',diff_secs,'\nremaining_time: ',remaining_time); +// debugLog('diff_secs: ', diff_secs, '\nremaining_time: ', remaining_time); return { days: diff_days, @@ -3080,6 +3272,7 @@ function REFERRAL(arg_refId, arg_referralProperties) } function dateToDHM(arg_prefix, arg_date, arg_suffix) { + if(arg_date === null) { return null; } var tmp_dhmObject = dateToDHMObject(this.referralSince); return arg_prefix+ @@ -3090,6 +3283,7 @@ function REFERRAL(arg_refId, arg_referralProperties) } function dateToDec(arg_prefix, arg_date, arg_suffix) { + if(arg_date === null) { return null; } var tmp_dhmObject = dateToDHMObject(arg_date); var tmp_age = tmp_dhmObject.days; tmp_age += tmp_dhmObject.hours / 24; @@ -3100,12 +3294,14 @@ function REFERRAL(arg_refId, arg_referralProperties) arg_suffix; } function dateToD(arg_date) { + if(arg_date === null) { return null; } return dateToDHMObject(this.referralSince).days; } function ultimateClickValuesRaw_toStats(arg_ultimateClickValues_raw) { + if(arg_ultimateClickValues_raw === null) { return null; } var minigraph = { 'rawClickData': arg_ultimateClickValues_raw, 'clicks': new Array() @@ -3157,23 +3353,24 @@ function REFERRAL(arg_refId, arg_referralProperties) return minigraph; } - - tmp_crToday.flagColour = flagIdToColour(tmp_crToday.flagColour_Id); -// console.info('tmp_crToday.referralSince_raw = ',tmp_crToday.referralSince_raw); + if('R' === arg_referralProperties['referralType']) { + tmp_crToday.nextPayment = nextPaymentToDateObject(tmp_crToday.nextPayment_raw).toString(); + tmp_crToday.flagColour = flagIdToColour(tmp_crToday.flagColour_Id); + } tmp_crToday.referralSince = referralSinceToDateObject(tmp_crToday.referralSince_raw).toString(); tmp_crToday.lastClick = lastClickToDateObject(tmp_crToday.lastClick_raw).toString(); - tmp_crToday.nextPayment = nextPaymentToDateObject(tmp_crToday.nextPayment_raw).toString(); tmp_crToday.realAverage = calculateRealAverage(tmp_crToday.referralSince, tmp_crToday.totalClicks); tmp_crToday.age_DHMObject = dateToDHMObject(tmp_crToday.referralSince); - tmp_crToday.age_dec = dateToDec('',tmp_crToday.referralSince,'') * 1; - + tmp_crToday.age_dec = dateToDec('', tmp_crToday.referralSince, '') * 1; - tmp_crToday.ultimateClickStats = ultimateClickValuesRaw_toStats(tmp_CurrentReferral.ultimateClickValues_raw); + if('ultimate' === currentUser.accountType.verbose.toLowerCase()) { + tmp_crToday.ultimateClickStats = ultimateClickValuesRaw_toStats(tmp_CurrentReferral.ultimateClickValues_raw); - for(var i=0; i < tmp_crToday.ultimateClickStats.clicks.length; i++){ - tmp_CurrentReferral.ultimateClickData = tmp_CurrentReferral.ultimateClickData || {}; - tmp_CurrentReferral.ultimateClickData[dates_array[i]] = tmp_CurrentReferral.ultimateClickData[dates_array[i]] || {}; - tmp_CurrentReferral.ultimateClickData[dates_array[i]].creditedClicks = tmp_crToday.ultimateClickStats.clicks[i]; + for(var i=0; i < tmp_crToday.ultimateClickStats.clicks.length; i++){ + tmp_CurrentReferral.ultimateClickData = tmp_CurrentReferral.ultimateClickData || {}; + tmp_CurrentReferral.ultimateClickData[dates_array[i]] = tmp_CurrentReferral.ultimateClickData[dates_array[i]] || {}; + tmp_CurrentReferral.ultimateClickData[dates_array[i]].creditedClicks = tmp_crToday.ultimateClickStats.clicks[i]; + } } Object_merge(tmp_CurrentReferral.referralListingsData[tmp_currentDateString], tmp_crToday) @@ -3271,7 +3468,7 @@ var referralListings = new function() // NB: How often a new dateTime is created vs. an existing one is updated will need a setting // Meanwhile, will create a new one on every page load / running of the script -// debugLog('restructureData:\n\n','arg_referralListingsData',arg_referralListingsData); +// debugLog('restructureData:\n\n', 'arg_referralListingsData', arg_referralListingsData); var tmp_referrals = {}; var tmp_currentDateTime = new Date(); @@ -3288,20 +3485,32 @@ var referralListings = new function() pr_ID = ('0' == pr[1]) ? pr[19] : pr[1]; var tmp_objectToPass = { - referralType: (currentPage.pageCode.match(/referralListings_Rented/)) ? "R" : "D", - flagColour_Id: cr[15], - locked: cr[17], - recycleable: cr[16], - nextPayment: ('9' == cr[3]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].nextPayment_raw : cr[3], - cameFrom: cr[2], - isSellable: cr[18], - referralSince: ('9' == cr[2]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].referralSince_raw : cr[2], - lastClick: ('9' == cr[4]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].lastClick_raw : ('N' == cr[4]) ? (('9' == cr[2]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].referralSince_raw : cr[2]) : ('O' == cr[4]) ? dates_array[1] : ('H' == cr[4]) ? dates_array[0]: cr[4], - totalClicks: cr[5], - clickAverage: cr[6], - ultimateClickValues: ('0' == cr[14]) ? '0000000000' : cr[14] - }; - + lastClick: ('9' == cr[4]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].lastClick_raw : ('N' == cr[4]) ? (('9' == cr[2]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].referralSince_raw : cr[2]) : ('O' == cr[4]) ? dates_array[1] : ('H' == cr[4]) ? dates_array[0]: cr[4], + totalClicks: cr[5], + clickAverage: cr[6] + }; + if('ultimate' === currentUser.accountType.verbose.toLowerCase()){ + tmp_objectToPass.ultimateClickValues = ('0' == cr[14]) ? '0000000000' : cr[14]; + } + + if(currentPage.pageCode.match(/referralListings_Rented/)) + { + tmp_objectToPass.referralType = "R"; + tmp_objectToPass.recycleable = cr[16]; + tmp_objectToPass.referralSince = ('9' == cr[2]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].referralSince_raw : cr[2]; + tmp_objectToPass.nextPayment = ('9' == cr[3]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].nextPayment_raw : cr[3]; + tmp_objectToPass.flagColour_Id = cr[15]; + } else if(currentPage.pageCode.match(/referralListings_Direct/)) { + tmp_objectToPass.referralType = "D"; + tmp_objectToPass.referralSince = ('9' == cr[3]) ? tmp_referrals[pr_ID].referralListingsData[dates_array[0]].referralSince_raw : cr[3]; + tmp_objectToPass.cameFrom = cr[2]; + tmp_objectToPass.isSellable = cr[18]; + tmp_objectToPass.locked = cr[17]; + } else { + //Unknown referral type so stop else risk corrupting stored stuff.. + break; + } + // console.info('cr = ', JSON.stringify(cr)); // console.info('tmp_objectToPass = ', JSON.stringify(tmp_objectToPass)); // console.info('tmp_referrals[pr_ID]', JSON.stringify(tmp_referrals[pr_ID])); @@ -3313,14 +3522,14 @@ var referralListings = new function() ); } - debugLog('restructureData:\n\n','tmp_referrals',tmp_referrals); + debugLog('restructureData:\n\n', 'tmp_referrals', tmp_referrals); return tmp_referrals; } this.init = function () { - var storedReferralData = getPref('referrals',{},{ prefType: 'JSON' }); + var storedReferralData = getPref('referrals', {}, { prefType: 'JSON' }); var referralData; var tmp_referralDataFromListingsPage = { mtx:'' }; @@ -3334,7 +3543,7 @@ var referralListings = new function() // Merge the newly fetched data with the stored data referralData = Object_merge(storedReferralData, tmp_referralsOnCurrentPage); - setPref('referrals',referralData,{ prefType: 'JSON' }); + setPref('referrals', referralData, { prefType: 'JSON' }); } } }; @@ -3487,7 +3696,7 @@ var logo = addClickEvent: function(arg_clickFunction) { if(document.getElementById('spanghurtLogo')) { - document.getElementById('spanghurtLogo').addEventListener('click',function() { arg_clickFunction(); },false); + document.getElementById('spanghurtLogo').addEventListener('click', function() { arg_clickFunction(); }, false); } }, @@ -3681,7 +3890,15 @@ var chartDataBars = new function() var tmp_dataBarDataToOutput; var tmp_graphLength; - function dataToOutputToDataBar(arg_dataSet,arg_dataBarIntervals,arg_dataBarTitle,arg_fieldToShow,arg_daysPrefix,arg_daysSuffix,arg_numberOfFixedDecimalPoints) + function dataToOutputToDataBar( + arg_dataSet, + arg_dataBarIntervals, + arg_dataBarTitle, + arg_fieldToShow, + arg_daysPrefix, + arg_daysSuffix, + arg_numberOfFixedDecimalPoints + ) { tmp_dataBarDataToOutput = []; @@ -3698,12 +3915,12 @@ var chartDataBars = new function() return arg_dataBarTitle+ tmp_dataBarDataToOutput.join(' '); } catch(e) { - errorLog('ERROR! \n',e); + errorLog('ERROR! \n', e); return 'error in calculations'; } } - function createDataBarRow(arg_graphId,argBarCode,arg_dataBarColumns,arg_customDataBarCss) + function createDataBarRow(arg_graphId, argBarCode, arg_dataBarColumns, arg_customDataBarCss) { var elmt_bar = document.createElement("tr"); @@ -3729,7 +3946,7 @@ var chartDataBars = new function() tmp_graphLength = graphLengthLookup[this.graphsOnCurrentPage[i]]; tmp_dataSet = this.getDataBarData(this.graphsOnCurrentPage[i]); - var tmp_dateAdjuster = friendlyNameLookup[this.graphsOnCurrentPage[i]].match(/extensions_([0-9]+)To([0-9]+)/) || [-1,0]; + var tmp_dateAdjuster = friendlyNameLookup[this.graphsOnCurrentPage[i]].match(/extensions_([0-9]+)To([0-9]+)/) || [-1, 0]; var tmp_counter = 0; var graphBarsContainerId = this.graphsOnCurrentPage[i]+'_containers'; @@ -3756,21 +3973,21 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'sum', - [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','sum','(',') ',0)], + [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'sum', '(', ') ', 0)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Avg. Clicks: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avg','(',') ',3)], + [tl8('Avg. Clicks: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avg', '(', ') ', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avgIncome', - [tl8('Avg. Income: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avgIncome','(',') $',3)], + [tl8('Avg. Income: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avgIncome', '(', ') $', 3)], '' ) ); @@ -3779,42 +3996,42 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'sum', - [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','sum','(',') $',3)], + [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'sum', '(', ') $', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Avg. Expense: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avg','(',') $',3)], + [tl8('Avg. Expense: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avg', '(', ') $', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avgIncome', - [tl8('Avg. Renewals (#): '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','numberOfRenewals_actualAvg','(',') ',2)], + [tl8('Avg. Renewals (#): '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'numberOfRenewals_actualAvg', '(', ') ', 2)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avgIncome', - [tl8('Ideal Avg. Renewals (#): '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','idealNumberOfRenewals_avg','(',') ',2)], + [tl8('Ideal Avg. Renewals (#): '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'idealNumberOfRenewals_avg', '(', ') ', 2)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avgIncome', - [tl8('Ideal Avg. Expense ($): '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','idealRenewalsCost_avg','(',') $',3)], + [tl8('Ideal Avg. Expense ($): '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'idealRenewalsCost_avg', '(', ') $', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avgIncome', - [tl8('Ideal Sum ($): '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','idealRenewalsCost_sum','(',') $',3)], + [tl8('Ideal Sum ($): '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'idealRenewalsCost_sum', '(', ') $', 3)], '' ) ); @@ -3831,14 +4048,14 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'sum', - [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','sum','(',') $',3)], + [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'sum', '(', ') $', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Avg. Expense: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avg','(',') $',3)], + [tl8('Avg. Expense: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avg', '(', ') $', 3)], '' ) ); @@ -3851,7 +4068,7 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Avg. #Recycles: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avgRecycles','(',') ',3)], + [tl8('Avg. #Recycles: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avgRecycles', '(', ') ', 3)], '' ) ); @@ -3860,14 +4077,14 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'sum', - [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','sum','(',') $',3)], + [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'sum', '(', ') $', 3)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Avg. Transfer: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avg','(',') $',3)], + [tl8('Avg. Transfer: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avg', '(', ') $', 3)], '' ) ); @@ -3876,14 +4093,14 @@ var chartDataBars = new function() graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'sum', - [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','sum','(',') ',1)], + [tl8('Sum: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'sum', '(', ') ', 1)], '' ) ); graphBarTable.appendChild( createDataBarRow(this.graphsOnCurrentPage[i], 'avg', - [tl8('Average Free Recycles: '), dataToOutputToDataBar(tmp_dataSet,dataBarIntervals[tmp_graphLength],'','avg','(',') ',1)], + [tl8('Average Free Recycles: '), dataToOutputToDataBar(tmp_dataSet, dataBarIntervals[tmp_graphLength], '', 'avg', '(', ') ', 1)], '' ) ); @@ -3936,7 +4153,7 @@ var exportTabs = new function() "#alertBox h1 {"+ "margin: 0;"+ - "font: bold 0.9em verdana,arial;"+ + "font: bold 0.9em verdana, arial;"+ "background-color: #78919B;"+ "color: #FFF;"+ "border-bottom: 1px solid #000;"+ @@ -3944,14 +4161,14 @@ var exportTabs = new function() " }"+ "#alertBox p {"+ - "font-family: verdana,arial;"+ + "font-family: verdana, arial;"+ "padding: 10px;"+ "margin: 10px;"+ "height: auto;"+ " }"+ "#alertBox textarea {"+ - "font-family: monospace,courier new,verdana,arial;"+ + "font-family: monospace, courier new, verdana, arial;"+ "font-size: x-small;"+ "margin: 15px;"+ "margin-top: 0px;"+ @@ -3966,7 +4183,7 @@ var exportTabs = new function() "padding: 3px;"+ "border: 2px solid #000;"+ "width: 70px;"+ - "font: 0.7em verdana,arial;"+ + "font: 0.7em verdana, arial;"+ "text-transform: uppercase;"+ "text-align: center;"+ "color: #FFF;"+ @@ -4027,7 +4244,7 @@ var exportTabs = new function() exportTab.show(); - // createExportDialog(messageHeader,textareaContents,'Exporting to '+arg_exportTabText+'..','Close',textareaContentsReverse,event); + // createExportDialog(messageHeader, textareaContents, $1'Exporting to '+arg_exportTabText+'..', 'Close', textareaContentsReverse, event); }, false); @@ -4094,8 +4311,8 @@ var exportTabs = new function() } catch(e) { errorLog("ERROR!\n#" + - 'tmp_currentGraphId = ',tmp_currentGraphId,"\n" + - "Error details: \n",e); + 'tmp_currentGraphId = ', tmp_currentGraphId, "\n" + + "Error details: \n", e); return 'Error retrieving data'; } } @@ -4116,13 +4333,13 @@ var exportTabs = new function() //// Add Export Links // Create and insert wrapper for export 'tabs' var exportTabsWrapper = document.createElement('div'); - exportTabsWrapper.setAttribute('style','bottom:-1px; margin-left:17px; margin-top:4px; position:relative; text-align:left;'); + exportTabsWrapper.setAttribute('style', 'bottom:-1px; margin-left:17px; margin-top:4px; position:relative; text-align:left;'); exportTabsWrapper.id = 'exportTabsWrapper_'+tmp_currentGraphId; exportTabsWrapper.innerHTML = ' '; - referenceNode.parentNode.insertBefore(exportTabsWrapper,referenceNode); + referenceNode.parentNode.insertBefore(exportTabsWrapper, referenceNode); - var exportTabTypes = ['CSV','TSV','Text']; + var exportTabTypes = ['CSV', 'TSV', 'Text']; for(var exportTabTypes_index = 0; exportTabTypes_index < exportTabTypes.length; exportTabTypes_index++) { var exportTabElement = EXPORT_TAB( @@ -4144,7 +4361,7 @@ var exportTabs = new function() } } catch(e) { - errorLog("ERROR!\nCannot add export tabs.\n\nFull error message:\n\n",e) + errorLog("ERROR!\nCannot add export tabs.\n\nFull error message:\n\n", e) } } } @@ -4218,22 +4435,22 @@ function mk_ch(x, y, o, w0, w, O, L, m, mn, p) plotBands: [{ from: 0, to: pn[0], - color: 'rgba(170,170,170,.3)' + color: 'rgba(170,170,170, 0.3)' }, { from: pn[0], to: pn[1], - color: 'rgba(255,101,79,.3)' + color: 'rgba(255,101,79, 0.3)' }, { from: pn[1], to: pn[2], - color: 'rgba(246,189,15,.3)' + color: 'rgba(246,189,15, 0.3)' }, { from: pn[2], to: pn[3], - color: 'rgba(139,186,0,.3)' + color: 'rgba(139,186,0, 0.3)' }] }, yAxis: { @@ -4254,17 +4471,17 @@ function mk_ch(x, y, o, w0, w, O, L, m, mn, p) plotBands: [{ from: 0, to: n[0], - color: 'rgba(255,101,79,.3)' + color: 'rgba(255,101,79, 0.3)' }, { from: n[0], to: n[1], - color: 'rgba(246,189,15,.3)' + color: 'rgba(246,189,15, 0.3)' }, { from: n[1], to: n[2], - color: 'rgba(139,186,0,.3)' + color: 'rgba(139,186,0, 0.3)' }] }, tooltip: { @@ -4355,7 +4572,7 @@ function mk_ch2(_containerID, _graphTitle, _x_axisCategories, _tooltipPrefix, _t style: { margin: "10px 0 0 10px", textAlign: "center", - font: "normal 12px Verdana,sans-serif" + font: "normal 12px Verdana, sans-serif" } }, xAxis: { @@ -4371,22 +4588,22 @@ function mk_ch2(_containerID, _graphTitle, _x_axisCategories, _tooltipPrefix, _t plotBands: [{ from: 0, to: pn[0], - color: "rgba(170,170,170,.25)" + color: "rgba(170,170,170, 0.25)" }, { from: pn[0], to: pn[1], - color: "rgba(255,101,79,.25)" + color: "rgba(255,101,79, 0.25)" }, { from: pn[1], to: pn[2], - color: "rgba(246,189,15,.25)" + color: "rgba(246,189,15, 0.25)" }, { from: pn[2], to: pn[3], - color: "rgba(139,186,0,.25)" + color: "rgba(139,186,0, 0.25)" }] }, yAxis: { @@ -4407,17 +4624,17 @@ function mk_ch2(_containerID, _graphTitle, _x_axisCategories, _tooltipPrefix, _t plotBands: [{ from: 0, to: n[0], - color: "rgba(255,101,79,.25)" + color: "rgba(255,101,79, 0.25)" }, { from: n[0], to: n[1], - color: "rgba(246,189,15,.25)" + color: "rgba(246,189,15, 0.25)" }, { from: n[1], to: n[2], - color: "rgba(139,186,0,.25)" + color: "rgba(139,186,0, 0.25)" }] }, tooltip: { @@ -4434,7 +4651,7 @@ function mk_ch2(_containerID, _graphTitle, _x_axisCategories, _tooltipPrefix, _t bottom: "5px", right: "5px", top: "auto", - font: "normal 12px Verdana,sans-serif" + font: "normal 12px Verdana, sans-serif" } }, plotOptions: { @@ -4577,8 +4794,8 @@ function insertAdCounterBox(arg_dateIndex, arg_adCounts, arg_adCountChange_curre elmnt_totalsContainer.id = 'clickTotalsContainer'; elmnt_totalsContainer.setAttribute('style', 'position: fixed; bottom: 2em; right: 2em; width: 150px; min-height: 10em; background-color: white; border: 1px solid black; font-size:x-small !important; padding: 1em 1em; opacity: 0.5;'); - elmnt_totalsContainer.setAttribute('onmouseover','document.getElementById("clickTotalsContainer").style.opacity = "1"; '); - elmnt_totalsContainer.setAttribute('onmouseout','document.getElementById("clickTotalsContainer").style.opacity = "0.5";'); + elmnt_totalsContainer.setAttribute('onmouseover', 'document.getElementById("clickTotalsContainer").style.opacity = "1"; '); + elmnt_totalsContainer.setAttribute('onmouseout', 'document.getElementById("clickTotalsContainer").style.opacity = "0.5";'); GM_addStyle(".adCountIncrementButton { width: 2.5em; text-align:center; font-size: xx-small; }"+ ".adCountDecrementButton { width: 2.5em; text-align:center; font-size: xx-small; }"+ @@ -4693,13 +4910,13 @@ function insertAdCounterBox(arg_dateIndex, arg_adCounts, arg_adCountChange_curre /* Add handlers for changing the currently selected date */ // NB: The date index is in reverse order (ie, n days into the past) thus incrementing this index equates to going an increased number of days into the past - document.getElementById('date_decrementButton').addEventListener('click',function () { + document.getElementById('date_decrementButton').addEventListener('click', function () { insertAdCounterBox(arg_dateIndex + 1, arg_adCounts, arg_adCountChange_currentPageview); - },false); + }, false); - document.getElementById('date_incrementButton').addEventListener('click',function () { + document.getElementById('date_incrementButton').addEventListener('click', function () { insertAdCounterBox(arg_dateIndex - 1, arg_adCounts, arg_adCountChange_currentPageview); - },false); + }, false); /* Add handlers for changing the ad counts */ @@ -4722,17 +4939,17 @@ function insertAdCounterBox(arg_dateIndex, arg_adCounts, arg_adCountChange_curre tmp_adCountChange[dates_array[arg_dateIndex]][arg_adType] = parseInt(tmp_adCountChange[dates_array[arg_dateIndex]][arg_adType]) - 1; } - document.getElementById(arg_adType+'AdCount_incrementButton').addEventListener('click',function () + document.getElementById(arg_adType+'AdCount_incrementButton').addEventListener('click', function () { - debugLog('tmp_adCounts (on increment click) = ',JSON.stringify(tmp_adCounts)); - debugLog('tmp_adCountChange (on increment click) = ',JSON.stringify(tmp_adCountChange)); + debugLog('tmp_adCounts (on increment click) = ', JSON.stringify(tmp_adCounts)); + debugLog('tmp_adCountChange (on increment click) = ', JSON.stringify(tmp_adCountChange)); insertAdCounterBox(arg_dateIndex, tmp_adCounts, tmp_adCountChange); // Workaround for GM access checks/violations // http://wiki.greasespot.net/Greasemonkey_access_violation setTimeout(function() { - setPref('ownAdCountTally',tmp_adCounts, { prefType: 'JSON' }); + setPref('ownAdCountTally', tmp_adCounts, { prefType: 'JSON' }); }, 0); - },false); + }, false); } function addDecrementListener(arg_adType, arg_oldAdCounts, arg_tmp_adCountChange_currentPageview) @@ -4753,17 +4970,17 @@ function insertAdCounterBox(arg_dateIndex, arg_adCounts, arg_adCountChange_curre tmp_adCountChange[dates_array[arg_dateIndex]][arg_adType] = parseInt(tmp_adCountChange[dates_array[arg_dateIndex]][arg_adType]) + 1; } - document.getElementById(arg_adType+'AdCount_decrementButton').addEventListener('click',function () + document.getElementById(arg_adType+'AdCount_decrementButton').addEventListener('click', function () { - debugLog('tmp_adCounts (on increment click) = ',JSON.stringify(tmp_adCounts)); - debugLog('tmp_adCountChange (on increment click) = ',JSON.stringify(tmp_adCountChange)); + debugLog('tmp_adCounts (on increment click) = ', JSON.stringify(tmp_adCounts)); + debugLog('tmp_adCountChange (on increment click) = ', JSON.stringify(tmp_adCountChange)); insertAdCounterBox(arg_dateIndex, tmp_adCounts, tmp_adCountChange); // Workaround for GM access checks/violations // http://wiki.greasespot.net/Greasemonkey_access_violation setTimeout(function() { - setPref('ownAdCountTally',tmp_adCounts, { prefType: 'JSON' }); + setPref('ownAdCountTally', tmp_adCounts, { prefType: 'JSON' }); }, 0); - },false); + }, false); } // Loop through the different ad types and call the function that adds the click events for the increment and decrement buttons @@ -4778,7 +4995,7 @@ function insertAdCounterBox(arg_dateIndex, arg_adCounts, arg_adCountChange_curre function addClickStatsToGoldenGraph() { - function mk_ch_ref(x, o, w0, w, O, L, m) + function mk_ch_ref(x, o, w0, w, O, L, m, arg_refName) { console.info(arguments); if (0 == m) @@ -4813,19 +5030,22 @@ function addClickStatsToGoldenGraph() { var sum = []; var avg = []; + var tmp_referralsData = getPref('referrals', {}, { prefType: 'JSON' }); + var tmp_refId = arg_refName.match(/\d+/); + tmp_referralsData[tmp_refId] = tmp_referralsData[tmp_refId] || {}; + tmp_referralsData[tmp_refId].goldenGraphClickData = tmp_referralsData[tmp_refId].goldenGraphClickData || {}; for (var i = 0; i < O[0].data.length; i++) { disp_clicks += ' ' + O[0].data[i]; clicks[i] = O[0].data[i]; + tmp_referralsData[tmp_refId].goldenGraphClickData[dates_array[i]] = clicks[i]; } - for (var i = O[0].data.length - 1; 0 <= i; i--) - { + console.info(JSON.stringify(tmp_referralsData[tmp_refId])); + + for (var i = O[0].data.length - 1; 0 <= i; i--) { sum[i] = ('undefined' !== typeof sum[i+1]) ? clicks[i] + sum[i+1] : clicks[i]; avg[i] = (sum[i] / (O[0].data.length - i)).toFixed(1); - -// console.info('i = '+i, '(O[0].data.length - i) = '+((O[0].data.length - i)+1), 'clicks[i] = '+clicks[i], 'sum[i+1] = '+sum[i+1], 'sum[i] = '+sum[i]); -// console.info('clicks: ',clicks,'\n','sum: ',sum,'\n','avg: ',avg); } newElmnt.innerHTML = '' + @@ -4848,12 +5068,36 @@ function addClickStatsToGoldenGraph() { } + function ved_cht(o, p) { + out = eval(p); + var lg = out.length == 3 ? 1 : 0; + if (out.length == 3) { + tmp = [{name: "Clicks", data: out[1]}, {name: "Credited clicks", data: out[2]}]; + } else { + tmp = [{name: "Credited clicks", data: out[1]}]; + } + d("chtdiv_t").innerHTML = "Click statistics for: " + out[0] + ""; + mk_ch_ref("chtdiv", + [dates_array[9], dates_array[8], dates_array[7], dates_array[6], dates_array[5], dates_array[4], dates_array[3], dates_array[2], dates_array[1], dates_array[0]], + "", + "", + tmp, + lg, + 0, + out[0]); + } + GM_addStyle(".refGraphDatabar { border-collapse: collapse; }" + ".refGraphDatabar tbody tr td { font-size: x-small; padding:0 1px; border: 1px solid black; }"); -// console.info('mk_ch_ref.toString() : ',mk_ch_ref.toString()); +// console.info('mk_ch_ref.toString() : ', mk_ch_ref.toString()); +// var script = document.createElement("script"); +// script.setAttribute('type', 'text/javascript'); +// script.text = ved_cht.toString(); +// document.body.appendChild(script); + var script = document.createElement("script"); - script.setAttribute('type','text/javascript'); + script.setAttribute('type', 'text/javascript'); script.text = mk_ch_ref.toString(); document.body.appendChild(script); @@ -4861,7 +5105,7 @@ function addClickStatsToGoldenGraph() { var referralListings_columns = new function() { - function addColumn(arg_row,arg_columnText,arg_colId,arg_customCSS) + function addColumn(arg_row, arg_columnText, arg_colId, arg_customCSS) { var tmp_newColumn; @@ -4897,7 +5141,7 @@ var referralListings_columns = new function() var now = new Date(); -// debugLog('now: ',now,'\nother date: ',arg_date); +// debugLog('now: ', now, '\nother date: ', arg_date); var t_diff = new Date(arg_date) - now; // debugLog('t_diff = '+t_diff); @@ -4906,27 +5150,27 @@ var referralListings_columns = new function() var future = (0 < t_diff); var remaining_time = (0 < t_diff) ? t_diff : t_diff * -1; -// debugLog('remaining_time: ',remaining_time); +// debugLog('remaining_time: ', remaining_time); var diff_days = Math.floor(remaining_time / oneDay); remaining_time -= diff_days * oneDay; -// debugLog('diff_days: ',diff_days,'\nremaining_time: ',remaining_time); +// debugLog('diff_days: ', diff_days, '\nremaining_time: ', remaining_time); var diff_hrs = Math.floor(remaining_time / oneHour); remaining_time -= diff_hrs * oneHour; -// debugLog('diff_hrs: ',diff_hrs,'\nremaining_time: ',remaining_time); +// debugLog('diff_hrs: ', diff_hrs, '\nremaining_time: ', remaining_time); var diff_mins = Math.floor(remaining_time / oneMinute); remaining_time -= diff_mins * oneMinute; -// debugLog('diff_mins: ',diff_mins,'\nremaining_time: ',remaining_time); +// debugLog('diff_mins: ', diff_mins, '\nremaining_time: ', remaining_time); var diff_secs = Math.floor(remaining_time / oneSecond); remaining_time -= diff_secs * oneSecond; -// debugLog('diff_secs: ',diff_secs,'\nremaining_time: ',remaining_time); +// debugLog('diff_secs: ', diff_secs, '\nremaining_time: ', remaining_time); return '['+ diff_days+'d'+ @@ -4963,7 +5207,7 @@ var referralListings_columns = new function() function nextPaymentStringToDate(arg_nextPaymentString) { arg_nextPaymentString = arg_nextPaymentString.toString(); -// debugLog('nextPaymentStringToDate: \n','arg_nextPaymentString : ',arg_nextPaymentString); +// debugLog('nextPaymentStringToDate: \n', 'arg_nextPaymentString : ', arg_nextPaymentString); var onesec = 1000; var onemin = onesec * 60; var onehr = onemin * 60; @@ -5010,16 +5254,19 @@ var referralListings_columns = new function() } var columns = { - totalIncomeCol: new COLUMN('new', '$', '', 'Total Income', [],[]), - totalExpensesCol: new COLUMN('new', '$', '', 'Total Expenses', [],[]), - netIncome: new COLUMN('new', '$', '', 'Net Income', [],[]), - clickValues: new COLUMN('new', '', '', 'Ultimate Click Values', ['Ultimate'],[]), - refSince_DHM: new COLUMN('new', '', '', 'D/H/M Ref Since', [],[]), - nextPayment_DHM: new COLUMN('new', '', '', 'D/H/M Next Payment', [],[]), - lastClick_D: new COLUMN('new', '', '', 'D Last Click', [],[]), - textifyFlag: new COLUMN('new', '', '', 'Flag Colour', [],[]) + totalIncomeCol: new COLUMN('new', '$', '', 'Total Income', [], []), + totalExpensesCol: new COLUMN('new', '$', '', 'Total Expenses', [], []), + netIncome: new COLUMN('new', '$', '', 'Net Income', [], []), + clickValues: new COLUMN('new', '', '', 'Ultimate Click Values', ['Ultimate'], []), + refSince_DHM: new COLUMN('new', '', '', 'D/H/M Ref Since', [], []), + nextPayment_DHM: new COLUMN('new', '', '', 'D/H/M Next Payment', [], []), + lastClick_D: new COLUMN('new', '', '', 'D Last Click', [], []) }; + if(currentPage.pageCode.match(/referralListings_Rented/i)){ + columns.textifyFlag = new COLUMN('new', '', '', 'Flag Colour', [], []); + } + //Add header row columns for(var columnName in columns) { if(columns.hasOwnProperty(columnName)) @@ -5056,7 +5303,7 @@ var referralListings_columns = new function() var tmp_colspans = document.querySelectorAll('div#tblprp td[colspan]'); for(var i=1; i 0) ? tmp_currentID : tmp_currentRow.children[colIndexes.refID].textContent; + + console.info('tmp_currentID = ', tmp_currentID); + tmp_currentRow.id = tmp_currentID; - tmp_currentRow.setAttribute('class',tmp_currentRow.getAttribute('class') + ' referralRow'); + tmp_currentRow.setAttribute('class', tmp_currentRow.getAttribute('class') + ' referralRow'); incomeExpenses[tmp_currentID] = incomeExpenses[tmp_currentID] || {}; @@ -5133,7 +5385,7 @@ var referralListings_columns = new function() tmp_value = dateToD(new Date(tmp_referralsData[tmp_currentID].referralListingsData[dates_array[0]].lastClick)); break; case 'textifyFlag': - tmp_value = tmp_referralsData[tmp_currentID].referralListingsData[dates_array[0]].flagColour.split('')[0] || "Unknown".split('')[0]; + tmp_value = tmp_referralsData[tmp_currentID].referralListingsData[dates_array[0]].flagColour.split('')[0] || "Unknown".split('')[0] || 'E'; break; } @@ -5149,7 +5401,7 @@ var referralListings_columns = new function() ); } catch(e) { - errorLog('error with new column - '+columnName+' ::\n',e); + errorLog('error with new column - '+columnName+' ::\n', e); } break; case 'append': @@ -5202,7 +5454,7 @@ function insertSidebar() // [another time period....], // [etc..] // ] - var sidebarTimePeriods = [[0,0],[1,1],[0,6],[1,6],[0,9],[1,9]]; + var sidebarTimePeriods = [[0,0], [1,1], [0,6], [1,6], [0,9], [1,9]]; var tmp_dataSet = getPref('accountCache', {}, { prefType: 'JSON' }); var sidebarData = {}; @@ -5260,7 +5512,7 @@ function insertSidebar() /*Show if user has referrals*/ function SIR(arg_toDisplay) { return (0 < currentUser.numberOfRefs.Direct || 0 < currentUser.numberOfRefs.Rented) ? arg_toDisplay : ''; } - function outputIfExists(arg_varToOutput,arg_textToDisplayOtherwise) + function outputIfExists(arg_varToOutput, arg_textToDisplayOtherwise) { try { return arg_varToOutput; } catch(e) { return arg_textToDisplayOtherwise; } @@ -5361,7 +5613,7 @@ function insertSidebar() } } - debugLog('sidebarData = ',sidebarData); + debugLog('sidebarData = ', sidebarData); var header = tl8("Totals between ") + startDay + tl8(" Days Ago and ") + (endDay+1) + tl8(" Days Ago"); @@ -5444,18 +5696,18 @@ function insertSidebar() // // *** INSERT STATISTICS SUMMARY INTO PAGE *** //// var wrapperTD = document.createElement('td'); - wrapperTD.setAttribute('valign','top'); + wrapperTD.setAttribute('valign', 'top'); wrapperTD.appendChild(sidebarContainer); - var statsSidebarPosition = getPref('statsSidebarPosition','right',{ prefType: 'text' }); - debugLog('statsSidebarPosition = ',statsSidebarPosition,'\n','locationToInsertSidebar[statsSidebarPosition] = ',locationToInsertSidebar[statsSidebarPosition]); + var statsSidebarPosition = getPref('statsSidebarPosition', 'right', { prefType: 'string' }); + debugLog('statsSidebarPosition = ', statsSidebarPosition, '\n', 'locationToInsertSidebar[statsSidebarPosition] = ', locationToInsertSidebar[statsSidebarPosition]); if('right' === statsSidebarPosition) { -// sidebarContainer.setAttribute('onmouseover','document.getElementById("sidebarContainer").style.opacity = "1";'); -// sidebarContainer.setAttribute('onmouseout','document.getElementById("sidebarContainer").style.opacity = "0.5";'); +// sidebarContainer.setAttribute('onmouseover', 'document.getElementById("sidebarContainer").style.opacity = "1";'); +// sidebarContainer.setAttribute('onmouseout', 'document.getElementById("sidebarContainer").style.opacity = "0.5";'); } - sidebarContainer.setAttribute('class',statsSidebarPosition+'Side'); + sidebarContainer.setAttribute('class', statsSidebarPosition+'Side'); locationToInsertSidebar[statsSidebarPosition].appendChild(wrapperTD); @@ -5483,7 +5735,7 @@ if(currentPage.pageCode.match(/referralListings/i)) } catch(e) { console.info("ERROR!\n\n referralListings.init() failed\n\n"+e); - alert("ERROR!\n\n referralListings.init() failed\n\n"+e); +// alert("ERROR!\n\n referralListings.init() failed\n\n"+e); throw e; } @@ -5513,10 +5765,19 @@ if(currentPage.pageCode.match(/referralListings/i)) var colCount = document.querySelectorAll('div#tblprp td[colspan]')[1].getAttribute('colspan'); - var colIndexes = { - refID: 3, - refSince: 5 - }; + var colIndexes = {} + + if(currentPage.pageCode.match(/referralListings_Rented/i)){ + colIndexes = { + refID: 3, + refSince: 5 + }; + }else{ + colIndexes = { + refID: 1, + refSince: 4 + }; + } var tmp_referralsData = getPref('referrals', {}, { prefType: 'JSON' }); debugLog(tmp_referralsData); @@ -5539,7 +5800,7 @@ if(currentPage.pageCode.match(/viewAdvertisementsPage/i)) catch(e) { console.info("ERROR!\n\n insertAdCounterBox(0, adCountData, {}); failed\n\n"+e); - alert("ERROR!\n\n insertAdCounterBox(0, adCountData, {}); failed\n\n"+e); +// alert("ERROR!\n\n insertAdCounterBox(0, adCountData, {}); failed\n\n"+e); } } @@ -5552,7 +5813,7 @@ if(currentPage.pageCode.match(/accSummary/i) || currentPage.pageCode.match(/refe } catch(e) { console.info("ERROR!\n\n chartDataBars.init(); failed\n\n"+e); - alert("ERROR!\n\n chartDataBars.init(); failed\n\n"+e); +// alert("ERROR!\n\n chartDataBars.init(); failed\n\n"+e); throw e; } try { @@ -5560,7 +5821,7 @@ if(currentPage.pageCode.match(/accSummary/i) || currentPage.pageCode.match(/refe } catch(e) { console.info("ERROR!\n\n exportTabs.init(); failed\n\n"+e); - alert("ERROR!\n\n exportTabs.init(); failed\n\n"+e); +// alert("ERROR!\n\n exportTabs.init(); failed\n\n"+e); throw e; } @@ -5574,7 +5835,7 @@ if(currentPage.pageCode.match(/referralStatistics/)) } catch(e) { console.info("ERROR!\n\n insertSidebar(); failed\n\n"+e); - alert("ERROR!\n\n insertSidebar(); failed\n\n"+e); +// alert("ERROR!\n\n insertSidebar(); failed\n\n"+e); } } @@ -5586,21 +5847,21 @@ if (!currentPage.pageCode.match(tmp_iframePages) && (top === self)) } catch(e) { console.info("ERROR!\n\n insertLocalServerTime(); failed\n\n"+e); - alert("ERROR!\n\n insertLocalServerTime(); failed\n\n"+e); +// alert("ERROR!\n\n insertLocalServerTime(); failed\n\n"+e); } try { logo.init(); } catch(e) { console.info("ERROR!\n\n logo.init(); failed\n\n"+e); - alert("ERROR!\n\n logo.init(); failed\n\n"+e); +// alert("ERROR!\n\n logo.init(); failed\n\n"+e); } try { widenPages.generic(); } catch(e) { console.info("ERROR!\n\n widenPages.generic(); failed\n\n"+e); - alert("ERROR!\n\n widenPages.generic(); failed\n\n"+e); +// alert("ERROR!\n\n widenPages.generic(); failed\n\n"+e); } } @@ -5612,4 +5873,5 @@ if(0 < tl8_counter) { } -debugLog(getPref('neobuxLanguageCode', 'EN', { prefType: 'string' })); \ No newline at end of file +debugLog(getPref('neobuxLanguageCode', 'EN', { prefType: 'string' })); +