// use this to isolate the scope (function () { if(!$axure.document.configuration.showConsole) { return; } $(document).ready(function () { $axure.player.createPluginHost({ id: 'debugHost', context: 'inspect', title: 'Console', gid: 3 }); generateDebug(); $('#variablesClearLink').click(clearvars_click); $('#traceClear').click(cleartrace_click); $('#traceToggle').click(stoptrace_click); $('#traceStart').click(starttrace_click); $('#traceClear').hide(); $('#traceToggle').hide(); $('#closeConsole').click(close); var currentStack= []; var finishedStack = []; $axure.messageCenter.addMessageListener(function (message, data) { if(message == 'axCompositeEventMessage') { for(var i = 0; i < data.length; i++) { processMessages(data[i].message, data[i].data); } } else processMessages(message, data); }); var processMessages = function(message, data) { if(message == 'globalVariableValues') { $('#variablesDiv').empty(); for(var key in data) { var value = data[key] == '' ? '(blank)' : data[key]; $('#variablesDiv').append('
' + key + '
' + value + '
'); } } else if(message == 'axEvent') { var addToStack = "
"; addToStack += "
"; addToStack += "
" + new Date().toLocaleTimeString() + "
"; addToStack += "
" + data.event.description + ":
"; addToStack += "
" + data.label + " (" + data.type + ")
"; addToStack += "
"; currentStack.push(addToStack); } else if (message == 'axEventComplete') { currentStack[currentStack.length - 1] += "
"; finishedStack.push(currentStack.pop()); if(currentStack.length == 0) { $('#traceEmptyState').hide(); $('#traceClear').show(); $('#traceToggle').show(); for(var i = finishedStack.length - 1; i >= 0; i--) { if($('#traceDiv').children().length > 99) $('#traceDiv').children().last().remove(); $('#traceDiv').prepend(finishedStack[i]); } finishedStack = []; } } else if (message == 'axCase') { //var addToStack = "
"; var addToStack = "
"; addToStack += "
" + data.item + "
"; if (data.description) { addToStack += "
" + data.description + "
" }; addToStack += "
"; currentStack[currentStack.length - 1] += addToStack; } else if (message == 'axAction') { var addToStack = "
"; addToStack += "
" + data.name + "
"; //addToStack += "
" + data.item + "
"; //if (data.description) { addToStack += "
" + data.description + "
" }; addToStack += "
"; currentStack[currentStack.length - 1] += addToStack; } else if (message == 'axInfo') { var addToStack = "
"; addToStack += "
" + data.item + "
"; if (data.description) { addToStack += "
" + data.description + "
" }; addToStack += "
"; currentStack[currentStack.length - 1] += addToStack; } } // bind to the page load $axure.page.bind('load.debug', function () { var traceStr = $axure.player.getHashStringVar(TRACE_VAR_NAME); if (traceStr.length > 0) $axure.messageCenter.setState("isTracing", true); else $axure.messageCenter.setState("isTracing", false); $axure.messageCenter.postMessage('getGlobalVariables', ''); return false; }); function clearvars_click(event) { $axure.messageCenter.postMessage('resetGlobalVariables', ''); } function close() { $axure.player.pluginClose("debugHost"); } function cleartrace_click(event) { $('#traceDiv').html(''); } function starttrace_click(event) { $axure.messageCenter.setState("isTracing", true); //$('#traceDiv').html(''); $('#traceEmptyState').hide(); $('#traceClear').show(); $('#traceToggle').text('Stop Trace'); $('#traceToggle').off("click"); $('#traceToggle').click(stoptrace_click); $('#traceToggle').show(); console.log("starting trace"); $axure.player.setVarInCurrentUrlHash(TRACE_VAR_NAME, 1); } function stoptrace_click(event) { $axure.messageCenter.setState("isTracing", false); $('#traceDiv').prepend('
Trace Paused
'); $('#traceToggle').text('Restart Trace'); $('#traceToggle').off("click"); $('#traceToggle').click(starttrace_click); console.log("stopping trace"); $axure.player.deleteVarFromCurrentUrlHash(TRACE_VAR_NAME); } }); function generateDebug() { var pageNotesUi = "
"; pageNotesUi += "
"; pageNotesUi += "
Console
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
Variables
"; pageNotesUi += "Reset Variables"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "TraceClear TraceStop Trace"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
Click the button below to start recording interactions as you click through the prototype.
"; pageNotesUi += "
Start Trace
"; pageNotesUi += "
"; pageNotesUi += "
"; pageNotesUi += "
"; $('#debugHost').html(pageNotesUi); $('#traceEmptyState').show(); } })();