debug.js
6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// use this to isolate the scope
(function () {
if(!$axure.document.configuration.showConsole) { return; }
$(document).ready(function () {
$axure.player.createPluginHost({
id: 'debugHost',
context: 'interface',
title: 'CONSOLE',
gid: 3
});
generateDebug();
$('#variablesClearLink').click(clearvars_click);
$('#traceClearLink').click(cleartrace_click);
$(document).on('ContainerHeightChange', function () {
updateContainerHeight();
});
//$('#traceContainer').hide();
//$('#debugTraceLink').click(function () {
// $('#variablesContainer').hide();
// $('#traceContainer').show();
//});
//$('#debugVariablesLink').click(function () {
// $('#variablesContainer').show();
// $('#traceContainer').hide();
//});
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('<div class="variableDiv"><span class="variableName">' + key + '</span><br/>' + value + '</div>');
}
} else if(message == 'axEvent') {
var addToStack = "<div class='axEventBlock'>";
addToStack += "<div class='axTime'>" + new Date().toLocaleTimeString() + "</div>";
addToStack += "<div class='axLabel'>" + data.label + " (" + data.type + ")</div>";
addToStack += "<div class='axEvent'>" + data.event.description + "</div>";
currentStack.push(addToStack);
} else if (message == 'axEventComplete') {
currentStack[currentStack.length - 1] += "</div>";
finishedStack.push(currentStack.pop());
if(currentStack.length == 0) {
$('#traceClearLinkContainer').show();
$('#traceEmptyState').hide();
$('.lastAxEvent').removeClass('lastAxEvent');
for(var i = finishedStack.length - 1; i >= 0; i--) {
if($('#traceDiv').children().length > 99) $('#traceDiv').children().last().remove();
$('#traceDiv').prepend(finishedStack[i]);
if(i == finishedStack.length - 1) $('#traceDiv').children().first().addClass('lastAxEvent');
}
finishedStack = [];
}
} else if (message == 'axCase') {
currentStack[currentStack.length - 1] += "<div class='axCase'>" + data.description + "</div>";
} else if (message == 'axAction') {
currentStack[currentStack.length - 1] += "<div class='axAction'>" + data.description + "</div>";
}
}
// bind to the page load
$axure.page.bind('load.debug', function () {
$axure.messageCenter.postMessage('getGlobalVariables', '');
return false;
});
function clearvars_click(event) {
$axure.messageCenter.postMessage('resetGlobalVariables', '');
}
function cleartrace_click(event) {
$('#traceDiv').html('');
$('#traceClearLinkContainer').hide();
$('#traceEmptyState').show();
}
});
function updateContainerHeight() {
$('#debugScrollContainer').height($('#debugHost').height() - $('#debugHeader').outerHeight());
}
function generateDebug() {
var pageNotesUi = "<div id='debugHeader'' class='sitemapHeader'>";
pageNotesUi += "<div id='debugToolbar' class='sitemapToolbar'>";
pageNotesUi += "<div class='pluginNameHeader'>CONSOLE</div>";
pageNotesUi += "<div class='pageNameHeader'></div>";
//pageNotesUi += "<div class='pageButtonHeader'>";
//pageNotesUi += "<a id='previousPageButton' title='Previous Page' class='sitemapToolbarButton'></a>";
//pageNotesUi += "<a id='nextPageButton' title='Next Page' class='sitemapToolbarButton'></a>";
//pageNotesUi += "<a id='variablesClearLink' title='Reset Variables' class='sitemapToolbarButton'></a>";
//pageNotesUi += "</div>";
pageNotesUi += "</div>";
pageNotesUi += "</div>";
//var pageNotesUi = "<div id='debugToolbar'><a id='debugVariablesLink' class='debugToolbarButton'>Variables</a> | <a id='debugTraceLink' class='debugToolbarButton'>Trace</a></div>";
pageNotesUi += "<div id='debugScrollContainer'>";
pageNotesUi += "<div id='debugContainer'>";
pageNotesUi += "<div id='variablesContainer'>";
pageNotesUi += "<div id='variablesClearLinkContainer' class='debugLinksContainer'><a id='variablesClearLink' title='Reset Variables'>Reset Variables</a></div>";
pageNotesUi += "<div id='variablesDiv'></div></div>";
pageNotesUi += "<div class='dottedDivider'></div>";
pageNotesUi += "<div id='traceContainer'>";
pageNotesUi += "<div id='traceClearLinkContainer' class='debugLinksContainer'><a id='traceClearLink' title='Clear Trace'>Clear Trace</a></div>";
pageNotesUi += "<div id='traceEmptyState' class='emptyStateContainer'><div class='emptyStateTitle'>No interactions in the trace.</div><div class='emptyStateContent'>Triggered interactions will appear here.</div><div class='dottedDivider'></div></div>";
pageNotesUi += "<div id='traceDiv'></div></div>";
pageNotesUi += "</div></div>";
$('#debugHost').html(pageNotesUi);
updateContainerHeight();
$('#traceClearLinkContainer').hide();
$('#traceEmptyState').show();
}
})();