1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 <include src
="../../../ui/webui/resources/js/util.js">
13 function formatNumber(str
) {
18 var x
= str
.split('.');
20 var x2
= x
.length
> 1 ? '.' + x
[1] : '';
21 var regex
= /(\d+)(\d{3})/;
22 while (regex
.test(x1
)) {
23 x1
= x1
.replace(regex
, '$1' + ',' + '$2');
28 function addToSum(id
, value
) {
29 var target
= document
.getElementById(id
);
30 var sum
= parseInt(target
.innerHTML
);
31 sum
+= parseInt(value
);
32 target
.innerHTML
= sum
;
35 function handleHelpTooltipMouseOver(event
) {
36 var el
= document
.createElement('div');
37 el
.id
= 'helpTooltip';
38 el
.innerHTML
= event
.toElement
.getElementsByTagName('div')[0].innerHTML
;
41 el
.style
.visibility
= 'hidden';
42 document
.body
.appendChild(el
);
44 var width
= el
.offsetWidth
;
45 var height
= el
.offsetHeight
;
47 var scrollLeft
= scrollLeftForDocument(document
);
48 if (event
.pageX
- width
- 50 + scrollLeft
>= 0)
49 el
.style
.left
= (event
.pageX
- width
- 20) + 'px';
51 el
.style
.left
= (event
.pageX
+ 20) + 'px';
53 var scrollTop
= scrollTopForDocument(document
);
54 if (event
.pageY
- height
- 50 + scrollTop
>= 0)
55 el
.style
.top
= (event
.pageY
- height
- 20) + 'px';
57 el
.style
.top
= (event
.pageY
+ 20) + 'px';
59 el
.style
.visibility
= 'visible';
62 function handleHelpTooltipMouseOut(event
) {
63 var el
= $('helpTooltip');
64 el
.parentNode
.removeChild(el
);
67 function enableHelpTooltips() {
68 var helpEls
= document
.getElementsByClassName('help');
70 for (var i
= 0, helpEl
; helpEl
= helpEls
[i
]; i
++) {
71 helpEl
.onmouseover
= handleHelpTooltipMouseOver
;
72 helpEl
.onmouseout
= handleHelpTooltipMouseOut
;
76 document
.addEventListener('DOMContentLoaded', function() {
77 // This is the javascript code that processes the template:
78 var input
= new JsEvalContext(loadTimeData
.getValue('jstemplateData'));
80 jstProcess(input
, output
);