recording.js
3.33 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
// ******* Recording MANAGER ******** //
$axure.internal(function($ax) {
var _recording = $ax.recording = {};
$ax.recording.recordEvent = function(element, eventInfo, axEventObject, timeStamp) {
var elementHtml = $jobj(element);
var className = elementHtml.attr('class');
var inputValue;
if(className === 'ax_checkbox') {
inputValue = elementHtml.find('#' + element + '_input')[0].checked;
eventInfo.inputType = className;
eventInfo.inputValue = inputValue;
}
if(className === 'ax_text_field') {
inputValue = elementHtml.find('#' + element + '_input').val();
eventInfo.inputType = className;
eventInfo.inputValue = inputValue;
}
var scriptId = $ax.repeater.getScriptIdFromElementId(element);
var diagramObjectPath = $ax.getPathFromScriptId(scriptId);
var form = {
recordingId: $ax.recording.recordingId,
elementID: element,
eventType: axEventObject.description,
'eventInfo': eventInfo,
// eventObject: axEventObject,
'timeStamp': timeStamp,
'path': diagramObjectPath
// ,
// 'trigger': function() {
// $ax.event.handleEvent(element, eventInfo, axEventObject);
// return false;
// }
};
$ax.messageCenter.postMessage('logEvent', form);
};
$ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
};
$ax.recording.recordingId = "";
$ax.recording.recordingName = "";
$ax.messageCenter.addMessageListener(function(message, data) {
if(message === 'startRecording') {
$ax.recording.maybeRecordEvent = $ax.recording.recordEvent;
$ax.recording.recordingId = data.recordingId;
$ax.recording.recordingName = data.recordingName;
} else if(message === 'stopRecording') {
$ax.recording.maybeRecordEvent = function(element, eventInfo, axEventObject, timeStamp) {
};
}
else if(message === 'playEvent') {
var eventType = makeFirstLetterLower(data.eventType);
var inputElement;
var dObj = data.element === '' ? $ax.pageData.page : $ax.getObjectFromElementId(data.element);
if(!data.axEventObject) {
data.axEventObject = dObj && dObj.interactionMap && dObj.interactionMap[eventType];
}
data.eventInfo.thiswidget = $ax.getWidgetInfo(data.element);
data.eventInfo.item = $ax.getItemInfo(data.element);
if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_checkbox') {
inputElement = $jobj(data.element + '_input');
inputElement[0].checked = data.eventInfo.inputValue;
}
if(data.eventInfo.inputType && data.eventInfo.inputType === 'ax_text_field') {
inputElement = $jobj(data.element + '_input');
inputElement.val(data.eventInfo.inputValue);
}
$ax.event.handleEvent(data.element, data.eventInfo, data.axEventObject, false, true);
}
});
var makeFirstLetterLower = function(eventName) {
return eventName.substr(0, 1).toLowerCase() + eventName.substr(1);
};
});