diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-09-24 12:45:54 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-09-24 12:45:54 +0200 |
commit | 3f68c63721f90e97aa9f5c8e297c7c84b7f9659d (patch) | |
tree | 54375d618849211feb61ac73878a897054de8ffc /docs/html/overview-summary-bzpage.js.html | |
parent | 43b43303a4d2abda8268fdc8245132a017a95d05 (diff) | |
download | bugzilla-triage-3f68c63721f90e97aa9f5c8e297c7c84b7f9659d.tar.gz |
Push unfinished documentation to a separate branch
Diffstat (limited to 'docs/html/overview-summary-bzpage.js.html')
-rw-r--r-- | docs/html/overview-summary-bzpage.js.html | 915 |
1 files changed, 0 insertions, 915 deletions
diff --git a/docs/html/overview-summary-bzpage.js.html b/docs/html/overview-summary-bzpage.js.html deleted file mode 100644 index d5a478d..0000000 --- a/docs/html/overview-summary-bzpage.js.html +++ /dev/null @@ -1,915 +0,0 @@ -<!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="bzpage.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> </td> - <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> - - - <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </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"> - PREV - NEXT</font></td> -<td bgcolor="white" class="NavBarCell2"><font size="-2"> - <a href="index.html" target="_top"><b>FRAMES</b></a> - <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> - -<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>bzpage.js</h2> - -</center> - - - - -<h4>Summary</h4> -<p> - - No overview generated for 'bzpage.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="BZPage.html">BZPage</a></b></td> - <td> </td> - </tr> - - </table> - <hr/> - - -<!-- ========== METHOD SUMMARY =========== --> - -<!-- ========== END METHOD SUMMARY =========== --> - - - <pre class="sourceview"><span class="comment">/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */</span> -<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 util = require(<span class="literal">"util"</span>); -var apiUtils = require(<span class="literal">"api-utils"</span>); -var simpleStorage = require(<span class="literal">"simple-storage"</span>); -var preferences = require(<span class="literal">"preferences-service"</span>); -var Color = require(<span class="literal">"color"</span>).Color; - -var TriagedDistro = 13; -var NumberOfFrames = 7; -var bugURL = <span class="literal">"https://bugzilla.redhat.com/show_bug.cgi?id="</span>; - -<span class="comment">// ====================================================================================</span> -<span class="comment">// BZPage's methods</span> -var BZPage = <span class="reserved">function</span> BZPage(win, config) { - var keys = <span class="literal">""</span>; - <span class="reserved">for</span> (var key in config) { - keys += key + <span class="literal">", "</span>; - } - console.log(<span class="literal">"config keys = "</span> + keys); - - <span class="comment">// constants</span> - <span class="reserved">this</span>.SalmonPink = new Color(255, 224, 176); <span class="comment">// RGB 255, 224, 176; HSL 36, 2,</span> - <span class="comment">// 85</span> - <span class="reserved">this</span>.ReporterColor = new Color(255, 255, 166); <span class="comment">// RGB 255, 255, 166; HSL 60, 2,</span> - <span class="comment">// 83</span> - <span class="comment">// initialize dynamic properties</span> - <span class="reserved">this</span>.win = win; - <span class="reserved">this</span>.doc = win.document; - <span class="reserved">this</span>.packages = <span class="reserved">this</span>.getInstalledPackages(config); - - <span class="reserved">if</span> (<span class="literal">"commentStrings"</span> in config.gJSONData) { - <span class="reserved">this</span>.commentStrings = config.gJSONData.commentStrings; - } - - <span class="reserved">if</span> (<span class="literal">"constantData"</span> in config.gJSONData) { - <span class="reserved">this</span>.constantData = config.gJSONData.constantData; - } - - <span class="reserved">if</span> (<span class="literal">"CCmaintainer"</span> in config.gJSONData.constantData) { - <span class="reserved">this</span>.defBugzillaMaintainerArr = config.gJSONData.constantData.CCmaintainer; - } - - <span class="reserved">if</span> (<span class="literal">"suspiciousComponents"</span> in config.gJSONData.configData) { - <span class="reserved">this</span>.suspiciousComponents = config.gJSONData.configData.suspiciousComponents; - } - - <span class="reserved">if</span> (<span class="literal">"submitsLogging"</span> in config.gJSONData.configData && - config.gJSONData.configData.submitsLogging) { - <span class="reserved">this</span>.log = config.logger; - console.log(<span class="literal">"length of this.log.store = "</span> + <span class="reserved">this</span>.log.getLength()); - <span class="reserved">this</span>.setUpLogging(); - } - - <span class="reserved">this</span>.submitHandlerInstalled = false; - <span class="reserved">this</span>.bugNo = util.getBugNo(<span class="reserved">this</span>.doc.location.toString()); - - <span class="reserved">this</span>.reporter = <span class="reserved">this</span>.getReporter(); - <span class="reserved">this</span>.product = <span class="reserved">this</span>.getOptionValue(<span class="literal">"product"</span>); - <span class="reserved">this</span>.component = <span class="reserved">this</span>.getOptionValue(<span class="literal">"component"</span>); - <span class="reserved">this</span>.version = <span class="reserved">this</span>.getVersion(); - <span class="reserved">this</span>.title = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"short_desc_nonedit_display"</span>).textContent; - <span class="reserved">this</span>.CCList = <span class="reserved">this</span>.getCCList(); - - <span class="comment">// Prepare for query buttons</span> - <span class="comment">// FIXME getting null for commentArea sometimes</span> - var commentArea = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comment_status_commit"</span>); - <span class="reserved">if</span> (commentArea) { - var brElementPlacer = commentArea.getElementsByTagName(<span class="literal">"br"</span>); - brElementPlacer = brElementPlacer[0]; - <span class="reserved">if</span> (brElementPlacer) { - brElementPlacer.setAttribute(<span class="literal">"id"</span>,<span class="literal">"brElementPlacer_location"</span>); - brElementPlacer.parentNode.insertBefore(<span class="reserved">this</span>.doc.createElement(<span class="literal">"br"</span>), - brElementPlacer); - } - } <span class="reserved">else</span> { - console.log(<span class="literal">"Cannot find element with 'comment_status_commit' ID!"</span>); - } - - <span class="reserved">this</span>.generateButtons(); -}; - -<span class="comment">/** - * Get the ID of the bug. - * - * <span class="attrib">@return</span> string - */</span> -BZPage.<span class="reserved">prototype</span>.getBugId = <span class="reserved">function</span> getBugId () { - <span class="reserved">return</span> util.getBugNo(<span class="reserved">this</span>.doc.location.href); -}; - -<span class="comment">/** - * - */</span> -BZPage.<span class="reserved">prototype</span>.getInstalledPackages = <span class="reserved">function</span> getInstalledPackages(cfg) { - var installedPackages = {}; - - <span class="reserved">if</span> (cfg.gJSONData && (<span class="literal">"commentPackages"</span> in cfg.gJSONData)) { - <span class="comment">// TODO: Temporary hack ... should be replaced by a proper configuration</span> - <span class="comment">// when replacement for jetpack.storage.settings lands</span> - var enabledPackages = cfg.gJSONData.configData.enabledPacks.split(/[, ]/); - enabledPackages.forEach(<span class="reserved">function</span> (pkg, idx, arr) { - <span class="reserved">if</span> (pkg in cfg.gJSONData.commentPackages) { - installedPackages[pkg] = cfg.gJSONData.commentPackages[pkg]; - } - }); - } - <span class="reserved">return</span> installedPackages; -}; - -<span class="comment">/** - * Actual execution function - * - * <span class="attrib">@param</span> cmdLabel String with the name of the command to be executed - * <span class="attrib">@param</span> cmdParams Object with the appropriate parameters for the command - */</span> -BZPage.<span class="reserved">prototype</span>.centralCommandDispatch = <span class="reserved">function</span> centralCommandDispatch (cmdLabel, cmdParams) { - switch (cmdLabel) { - case <span class="literal">"resolution"</span>: - case <span class="literal">"product"</span>: - case <span class="literal">"component"</span>: - case <span class="literal">"version"</span>: - case <span class="literal">"priority"</span>: - <span class="reserved">this</span>.selectOption(cmdLabel, cmdParams); - break; - case <span class="literal">"status"</span>: - <span class="reserved">this</span>.selectOption(<span class="literal">"bug_status"</span>, cmdParams); - break; - case <span class="literal">"platform"</span>: - <span class="reserved">this</span>.selectOption(<span class="literal">"rep_platform"</span>, cmdParams); - break; - case <span class="literal">"os"</span>: - <span class="reserved">this</span>.selectOption(<span class="literal">"op_sys"</span>, cmdParams); - break; - case <span class="literal">"severity"</span>: - <span class="reserved">this</span>.selectOption(<span class="literal">"bug_severity"</span>, cmdParams); - break; - case <span class="literal">"target"</span>: - <span class="reserved">this</span>.selectOption(<span class="literal">"target_milestone"</span>, cmdParams); - break; - case <span class="literal">"addKeyword"</span>: - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"keywords"</span>,cmdParams); - break; - case <span class="literal">"removeKeyword"</span>: - <span class="reserved">this</span>.removeStuffFromTextBox(<span class="literal">"keywords"</span>, cmdParams); - break; - case <span class="literal">"addWhiteboard"</span>: - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"status_whiteboard"</span>,cmdParams); - break; - case <span class="literal">"removeWhiteboard"</span>: - <span class="reserved">this</span>.removeStuffFromTextBox(<span class="literal">"status_whiteboard"</span>,cmdParams); - break; - case <span class="literal">"assignee"</span>: - <span class="reserved">this</span>.changeAssignee(cmdParams); - break; - case <span class="literal">"qacontact"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"bz_qa_contact_edit_action"</span>); - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"qa_contact"</span>).value = cmdParams; - break; - case <span class="literal">"url"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"bz_url_edit_action"</span>); - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"bug_file_loc"</span>).value = cmdParams; - break; - <span class="comment">// TODO dependson/blocked doesn't work. Find out why.</span> - case <span class="literal">"addDependsOn"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"dependson_edit_action"</span>); - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"dependson"</span>, cmdParams); - break; - case <span class="literal">"removeDependsOn"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"dependson_edit_action"</span>); - <span class="reserved">this</span>.removeStuffFromTextBox(<span class="literal">"dependson"</span>, cmdParams); - break; - case <span class="literal">"addBlocks"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"blocked_edit_action"</span>); - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"blocked"</span>, cmdParams); - break; - case <span class="literal">"removeBlocks"</span>: - <span class="reserved">this</span>.clickMouse(<span class="literal">"blocked_edit_action"</span>); - <span class="reserved">this</span>.removeStuffFromTextBox(<span class="literal">"blocked"</span>, cmdParams); - break; - case <span class="literal">"comment"</span>: - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"comment"</span>, cmdParams); - break; - case <span class="literal">"commentIdx"</span>: - var commentText = <span class="reserved">this</span>.commentStrings[cmdParams]; - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"comment"</span>, commentText); - break; - case <span class="literal">"setNeedinfo"</span>: - <span class="comment">// cmdParams are actually ignored for now; we may in future</span> - <span class="comment">// distinguish different actors to be target of needinfo</span> - <span class="reserved">this</span>.setNeedinfoReporter(); - break; - case <span class="literal">"addCC"</span>: - <span class="reserved">this</span>.addToCCList(cmdParams); - break; - <span class="comment">// TODO flags, see also</span> - - case <span class="literal">"commit"</span>: - <span class="reserved">if</span> (cmdParams) { - <span class="comment">// Directly commit the form</span> - <span class="reserved">this</span>.doc.forms.namedItem(<span class="literal">"changeform"</span>).submit(); - } - break; - } -}; - -<span class="comment">/** - * Take the ID of the package/id combination, and execute it - * - * <span class="attrib">@param</span> String combined package + "//" + id combination - * Fetches the command object from this.installedPackages and then - * goes through all commands contained in it, and calls - * this.centralCommandDispatch to execute them. - */</span> -BZPage.<span class="reserved">prototype</span>.executeCommand = <span class="reserved">function</span> executeCommand (cmd) { - var cmdArr = cmd.split(<span class="literal">"//"</span>); - var commentObj = <span class="reserved">this</span>.packages[cmdArr[0]][cmdArr[1]]; - - <span class="reserved">for</span> (var key in commentObj) { - <span class="reserved">this</span>.centralCommandDispatch(key,commentObj[key]); - } -}; - -<span class="comment">/** - * Add XGL to the CC list - * - * <span class="attrib">@param</span> evt Event which made this function active - * <span class="attrib">@return</span> none - */</span> -BZPage.<span class="reserved">prototype</span>.changeAssignee = <span class="reserved">function</span> changeAssignee (newAssignee) { - var defAssigneeButton = null; - <span class="reserved">this</span>.addToCCList(<span class="reserved">this</span>.owner); - <span class="reserved">if</span> (newAssignee === null) { - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"set_default_assignee"</span>).removeAttribute( - <span class="literal">"checked"</span>); - <span class="reserved">return</span> ; - } - - <span class="reserved">if</span> (<span class="reserved">this</span>.getDefaultAssignee) { - <span class="reserved">if</span> (newAssignee === <span class="literal">"default"</span>) { - var defAss = <span class="reserved">this</span>.getDefaultAssignee(); - <span class="reserved">if</span> (defAss) { - newAssignee = defAss; - } <span class="reserved">else</span> { - <span class="reserved">return</span> ; - } - } - } - - <span class="reserved">if</span> (newAssignee) { - <span class="reserved">this</span>.clickMouse(<span class="literal">"bz_assignee_edit_action"</span>); - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"assigned_to"</span>).value = newAssignee; - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"set_default_assignee"</span>).checked = false; - defAssigneeButton = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"setDefaultAssignee_btn"</span>); - <span class="reserved">if</span> (defAssigneeButton) { - defAssigneeButton.style.display = <span class="literal">"none"</span>; - } - } -}; - -<span class="comment">/** - * Adds new option to the 'comment_action' scroll down box - * - * <span class="attrib">@param</span> pkg String package name - * <span class="attrib">@param</span> cmd String with the name of the command - * If the 'comment_action' scroll down box doesn't exist, this - * function will set up new one. - */</span> -BZPage.<span class="reserved">prototype</span>.addToCommentsDropdown = <span class="reserved">function</span> addToCommentsDropdown (pkg, cmd) { - var select = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comment_action"</span>); - <span class="reserved">if</span> (!select) { - var that = <span class="reserved">this</span>; - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comments"</span>).innerHTML += - <span class="literal">"<div id='make_bugzilla_comment_action'>"</span> + - <span class="literal">" <label for='comment_action'>Add Comment: </label>"</span> + - <span class="literal">" <select id='comment_action'>"</span> + - <span class="literal">" <option value=''>-- Select Comment from List --</option>"</span> + - <span class="literal">"</div>"</span>; - select = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comment_action"</span>); - select.addEventListener(<span class="literal">"change"</span>, <span class="reserved">function</span> () { - var value = <span class="literal">""</span>; - var valueElement = that.doc.getElementById(<span class="literal">"comment_action"</span>); - <span class="reserved">if</span> (valueElement) { - value = valueElement.getAttribute(<span class="literal">"value"</span>); - } <span class="reserved">else</span> { - <span class="reserved">return</span>; - } - that.executeCommand(value); - }, false); - } - - var opt = <span class="reserved">this</span>.doc.createElement(<span class="literal">"option"</span>); - opt.value = pkg + <span class="literal">"//"</span> + cmd; - opt.textContent = <span class="reserved">this</span>.packages[pkg][cmd].name; - select.appendChild(opt); -}; - -<span class="comment">/** - * Generic function to add new button to the page. Actually copies new button - * from the old one (in order to have the same look-and-feel, etc. - * - * <span class="attrib">@param</span> location Object around which the new button will be added - * <span class="attrib">@param</span> after Boolean before or after location ? - * <span class="attrib">@param</span> pkg String which package to take the command from - * <span class="attrib">@param</span> id String which command to take - * <span class="attrib">@return</span> none - */</span> -BZPage.<span class="reserved">prototype</span>.createNewButton = <span class="reserved">function</span> createNewButton (location, after, pkg, id) { - var that = <span class="reserved">this</span>; - var cmdObj = <span class="reserved">this</span>.packages[pkg][id]; - var newId = id + <span class="literal">"_btn"</span>; - var label = cmdObj.name; - - <span class="comment">// protection against double-firings</span> - <span class="reserved">if</span> (<span class="reserved">this</span>.doc.getElementById(newId)) { - console.log(<span class="literal">"Element with id "</span> + newId + <span class="literal">"already exists!"</span>); - <span class="reserved">return</span> ; - } - - <span class="comment">// creation of button might be conditional on existence of data in constantData</span> - <span class="reserved">if</span> (<span class="literal">"ifExist"</span> in cmdObj) { - <span class="reserved">if</span> (!(cmdObj.ifExist in <span class="reserved">this</span>.constantData)) { - <span class="reserved">return</span> ; - } - } - - var newButton = <span class="reserved">this</span>.doc.createElement(<span class="literal">"input"</span>); - newButton.setAttribute(<span class="literal">"id"</span>, newId); - newButton.setAttribute(<span class="literal">"type"</span>, <span class="literal">"button"</span>); - newButton.value = label; - newButton.addEventListener(<span class="literal">"click"</span>, <span class="reserved">function</span>(evt) { - that.executeCommand(pkg + <span class="literal">"//"</span> + id); - }, false); - - var originalLocation = <span class="reserved">this</span>.doc.getElementById(location); - - <span class="reserved">if</span> (after) { - originalLocation.parentNode.insertBefore(newButton, - originalLocation.nextSibling); - originalLocation.parentNode.insertBefore(<span class="reserved">this</span>.doc - .createTextNode(<span class="literal">"\u00A0"</span>), newButton); - } <span class="reserved">else</span> { - originalLocation.parentNode.insertBefore(newButton, originalLocation); - originalLocation.parentNode.insertBefore(<span class="reserved">this</span>.doc - .createTextNode(<span class="literal">"\u00A0"</span>), originalLocation); - } -}; - -<span class="comment">/** - * - */</span> -BZPage.<span class="reserved">prototype</span>.generateButtons = <span class="reserved">function</span> generateButtons () { - var topRowPosition = <span class="literal">"topRowPositionID"</span>; - var bottomRowPosition = <span class="literal">"commit"</span>; - - <span class="comment">// create anchor for the top toolbar</span> - var commentBox = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comment"</span>); - var brElement = <span class="reserved">this</span>.doc.createElement(<span class="literal">"br"</span>); - brElement.setAttribute(<span class="literal">"id"</span>,topRowPosition); - commentBox.parentNode.normalize(); - commentBox.parentNode.insertBefore(brElement, commentBox); - - <span class="reserved">for</span> (var pkg in <span class="reserved">this</span>.packages) { - <span class="reserved">for</span> (var cmdIdx in <span class="reserved">this</span>.packages[pkg]) { - var cmdObj = <span class="reserved">this</span>.packages[pkg][cmdIdx]; - switch (cmdObj.position) { - case <span class="literal">"topRow"</span>: - <span class="reserved">this</span>.createNewButton(topRowPosition, false, pkg, cmdIdx); - break; - case <span class="literal">"bottomRow"</span>: - <span class="reserved">this</span>.createNewButton(bottomRowPosition, false, pkg, cmdIdx); - break; - case <span class="literal">"dropDown"</span>: - <span class="reserved">this</span>.addToCommentsDropdown(pkg,cmdIdx); - break; - default: <span class="comment">// [+-]ID</span> - var firstChr = cmdObj.position.charAt(0); - var newId = cmdObj.position.substr(1); - <span class="reserved">this</span>.createNewButton(newId, firstChr === <span class="literal">"+"</span>, pkg, cmdIdx); - break; - } - } - } -}; - -<span class="comment">/** - * Get the current email of the reporter of the bug. - * - * <span class="attrib">@return</span> string - */</span> -BZPage.<span class="reserved">prototype</span>.getReporter = <span class="reserved">function</span> getReporter () { - var reporterElement = <span class="reserved">this</span>.doc. - querySelector(<span class="literal">"#bz_show_bug_column_2 > table .vcard:first-of-type > a"</span>); - <span class="reserved">if</span> (reporterElement) { - <span class="reserved">return</span> reporterElement.textContent; - } - <span class="reserved">return</span> <span class="literal">""</span>; -}; - -<span class="comment">/** - * Get the current version of the Fedora release ... even if changed meanwhile - * by bug triager. - * - * <span class="attrib">@return</span> string (integer for released Fedora, float for RHEL, rawhide) - */</span> -BZPage.<span class="reserved">prototype</span>.getVersion = <span class="reserved">function</span> getVersion () { - var verStr = <span class="reserved">this</span>.getOptionValue(<span class="literal">"version"</span>).toLowerCase(); - var verNo = 0; - <span class="reserved">if</span> (/rawhide/.test(verStr)) { - verNo = 999; - } <span class="reserved">else</span> { - verNo = Number(verStr); - } - <span class="reserved">return</span> verNo; -}; - -BZPage.<span class="reserved">prototype</span>.commentsWalker = <span class="reserved">function</span> commentsWalker (fce) { - var comments = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"comments"</span>).getElementsByClassName( - <span class="literal">"bz_comment"</span>); - Array.forEach(comments, <span class="reserved">function</span>(item) { - fce(item); - }, <span class="reserved">this</span>); -}; - -<span class="comment">/** - * Set background color of all comments made by reporter in ReporterColor color - * - */</span> -BZPage.<span class="reserved">prototype</span>.checkComments = <span class="reserved">function</span> checkComments () { - var that = <span class="reserved">this</span>; - <span class="reserved">this</span>.commentsWalker(<span class="reserved">function</span>(x) { - var email = x.getElementsByClassName(<span class="literal">"vcard"</span>)[0] - .getElementsByTagName(<span class="literal">"a"</span>)[0].textContent; - <span class="reserved">if</span> (new RegExp(that.reporter).test(email)) { - x.style.backgroundColor = that.ReporterColor.toString(); - } - }); -}; - -BZPage.<span class="reserved">prototype</span>.collectComments = <span class="reserved">function</span> collectComments () { - var outStr = <span class="literal">""</span>; - <span class="reserved">this</span>.commentsWalker(<span class="reserved">function</span>(x) { - outStr += x.getElementsByTagName(<span class="literal">"pre"</span>)[0].textContent + <span class="literal">"\n"</span>; - }); - <span class="reserved">return</span> outStr.trim(); -}; - - -<span class="comment">/** - * Select option with given label on the <SELECT> element with given id. - * - * Also execute change HTMLEvent, so that the form behaves accordingly. - * - * <span class="attrib">@param</span> id - * <span class="attrib">@param</span> label - * <span class="attrib">@return</span> none - * - * FIXME bugzilla-comments version has this signature: - * selectOption = function selectOption(select, value) { - var doc = select[0].ownerDocument; - select.val(value); - */</span> -BZPage.<span class="reserved">prototype</span>.selectOption = <span class="reserved">function</span> selectOption (id, label) { - var sel = <span class="reserved">this</span>.doc.getElementById(id); - sel.value = label; - var intEvent = <span class="reserved">this</span>.doc.createEvent(<span class="literal">"HTMLEvents"</span>); - intEvent.initEvent(<span class="literal">"change"</span>, true, true); - sel.dispatchEvent(intEvent); -}; - -<span class="comment">/** - * Send mouse click to the specified element - * - * <span class="attrib">@param</span> String ID of the element to send mouseclick to - * <span class="attrib">@return</span> None - */</span> -BZPage.<span class="reserved">prototype</span>.clickMouse = <span class="reserved">function</span> clickMouse (targetID) { - var localEvent = <span class="reserved">this</span>.doc.createEvent(<span class="literal">"MouseEvents"</span>); - localEvent.initMouseEvent(<span class="literal">"click"</span>, true, true, <span class="reserved">this</span>.doc.defaultView, 0, 0, - 0, 0, 0, false, false, false, false, 0, null); - <span class="reserved">this</span>.doc.getElementById(targetID).dispatchEvent(localEvent); -}; - -<span class="comment">/** - * Add object to the text box (comment box or status whiteboard) - * - * <span class="attrib">@param</span> id String with the id of the element - * <span class="attrib">@param</span> stuff String/Array to be added to the comment box - * - * <span class="attrib">@return</span> none - */</span> -BZPage.<span class="reserved">prototype</span>.addStuffToTextBox = <span class="reserved">function</span> addStuffToTextBox (id, stuff) { - var textBox = <span class="reserved">this</span>.doc.getElementById(id); - <span class="reserved">if</span> (textBox.tagName.toLowerCase() === <span class="literal">"textarea"</span>) { - stuff = textBox.value ? <span class="literal">"\n\n"</span> + stuff : stuff; - textBox.value += stuff; - } <span class="reserved">else</span> { - textBox.value = util.addCSVValue(textBox.value,stuff); - } -}; - -<span class="comment">/** - * Remove a keyword from the element if it is there - * - * <span class="attrib">@param</span> id String with the id of the element - * <span class="attrib">@param</span> stuff String/Array with keyword(s) to be removed - */</span> -BZPage.<span class="reserved">prototype</span>.removeStuffFromTextBox = <span class="reserved">function</span> removeStuffFromTextBox (id, stuff) { - var changedElement = <span class="reserved">this</span>.getElementById(id); - changedElement.value = util.removeCSVValue(changedElement.value,stuff); -}; - -<span class="comment">/** - * generalized hasKeyword ... search in the value of the box with given id - * - * <span class="attrib">@param</span> id String with ID of the element we want to check - * <span class="attrib">@param</span> str String to be searched for - * <span class="attrib">@return</span> Boolean found? - */</span> -BZPage.<span class="reserved">prototype</span>.idContainsWord = <span class="reserved">function</span> idContainsWord (id, str) { - var kwd = <span class="literal">""</span>; - try { - kwd = <span class="reserved">this</span>.doc.getElementById(id).value; - } catch (e) { - <span class="comment">// For those who don't have particular element at all or if it is empty</span> - <span class="reserved">return</span> false; - } - <span class="reserved">return</span> (kwd.trim().indexOf(str) !== -1); -}; - -<span class="comment">/** - * Check for the presence of a keyword - * - * <span class="attrib">@param</span> str String with the keyword - * <span class="attrib">@return</span> Boolean - */</span> -BZPage.<span class="reserved">prototype</span>.hasKeyword = <span class="reserved">function</span> hasKeyword (str) { - <span class="reserved">return</span> (<span class="reserved">this</span>.idContainsWord(<span class="literal">'keywords'</span>, str)); -}; - -<span class="comment">/** - * - */</span> -BZPage.<span class="reserved">prototype</span>.getOptionValue = <span class="reserved">function</span> getOptionValue (id) { - <span class="comment">// Some special bugs don't have version for example</span> - var element = <span class="reserved">this</span>.doc.getElementById(id); - <span class="reserved">if</span> (element) { - <span class="reserved">return</span> element.value; - } <span class="reserved">else</span> { - console.error(<span class="literal">"Failed to find element with id = "</span> + id); - <span class="reserved">return</span> <span class="literal">"#NA"</span>; - } -}; - -<span class="comment">/** - * Set the bug to NEEDINFO state - * - * Working function. - * <span class="attrib">@return</span> none - * <span class="attrib">@todo</span> TODO we may extend this to general setNeedinfo function - * with parameter [reporter|assignee|general-email-address] - */</span> -BZPage.<span class="reserved">prototype</span>.setNeedinfoReporter = <span class="reserved">function</span> setNeedinfoReporter () { - <span class="reserved">this</span>.clickMouse(<span class="literal">"needinfo"</span>); - <span class="reserved">this</span>.selectOption(<span class="literal">"needinfo_role"</span>, <span class="literal">"reporter"</span>); -}; - -<span class="comment">/** - * - */</span> -BZPage.<span class="reserved">prototype</span>.getOwner = <span class="reserved">function</span> getOwner () { - var priorityParent = <span class="reserved">this</span>.doc.querySelector(<span class="literal">"label[for~='target_milestone']"</span>) - .parentNode.parentNode.parentNode; - var assigneeAElement = priorityParent.querySelector(<span class="literal">"tr:nth-of-type(1) a.email"</span>); - var assgineeHref = decodeURI(assigneeAElement.getAttribute(<span class="literal">"href"</span>)); - var email = assgineeHref.split(<span class="literal">":"</span>)[1]; - <span class="reserved">return</span> email; -}; - -<span class="comment">/** - * Get login of the currently logged-in user. - * - * <span class="attrib">@return</span> String with the login name of the currently logged-in user - */</span> -BZPage.<span class="reserved">prototype</span>.getLogin = <span class="reserved">function</span> getLogin () { - var lastLIElement = <span class="reserved">this</span>.doc.querySelector(<span class="literal">"#header ul.links li:last-of-type"</span>); - var loginArr = lastLIElement.textContent.split(<span class="literal">"\n"</span>); - var loginStr = loginArr[loginArr.length - 1].trim(); - <span class="reserved">return</span> loginStr; -}; - -<span class="comment">/** - * Return maintainer which is per default by bugzilla - * (which is not necessarily the one who is default maintainer per component) - * - * <span class="attrib">@return</span> String with the maintainer's email address - */</span> -BZPage.<span class="reserved">prototype</span>.getDefaultBugzillaMaintainer = <span class="reserved">function</span> getDefaultBugzillaMaintainer (component) { - var address = util.filterByRegexp(<span class="reserved">this</span>.defBugzillaMaintainerArr, component); - <span class="reserved">return</span> address; -}; - -<span class="comment">/** - * collect the list of attachments in a structured format - * - * <span class="attrib">@return</span> Array of arrays, one for each attachments; - * each record has string name of the attachment, integer its id number, - * string of MIME type, integer of size in kilobytes, and the whole - * element itself - */</span> -BZPage.<span class="reserved">prototype</span>.getAttachments = <span class="reserved">function</span> getAttachments () { - var outAtts = []; - var atts = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"attachment_table"</span>) - .getElementsByTagName(<span class="literal">"tr"</span>); - <span class="reserved">for</span> ( var i = 1, ii = atts.length - 1; i < ii; i++) { - outAtts.push(<span class="reserved">this</span>.parseAttachmentLine(atts[i])); - } - <span class="reserved">return</span> outAtts; -}; - -<span class="comment">/** - * returns password from the current storage, or if there isn't - * one, then it will ask user for it. - * - * <span class="attrib">@return</span> String with the password - */</span> -BZPage.<span class="reserved">prototype</span>.getPassword = <span class="reserved">function</span> getPassword () { - <span class="reserved">if</span> (preferences.isSet(<span class="literal">"BZpassword"</span>)) { - <span class="reserved">return</span> preferences.get(<span class="literal">"BZpassword"</span>,undefined); - } <span class="reserved">else</span> { - var passwordText = util.getPassword(); - <span class="reserved">if</span> (passwordText) { - preferences.set(<span class="literal">"BZpassword"</span>, passwordText); - } - } -}; - -<span class="comment">/** - * - */</span> -BZPage.<span class="reserved">prototype</span>.setUpLogging = <span class="reserved">function</span> setUpLogging () { - <span class="comment">// Protection against double-call</span> - <span class="reserved">if</span> (<span class="reserved">this</span>.doc.getElementById(<span class="literal">"generateTSButton"</span>)) { - console.log(<span class="literal">"Logging has been already set up!"</span>); - <span class="reserved">return</span> ; - } - - <span class="comment">// For adding additional buttons to the top toolbar</span> - var additionalButtons = <span class="reserved">this</span>.doc.querySelector(<span class="literal">"#bugzilla-body *.related_actions"</span>); - var that = <span class="reserved">this</span>; - - <span class="comment">// logging all submits for timesheet</span> - <span class="comment">// FIXME we should merge in functionality of RHBugzillaPage.submitCallback</span> - <span class="comment">// and actually make it working</span> - <span class="comment">// Maybe rewriting whole offline capability into a separate object?</span> - <span class="reserved">if</span> (!<span class="reserved">this</span>.submitHandlerInstalled) { - console.log(<span class="literal">"Installing submit callback!"</span>); - <span class="reserved">this</span>.doc.forms.namedItem(<span class="literal">"changeform"</span>).addEventListener(<span class="literal">"submit"</span>,<span class="reserved">function</span> (evt) { - console.log(<span class="literal">"Submit callback!"</span>); - - var resp = that.log.addLogRecord(that); - <span class="reserved">if</span> (resp === null) { - console.log(<span class="literal">"Avoiding submitting!"</span>); - <span class="comment">// FIXME doesn't work ... still submitting'</span> - evt.stopPropagation(); - evt.preventDefault(); - } - }, false); - <span class="reserved">this</span>.submitHandlerInstalled = true; - } - - var generateTimeSheetUI = <span class="reserved">this</span>.doc.createElement(<span class="literal">"li"</span>); - generateTimeSheetUI.innerHTML = <span class="literal">"\u00A0-\u00A0<a href='#' id='generateTSButton'>"</span> - + <span class="literal">"Generate timesheet</a>"</span>; - additionalButtons.appendChild(generateTimeSheetUI); - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"generateTSButton"</span>).addEventListener( - <span class="literal">"click"</span>, - <span class="reserved">function</span>(evt) { - that.log.createBlankPage.call(that.log, <span class="literal">"TimeSheet"</span>, - that.log.generateTimeSheet); - evt.stopPropagation(); - evt.preventDefault(); - }, false); - - var clearLogsUI = <span class="reserved">this</span>.doc.createElement(<span class="literal">"li"</span>); - clearLogsUI.innerHTML = <span class="literal">"\u00A0-\u00A0<a href='#' id='clearLogs'>"</span> - + <span class="literal">"Clear logs</a>"</span>; - additionalButtons.appendChild(clearLogsUI); - var clearLogAElem = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"clearLogs"</span>); - clearLogAElem.addEventListener(<span class="literal">"click"</span>, <span class="reserved">function</span>() { - that.log.store = {}; - <span class="reserved">this</span>.style.color = that.log.EmptyLogsColor; - <span class="reserved">this</span>.style.fontWeight = <span class="literal">"normal"</span>; - console.log(<span class="literal">"this.store wiped out!"</span>); - }, false); - - <span class="reserved">if</span> (<span class="reserved">this</span>.log.store.length > 0) { - clearLogAElem.style.color = <span class="reserved">this</span>.log.FullLogsColor; - clearLogAElem.style.fontWeight = <span class="literal">"bolder"</span>; - } <span class="reserved">else</span> { - clearLogAElem.style.color = <span class="reserved">this</span>.log.EmptyLogsColor; - clearLogAElem.style.fontWeight = <span class="literal">"normal"</span>; - } -}; - -<span class="comment">/** - * adds a person to the CC list, if it isn't already there - * - * <span class="attrib">@param</span> who String with email address or "self" if the current user - * of the bugzilla should be added - */</span> -BZPage.<span class="reserved">prototype</span>.addToCCList = <span class="reserved">function</span> addToCCList (who) { - <span class="reserved">if</span> (!who) { - <span class="reserved">return</span> ; - } - <span class="reserved">if</span> (who === <span class="literal">"self"</span>) { - <span class="reserved">this</span>.doc.getElementById(<span class="literal">"addselfcc"</span>).checked = true; - } <span class="reserved">else</span> { - <span class="reserved">this</span>.clickMouse(<span class="literal">"cc_edit_area_showhide"</span>); - <span class="reserved">if</span> (!util.isInList(who, <span class="reserved">this</span>.CCList)) { - <span class="reserved">this</span>.addStuffToTextBox(<span class="literal">"newcc"</span>,who); - } - } -}; - -<span class="comment">/** - * a collect a list of emails on CC list - * - * <span class="attrib">@return</span> Array with email addresses as Strings. - */</span> -BZPage.<span class="reserved">prototype</span>.getCCList = <span class="reserved">function</span> getCCList () { - var CCListSelect = <span class="reserved">this</span>.doc.getElementById(<span class="literal">"cc"</span>); - outCCList = []; - <span class="reserved">if</span> (CCListSelect) { - outCCList = Array.map(CCListSelect.options, <span class="reserved">function</span>(item) { - <span class="reserved">return</span> item.value; - }); - } - <span class="reserved">return</span> outCCList; -}; - -<span class="comment">// exports.BZPage = apiUtils.publicConstructor(BZPage);</span> -exports.BZPage = BZPage;</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> </td> - <td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td> - - - <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td> - <td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </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"> - PREV - NEXT</font></td> -<td bgcolor="white" class="NavBarCell2"><font size="-2"> - <a href="index.html" target="_top"><b>FRAMES</b></a> - <a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a> - -<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> |