forked from datokrat/X-Tree-M
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_dbg_log.js
More file actions
97 lines (76 loc) · 2.9 KB
/
Copy pathlib_dbg_log.js
File metadata and controls
97 lines (76 loc) · 2.9 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
import { global_setup } from "./global_setup.js";
// Class 'lib_dbg_log'
export function lib_dbg_log()
{
// import params
// object functions
this.create_log = lib_dbg_log_create_log.bind(this);
this.add_entry = lib_dbg_log_add_entry.bind(this);
this.create_email = lib_dbg_log_create_email.bind(this);
// object variables
this.log_array = [];
this.path = "";
// constructor call
this.create_log();
}
function lib_dbg_log_create_log()
{
if (window.location.host == "localhost") // (this.data_src_path.toLowerCase() == "local")
{
this.path = "http://localhost/";
}
else
{
var myPath = window.location.pathname;
if (myPath.indexOf(".php") >= 0)
{
var lastSlashIdx = myPath.lastIndexOf("/");
myPath = myPath.substring(0, lastSlashIdx+1);
this.path = "http://" + window.location.host + myPath;
}
else
this.path = "http://" + window.location.host + window.location.pathname;
}
var dateObj = document.getElementById('GLOBAL_DATE');
var now = new Date();
var new_log_entry = now.toLocaleString()+ ' | # LOG-START # | instance:' + this.path;
this.log_array[this.log_array.length] = new_log_entry;
}
// get field content
function lib_dbg_log_add_entry(iparams)
{
// if maximum number of log entries is reached -> kill oldest
if (this.log_array.length > global_setup.dbg_log_max_entries)
{
this.log_array.splice(0,1);
}
var new_log_entry = "";
var dateObj = document.getElementById('GLOBAL_DATE');
var now = new Date();
if (iparams.module == "uc_brow_disp_keyb_proc")
new_log_entry = now.toLocaleString()+ ' | #' + iparams.module + '# | key:' + iparams.sub_function + ' | fctn keys:' + iparams.side_condition + ' | action:' + iparams.action;
if (iparams.module == "uc_browsing_main_clicked_at")
new_log_entry = now.toLocaleString()+ ' | #' + iparams.module + '# | sender:' + iparams.sender + ' | submodule:' + iparams.submodule + ' | item:' + iparams.item;
this.log_array[this.log_array.length] = new_log_entry;
}
function lib_dbg_log_create_email()
{
var message = "";
for (var i=0; i<this.log_array.length; i++)
{
message = message + this.log_array[i] + '\\n'; // oder '\\n'
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
var xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
// to make sure that the Browser doesn't use a cached version of the file
var php_path = this.path+"lib_dbg_log2email.php";
xmlhttp.open("POST",php_path,true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(message);
}