Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1244827
debugger.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Nov 21, 3:21 AM
Size
7 KB
Mime Type
text/plain
Expires
Sun, Nov 23, 3:21 AM (1 d, 15 h)
Engine
blob
Format
Raw Data
Handle
809672
Attached To
rINP In-Portal
debugger.js
View Options
function
DebugReq
()
{}
DebugReq
.
timeout
=
5000
;
//5 seconds
DebugReq
.
makeRequest
=
function
(
p_url
,
p_busyReq
,
p_progId
,
p_successCallBack
,
p_errorCallBack
,
p_pass
)
{
//p_url: the web service url
//p_busyReq: is a request for this object currently in progress?
//p_progId: element id where progress HTML should be shown
//p_successCallBack: callback function for successful response
//p_errorCallBack: callback function for erroneous response
//p_pass: string of params to pass to callback functions
if
(
p_busyReq
)
return
;
var
req
=
DebugReq
.
getRequest
();
if
(
req
!=
null
)
{
p_busyReq
=
true
;
DebugReq
.
showProgress
(
p_progId
);
req
.
onreadystatechange
=
function
()
{
if
(
req
.
readyState
==
4
)
{
p_busyReq
=
false
;
window
.
clearTimeout
(
toId
);
if
(
req
.
status
==
200
)
{
p_successCallBack
(
req
,
p_pass
);
}
else
{
p_errorCallBack
(
req
,
p_pass
);
}
}
}
req
.
open
(
'GET'
,
p_url
,
true
);
req
.
setRequestHeader
(
'If-Modified-Since'
,
'Sat, 1 Jan 2000 00:00:00 GMT'
);
req
.
send
(
null
);
var
toId
=
window
.
setTimeout
(
function
()
{
if
(
p_busyReq
)
req
.
abort
();},
DebugReq
.
timeout
);
}
}
DebugReq
.
getRequest
=
function
()
{
var
xmlHttp
;
try
{
xmlHttp
=
new
ActiveXObject
(
'MSXML2.XMLHTTP'
);
return
xmlHttp
;
}
catch
(
e
)
{}
try
{
xmlHttp
=
new
ActiveXObject
(
'Microsoft.XMLHTTP'
);
return
xmlHttp
;
}
catch
(
e
)
{}
try
{
xmlHttp
=
new
XMLHttpRequest
();
return
xmlHttp
;
}
catch
(
e
)
{}
return
null
;
}
DebugReq
.
showProgress
=
function
(
p_id
)
{
$Debugger
.
AppendRow
(
DebugReq
.
getProgressHtml
());
}
DebugReq
.
getProgressHtml
=
function
()
{
return
'Loading ...'
;
}
DebugReq
.
getErrorHtml
=
function
(
p_req
)
{
//TODO: implement accepted way to handle request error
return
"<p>"
+
"("
+
p_req
.
status
+
") "
+
p_req
.
statusText
+
"</p>"
}
// Debugger
function
Debugger
()
{
this
.
IsQueried
=
false
;
this
.
IsVisible
=
false
;
this
.
DebuggerDIV
=
document
.
getElementById
(
'debug_layer'
);
this
.
DebuggerTable
=
document
.
getElementById
(
'debug_table'
);
this
.
RowCount
=
0
;
// window.$Debugger = this; // this should be uncommented in case if debugger variable is not $Debugger
window
.
onscroll
=
function
(
ev
)
{
window
.
$Debugger
.
Resize
(
ev
);
}
window
.
onresize
=
function
(
ev
)
{
window
.
$Debugger
.
Resize
(
ev
);
}
document
.
onkeydown
=
function
(
ev
)
{
window
.
$Debugger
.
KeyDown
(
ev
);
}
}
Debugger
.
prototype
.
AppendRow
=
function
(
$html
)
{
this
.
RowCount
++
;
var
$tr
=
document
.
createElement
(
'TR'
);
this
.
DebuggerTable
.
appendChild
(
$tr
);
$tr
.
className
=
'debug_row_'
+
(
this
.
RowCount
%
2
?
'odd'
:
'even'
);
$tr
.
id
=
'debug_row_'
+
this
.
RowCount
;
var
$td
=
document
.
createElement
(
'TD'
);
$tr
.
appendChild
(
$td
);
$td
.
className
=
'debug_cell'
;
$td
.
innerHTML
=
$html
;
}
Debugger
.
prototype
.
KeyDown
=
function
(
$e
)
{
var
$KeyCode
=
this
.
GetKeyCode
(
$e
);
if
(
$KeyCode
==
123
||
$KeyCode
==
27
)
{
// F12 or ESC
this
.
Toggle
(
$KeyCode
);
this
.
StopEvent
(
$e
);
}
}
Debugger
.
prototype
.
OpenDOMViewer
=
function
()
{
var
$value
=
document
.
getElementById
(
'dbg_domviewer'
).
value
;
DOMViewerObj
=
(
$value
.
indexOf
(
'"'
)
!=
-
1
)
?
document
.
getElementById
(
$value
.
substring
(
1
,
$value
.
length
-
1
)
)
:
eval
(
$value
);
window
.
open
(
this
.
DOMViewerURL
);
return
false
;
}
Debugger
.
prototype
.
GetKeyCode
=
function
(
$e
)
{
$e
=
(
$e
)
?
$e
:
event
;
var
target
=
(
$e
.
target
)
?
$e
.
target
:
$e
.
scrElement
;
var
charCode
=
(
$e
.
charCode
)
?
$e
.
charCode
:
((
$e
.
which
)
?
$e
.
which
:
$e
.
keyCode
);
return
charCode
;
}
Debugger
.
prototype
.
StopEvent
=
function
(
$e
)
{
$e
=
(
$e
)
?
$e
:
event
;
$e
.
cancelBubble
=
true
;
if
(
$e
.
stopPropagation
)
$e
.
stopPropagation
();
}
Debugger
.
prototype
.
Toggle
=
function
(
$KeyCode
)
{
if
(
!
this
.
DebuggerDIV
)
return
false
;
this
.
IsVisible
=
this
.
DebuggerDIV
.
style
.
display
==
'none'
?
false
:
true
;
if
(
!
this
.
IsVisible
&&
$KeyCode
==
27
)
{
return
false
;
}
this
.
Resize
(
null
);
if
(
!
this
.
IsQueried
)
{
this
.
Query
();
}
this
.
DebuggerDIV
.
style
.
display
=
this
.
IsVisible
?
'none'
:
'block'
;
}
Debugger
.
prototype
.
Query
=
function
()
{
DebugReq
.
makeRequest
(
this
.
DebugURL
,
this
.
busyReq
,
''
,
this
.
successCallback
,
this
.
errorCallback
,
''
);
}
Debugger
.
prototype
.
successCallback
=
function
(
p_req
,
p_pass
)
{
var
contents
=
p_req
.
responseText
;
contents
=
contents
.
split
(
$Debugger
.
RowSeparator
);
if
(
contents
.
length
==
1
)
{
alert
(
'error: '
+
p_req
.
responseText
);
$Debugger
.
IsQueried
=
true
;
return
;
}
for
(
var
$i
=
0
;
$i
<
contents
.
length
-
1
;
$i
++
)
{
$Debugger
.
AppendRow
(
contents
[
$i
]);
}
$Debugger
.
Refresh
();
}
Debugger
.
prototype
.
Refresh
=
function
()
{
// progress mether row
document
.
getElementById
(
'debug_row_1'
).
style
.
display
=
'none'
;
this
.
IsQueried
=
true
;
this
.
DebuggerDIV
.
scrollTop
=
this
.
IsFatalError
?
10000000
:
0
;
this
.
DebuggerDIV
.
scrollLeft
=
0
;
}
Debugger
.
prototype
.
errorCallback
=
function
(
p_req
,
p_pass
)
{
alert
(
'AJAX ERROR: '
+
DebugReq
.
getErrorHtml
(
p_req
));
$Debugger
.
Refresh
();
}
Debugger
.
prototype
.
Resize
=
function
(
$e
)
{
if
(
!
this
.
DebuggerDIV
)
return
false
;
var
$pageTop
=
document
.
all
?
document
.
body
.
offsetTop
+
document
.
body
.
scrollTop
:
window
.
scrollY
;
this
.
DebuggerDIV
.
style
.
top
=
$pageTop
+
'px'
;
this
.
DebuggerDIV
.
style
.
height
=
GetWindowHeight
()
+
'px'
;
return
true
;
}
function
GetWindowHeight
()
{
var
currWinHeight
;
if
(
window
.
innerHeight
)
{
//FireFox with correction for status bar at bottom of window
currWinHeight
=
window
.
innerHeight
-
10
;
}
else
if
(
document
.
documentElement
.
clientHeight
)
{
//IE 7 with correction for address bar
currWinHeight
=
document
.
documentElement
.
clientHeight
-
10
;
}
else
if
(
document
.
body
.
offsetHeight
)
{
//IE 4+
currWinHeight
=
document
.
body
.
offsetHeight
-
5
+
15
-
10
;
// + 10
}
return
currWinHeight
;
}
/*function GetWinHeight() {
if (window.innerHeight) return window.innerHeight;
else if (document.documentElement.clientHeight) return document.documentElement.clientHeight;
else if (document.body.offsetHeight) return document.body.offsetHeight;
else return _winHeight;
}*/
Debugger
.
prototype
.
SetClipboard
=
function
(
copyText
)
{
if
(
window
.
clipboardData
)
{
// IE send-to-clipboard method.
window
.
clipboardData
.
setData
(
'Text'
,
copyText
);
}
else
if
(
window
.
netscape
)
{
// You have to sign the code to enable this or allow the action in about:config by changing user_pref("signed.applets.codebase_principal_support", true);
netscape
.
security
.
PrivilegeManager
.
enablePrivilege
(
'UniversalXPConnect'
);
// Store support string in an object.
var
str
=
Components
.
classes
[
'@mozilla.org/supports-string;1'
].
createInstance
(
Components
.
interfaces
.
nsISupportsString
);
if
(
!
str
)
{
return
false
;
}
str
.
data
=
copyText
;
// Make transferable.
var
trans
=
Components
.
classes
[
'@mozilla.org/widget/transferable;1'
].
createInstance
(
Components
.
interfaces
.
nsITransferable
);
if
(
!
trans
)
{
return
false
;
}
// Specify what datatypes we want to obtain, which is text in this case.
trans
.
addDataFlavor
(
'text/unicode'
);
trans
.
setTransferData
(
'text/unicode'
,
str
,
copyText
.
length
*
2
);
var
clipid
=
Components
.
interfaces
.
nsIClipboard
;
var
clip
=
Components
.
classes
[
'@mozilla.org/widget/clipboard;1'
].
getService
(
clipid
);
if
(
!
clip
)
{
return
false
;
}
clip
.
setData
(
trans
,
null
,
clipid
.
kGlobalClipboard
);
}
}
Debugger
.
prototype
.
ShowProps
=
function
(
$Obj
,
$Name
)
{
var
$ret
=
''
;
for
(
$Prop
in
$Obj
)
{
$ret
+=
$Name
+
'.'
+
$Prop
+
' = '
+
$Obj
[
$Prop
]
+
"\n"
;
}
return
alert
(
$ret
);
}
Debugger
.
prototype
.
editFile
=
function
(
$fileName
,
$lineNo
)
{
if
(
!
document
.
all
)
{
alert
(
'Only works in IE'
);
return
;
}
if
(
!
this
.
EditorPath
)
{
alert
(
'Editor path not defined!'
);
return
;
}
var
$launch_object
=
new
ActiveXObject
(
'LaunchinIE.Launch'
);
var
$editor_path
=
this
.
EditorPath
;
$editor_path
=
$editor_path
.
replace
(
'%F'
,
$fileName
);
$editor_path
=
$editor_path
.
replace
(
'%L'
,
$lineNo
);
$launch_object
.
LaunchApplication
(
$editor_path
);
}
Debugger
.
prototype
.
ToggleTraceArgs
=
function
(
$arguments_layer_id
)
{
var
$arguments_layer
=
document
.
getElementById
(
$arguments_layer_id
);
$arguments_layer
.
style
.
display
=
(
$arguments_layer
.
style
.
display
==
'none'
)
?
'block'
:
'none'
;
}
Event Timeline
Log In to Comment