aboutsummaryrefslogblamecommitdiffstats
path: root/docs/html/overview-summary-logger.js.html
blob: a011906666211126f95b1e0785b71b4dbd82999a (plain) (tree)












































































































































































































































































































                                                                                                                                                        
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
 Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="logger.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>logger.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'logger.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="Logger.html">Logger</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">// Released under the MIT/X11 license</span>
<span class="comment">// http://www.opensource.org/licenses/mit-license.php</span>
<span class="literal">"use strict"</span>;
var urlMod = require(<span class="literal">"url"</span>);
var utilMod = require(<span class="literal">"util"</span>);
var Color = require(<span class="literal">"color"</span>).Color;
var tabs = require(<span class="literal">"tabs"</span>);
var apiUtils = require(<span class="literal">"api-utils"</span>);

<span class="reserved">function</span> Logger(store, abbsMap) {
    <span class="reserved">this</span>.EmptyLogsColor = new Color(0, 255, 0);
    <span class="reserved">this</span>.FullLogsColor = new Color(0, 40, 103);

    <span class="reserved">this</span>.store = store;
    <span class="reserved">this</span>.abbsMap = abbsMap;
};

exports.Logger = Logger;

Logger.<span class="reserved">prototype</span>.addLogRecord = <span class="reserved">function</span>(that) {
    console.log(<span class="literal">"Adding log record!"</span>);
    var rec = {};
    rec.date = new Date();
    rec.url = that.doc.location.toString();
    rec.title = that.title;
    var comment = tabs.activeTab.contentWindow.prompt(
            <span class="literal">"Enter comments for this comment"</span>);
    console.log(<span class="literal">"comment = "</span> + comment);
    <span class="reserved">if</span> (comment &amp;&amp; comment.length &gt; 0) {
        console.log(<span class="literal">"I am in!"</span>);
        comment = comment.trim();
        rec.comment = comment;
        console.log(<span class="literal">"rec.comment = "</span> + rec.comment);
        <span class="comment">// FIXME We break on the following line. Not sure what's going on!</span>
        var dateStr = utilMod.getISODate(rec.date);
        console.log(<span class="literal">"rec.date = "</span> + rec.date + <span class="literal">", dateStr = "</span> + dateStr);
        var urlStr = urlMod.URL(rec.url).host;
        console.log(<span class="literal">"rec.url = "</span> + rec.url + <span class="literal">", urlStr = "</span> + urlStr);
        var recKey = dateStr + <span class="literal">"+"</span>
            + urlStr
            + <span class="literal">"+"</span> + that.bugNo;
        console.log(<span class="literal">"recKey = "</span> + recKey);
        console.log(<span class="literal">"rec = "</span> + rec.toSource());

        <span class="reserved">if</span> (<span class="reserved">this</span>.store[recKey]) {
            <span class="reserved">this</span>.store[recKey].comment += <span class="literal">"&lt;br/&gt;\n"</span> + comment;
        } <span class="reserved">else</span> {
            <span class="reserved">this</span>.store[recKey] = rec;
        }
    }
    <span class="reserved">return</span> comment;
};

Logger.<span class="reserved">prototype</span>.getLength = <span class="reserved">function</span> () {
    var counter = 0;
    <span class="reserved">for</span> (var key in <span class="reserved">this</span>.store) {
        counter += 1;
    }
    <span class="reserved">return</span> counter;
};

Logger.<span class="reserved">prototype</span>.getBugzillaAbbr = <span class="reserved">function</span>(url) {
    <span class="comment">// for https://bugzilla.redhat.com/show_bug.cgi?id=579123 get RH</span>
    <span class="comment">// for https://bugzilla.mozilla.org/show_bug.cgi?id=579123 get MoFo</span>
    var abbr = <span class="reserved">this</span>.abbsMap[urlMod.URL(url).host];
    <span class="reserved">return</span> abbr;
};

Logger.<span class="reserved">prototype</span>.timeSheetRecordsPrinter = <span class="reserved">function</span>(body, records) {
    var that = <span class="reserved">this</span>;
    var commentBugRE = new RegExp(<span class="literal">"[bB]ug\\s+([0-9]+)"</span>,<span class="literal">"g"</span>);
    <span class="comment">// sort the records into temporary array</span>
    var tmpArr = [];

    <span class="reserved">for</span> ( var i in records) {
        <span class="reserved">if</span> (records.hasOwnProperty(i)) {
            tmpArr.push( [ i, records[i] ]);
        }
    }
    tmpArr.sort(<span class="reserved">function</span>(a, b) {
        <span class="reserved">return</span> a[0] &gt; b[0] ? 1 : -1;
    });

    var currentDay = <span class="literal">""</span>;
    <span class="comment">// now print the array</span>
    tmpArr.forEach(<span class="reserved">function</span>(rec) {
                var x = rec[1];
                var dayStr = utilMod.getISODate(x.date);
                var host = urlMod.URL(x.url).host;
                var BZName = that.getBugzillaAbbr(x.url);
                var bugNo = utilMod.getBugNo(x.url);
                <span class="reserved">if</span> (dayStr != currentDay) {
                    currentDay = dayStr;
                    body.innerHTML += <span class="literal">"&lt;hr/&gt;&lt;p&gt;&lt;strong&gt;"</span> + currentDay
                            + <span class="literal">"&lt;/strong&gt;&lt;/p&gt;"</span>;
                }
                <span class="comment">// replace "bug ####" with a hyperlink to the current bugzilla</span>
                var comment = x.comment.replace(commentBugRE,
                    <span class="literal">"&lt;a href='http://"</span>+host+<span class="literal">"/show_bug.cgi?id=$1'&gt;$&amp;&lt;/a&gt;"</span>);
                body.innerHTML += <span class="literal">"&lt;p&gt;&lt;em&gt;&lt;a href='"</span>
                        + x.url
                        + <span class="literal">"'&gt;Bug "</span>
                        + BZName + <span class="literal">"/"</span> + bugNo + <span class="literal">": "</span>
                        + x.title
                        + <span class="literal">"&lt;/a&gt;"</span>
                        + <span class="literal">" &lt;/em&gt;\n&lt;br/&gt;"</span> + comment + <span class="literal">"&lt;/p&gt;"</span>;
            });
};

<span class="comment">/**
 *
 */</span>
Logger.<span class="reserved">prototype</span>.createBlankPage = <span class="reserved">function</span> (ttl, bodyBuildCB) {
    var title = ttl || <span class="literal">"Yet another untitled page"</span>;
    var that = <span class="reserved">this</span>;

    var logTab = tabs.open({
        url: <span class="literal">"about:blank"</span>,
        onOpen: <span class="reserved">function</span> (tab) {
            var otherDoc = tab.contentDocument;
            otherDoc.title = title;
            otherDoc.body.innerHTML = <span class="literal">"&lt;h1&gt;"</span> + title + <span class="literal">"&lt;/h1&gt;"</span>;
            bodyBuildCB.call(that, otherDoc.body);
        }
    });
};

Logger.<span class="reserved">prototype</span>.generateTimeSheet = <span class="reserved">function</span>(body) {
    var doc = body.ownerDocument;
    <span class="reserved">this</span>.timeSheetRecordsPrinter(body, <span class="reserved">this</span>.store);
};</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Jun 23 09:33:14 2010</div>
</body>
</html>