blob: a873d8d8be52e5db9cc76c2fe38dd9f62693b4fc (
plain)
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
|
<?php
/**
* TJavascriptLogger class file.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
* @copyright Copyright © 2005 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.Web.UI.WebControls
*/
/**
* TJavascriptLogger class.
*
* Provides logging for client-side javascript. Example: template code
* <code><com:TJavascriptLogger /></code>
*
* Client-side javascript code to log info, error, warn, debug
* <code>Logger.warn('A warning');
* Logger.info('something happend');
* </code>
*
* To see the logger and console, press ALT-D (or CTRL-D on OS X).
* More information on the logger can be found at
* http://gleepglop.com/javascripts/logger/
*
* @author Wei Zhuo<weizhuo[at]gmail[dot]com>
* @version $Id$
* @package System.Web.UI.WebControls
* @since 3.0
*/
class TJavascriptLogger extends TWebControl
{
/**
* @return string tag name of the panel
*/
protected function getTagName()
{
return 'div';
}
/**
* Registers the required logger javascript.
* @param TEventParameter event parameter
*/
public function onPreRender($param)
{
$this->getPage()->getClientScript()->registerPradoScript('logger');
}
/**
* Register the required javascript libraries and
* display some general usage information.
* @param THtmlWriter the writer used for the rendering purpose
*/
public function renderContents($writer)
{
$info = '(<a href="http://gleepglop.com/javascripts/logger/" target="_blank">more info</a>).';
$link = '<a href="javascript:if(logConsole)logConsole.toggle()">toggle the javascript log console.</a>';
$usage = 'Press ALT-D (Or CTRL-D on OS X) to';
$writer->write("{$usage} {$link} {$info}");
}
}
?>
|