-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.js
33 lines (30 loc) · 1.02 KB
/
events.js
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
jQuery.print = function(message, insertionType) {
console.log("print event");
if (typeof(message) == 'object') {
var string = '{<br />',
values = [],
counter = 0;
$.each(message, function(key, value) {
if (value && value.nodeName) {
var domnode = '<' + value.nodeName.toLowerCase();
domnode += value.className ? ' class="' + value.className + '"' : '';
domnode += value.id ? ' id="' + value.id + '"' : '';
domnode += '>';
value = domnode;
}
values[counter++] = key + ': ' + value;
});
string += values.join(',<br />');
string += '<br />}';
message = string;
}
var $output = $('#print-output');
if ($output.length === 0) {
$output = $('<div id="print-output" />').appendTo('body');
console.log("tekee divin");
}
var $newMessage = $('<div class="print-output-line" />');
$newMessage.html(message);
insertionType = insertionType || 'append';
$output[insertionType]($newMessage);
};