Kwiki-JSLog
view release on metacpan or search on metacpan
lib/Kwiki/JSLog.pm view on Meta::CPAN
oSev.style.backgroundColor="#FF7070";
}
oSev.appendChild(document.createTextNode(sLevel));
oRes.appendChild(oSev);
var oTime= document.createElement("span");
oTime.style.paddingLeft="3px";
oTime.style.paddingRight="8px";
oSev.style[sFloat]="left";
oTime.appendChild(document.createTextNode(getCurrentTimeFormatted()));
oRes.appendChild(oTime);
oRes.appendChild(document.createTextNode(sMsg));
var oClear=document.createElement("div");
oClear.style.clear="both";
oRes.appendChild(oClear);
return oRes;
}
// this private method returns the current date formated properly with a nice AM/PM
function getCurrentTimeFormatted() {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours);
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
timeValue += (hours >= 12) ? " PM" : " AM";
return timeValue;
}
if (Config_Enabled) {
initializeDisplay();
}
/*------------------------------------------------------------------------------------
Initialization code. It's wrapped in a try-catch block because if something here
fails, there is no other notification
------------------------------------------------------------------------------------*/
function initializeDisplay() {
if (!bLoggerConfigured) {
// Create the display div if necessary. This writes directly to the document to create the UI for the logger.
// Note also that there are onclick events here, which call back to the public methods of the class.
try {
// default positions if other positions are not available
var nTop=2;
var nLeft=2;
var sDisplay="none";
if (bPersistState) {
try {
var sPersistString = EC.F.getCookie(sInstance+"_position");
if (sPersistString != null) {
var aTemp = sPersistString.split("|");
if(!isNaN(parseInt(aTemp[0]))) {
nLeft = aTemp[0];
}
if(!isNaN(parseInt(aTemp[1]))) {
nTop = aTemp[1];
}
}
if(EC.F.getCookie(sInstance+"_visibility") == "block") {
sDisplay="block";
}
} catch (e) {
// nullop, just leave the arguments as the default
}
} // end if bPersistState
var sIdToInspect = EC.F.getCookie(sInstance+"_idToInspect");
sIdToInspect = sIdToInspect==null?"":sIdToInspect;
document.write('<div id="'+sDOMInstance+'_container" style="font-family:arial; color:black; font-size:9px; line-height:normal; letter-spacing: normal; position:absolute; z-index:10000;top:'+nTop+'px; left:'+nLeft+'px; ">'+
'<div id="'+sDOMInstance+'_handle" style="cursor:move; position: absolute; background-color:#FFFFCC; border:1px solid #FF0400; color:black; padding:2px;" ondblclick="'+sInstance+'.toggleDisplay()">0</div>'+
'<div id="'+sDOMInstance+'_body" style="text-align:left; border:1px solid #FF0400; width:300px; position: absolute; top:20px; left:0px; background-color:white; display:'+sDisplay+'">'+
'<div id="'+sDOMInstance+'_header" style="height:10px; padding:2px; border-bottom:1px solid black; background-color:#FFFFCC;">'+
'<span id="'+sDOMInstance+'_clear" style="color: blue;" onclick="'+sInstance+'.clearLog()">clear</span>'+
'</div>'+
'<div id="'+sDOMInstance+'_logDisplay" style="height:240px; overflow:auto;"></div>'+
'<div id="'+sDOMInstance+'_footer" style="padding-left:2px; border-top:1px solid black; background-color:#FFFFCC;">'+
'get html:<input id="'+sDOMInstance+'_idToInspect" style="font-size:9px; height:18px;" value="'+sIdToInspect+'" size=42/> <span id="'+sDOMInstance+'_go" style="color: blue;" onclick="'+sInstance+'.getHTML()">go</span>'+
'<textarea id="'+sDOMInstance+'_textArea" style="width:99%; font-size:9px;"></textarea>'+
'</div></div></div></div>');
// Allow browser to construct DOM elements
setTimeout(function() {
$(sDOMInstance+"_clear").style.cursor="pointer";
$(sDOMInstance+"_go").style.cursor="pointer";
// Check if the draggable library is provided. This would be true if the appropriate libraries
// are included in the page via a <script> tag
if (window['Draggable'] != null) {
// draggable is available, so use it!
new Draggable(sDOMInstance+'_container',{handle:sDOMInstance+'_handle', revert:false,
starteffect:false, endeffect:false});
// if the persistState option is true, set up the listener as appropriate
if (bPersistState) {
var fMyDropListener = new function() {
this.onStart = function(){};
this.onEnd = function(s,o) {
if (o.element.id == sDOMInstance+"_container"){
var pos = Position.cumulativeOffset(o.element);
EC.F.setCookie(sInstance+"_position",+pos[0]+"|"+pos[1]);
}
}
}
Draggables.addObserver(fMyDropListener);
}
} else {
// Otherwise, it means sciptaculous is not included, and debug won't be draggable
// change the cursor on the loggerHandle
$(sDOMInstance+'_handle').style.cursor="pointer";
}
}, 100);
( run in 2.749 seconds using v1.01-cache-2.11-cpan-d01c6094234 )