1 // login.php makes sure the session ID captured here is different for each
2 // new login. We maintain it here because most browsers do not have separate
3 // cookie storage for different top-level windows. This function should be
4 // called just prior to invoking any server script that requires correct
5 // session data. onclick="top.restoreSession()" usually does the job.
7 var oemr_session_name
= '<?php echo session_name(); ?>';
8 var oemr_session_id
= '<?php echo session_id(); ?>';
9 var oemr_dialog_close_msg
= '<?php echo xl('OK to close this other popup window?
'); ?>';
11 function restoreSession() {
12 <?php
if (!empty($GLOBALS['restore_sessions'])) { ?
>
13 var ca
= document
.cookie
.split('; ');
14 for (var i
= 0; i
< ca
.length
; ++i
) {
15 var c
= ca
[i
].split('=');
16 if (c
[0] == oemr_session_name
&& c
[1] != oemr_session_id
) {
17 <?php
if ($GLOBALS['restore_sessions'] == 2) { ?
>
18 alert('Changing session ID from\n"' + c
[1] +
'" to\n"' + oemr_session_id +
'"');
20 document
.cookie
= oemr_session_name +
'=' + oemr_session_id +
'; path=/';
27 // Pages that have a Print button or link should call this to initialize it for logging.
28 // This is done at page load time in case we want to hide or disable the element.
30 function printLogSetup(elem
, logdata
) {
31 if (elem
== null) return;
32 var doc
= elem
.ownerDocument
;
33 var win
= doc
.defaultView || doc
.parentWindow
;
34 if (typeof(logdata
) == 'undefined') logdata
= null;
35 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
36 if (logdata
== null) {
37 elem
.style
.display
= 'none';
41 win
.printlogdata
= logdata
;
42 elem
.onclick
= function () {
43 // This is a function definition and variables here will be evaluated when the function executes.
44 top
.printLogPrint(this
);
48 // Pages that would otherwise call window.print() at load time should call this instead
49 // to support print logging. In this case the passed argument is normally the window and
50 // data to log, if specified, should be in the caller's window.printlogdata.
52 function printLogPrint(elem
) {
54 if (elem
.ownerDocument
) {
55 var doc
= elem
.ownerDocument
;
56 win
= doc
.defaultView || doc
.parentWindow
;
58 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
59 // Returning false means we didn't print.
60 if (!win
.printlogdata
) return false;
62 if (win
.printlog_before_print
) win
.printlog_before_print();
64 <?php
if (!empty($GLOBALS['gbl_print_log_option'])) { ?
>
65 comments
= win
.printlogdata || win
.document
.body
.innerHTML
;
67 $
.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/log_print_action_ajax.php",
68 { comments
: comments
}