diff options
-rw-r--r-- | data/RH_Data-packages.json | 379 | ||||
-rw-r--r-- | jsons/BugZappers_data.json (renamed from data/BugZappers_data.json) | 0 | ||||
-rw-r--r-- | jsons/RH_Data-packages.json | 169 | ||||
-rwxr-xr-x | jsons/drm_pciids.awk (renamed from data/drm_pciids.awk) | 0 | ||||
-rw-r--r-- | jsons/drm_pciids.json (renamed from data/drm_pciids.json) | 0 | ||||
-rw-r--r-- | lib/bzpage.js | 54 | ||||
-rw-r--r-- | lib/main.js | 20 | ||||
-rw-r--r-- | lib/offline-support.js | 153 | ||||
-rw-r--r-- | lib/rhbzpage.js | 227 | ||||
-rw-r--r-- | lib/util.js | 22 | ||||
-rw-r--r-- | tests/test-util.js | 38 |
11 files changed, 436 insertions, 626 deletions
diff --git a/data/RH_Data-packages.json b/data/RH_Data-packages.json deleted file mode 100644 index b0cb6de..0000000 --- a/data/RH_Data-packages.json +++ /dev/null @@ -1,379 +0,0 @@ -{ - "commentPackages": { - "test": { - "test-all": { - "name": "Test lots of things", - "comment": "some comment", - "position": "topRow,bottomRow,dropDown,[+-]ID", - "product": "Thunderbird", - "component": "Internal Components", - "priority": "P1", - "severity": "major", - "assignee": "mschroeder", - "qacontact": "foobar", - "url": "http://example.com", - "addDependsOn": "123", - "removeDependsOn": "456", - "addBlocks": "789", - "removeBlocks": "101112", - "addWhiteboard": [ - "a", - "b", - "c" - ], - "removeWhiteboard": [ - "a", - "b" - ], - "addKeyword": [ - "d", - "e" - ], - "removeKeyword": "e", - "url": "http://example.com", - "status": "RESOLVED", - "resolution": "INCOMPLETE", - "version": "Lightning 0.3", - "os": "All", - "platform": "All", - "setNeedinfo": true - } - }, - "rh-common": { - "markTriaged": { - "position": "-commit_middle", - "name": "Mark Triaged", - "markTriaged": true, - "assignee": null - }, - "addnoresponse": { - "name": "NoRespns", - "position": "topRow", - "commentIdx": "noResponseString", - "status": "CLOSED", - "resolution": "INSUFFICIENT_DATA" - }, - "addcloseupstream": { - "name": "CloseUP", - "position": "topRow", - "closeUpstream": true - }, - "moveyourbutt": { - "name": "InfRemind", - "position": "topRow", - "commentIdx": "moveYourButString", - "setNeedinfo": true - }, - "needinforbtn": { - "name": "NEEDINFO", - "position": "bottomRow", - "setNeedinfo": true - }, - "closeoldrhel": { - "name": "old", - "position": "bottomRow", - "commentIdx": "obsoleteRHELString", - "status": "CLOSED", - "resolution": "WONTFIX" - }, - "notriagebtn": { - "name": "noTriage", - "position": "bottomRow", - "comment": "This bug has been triaged", - "status": "ASSIGNED", - "addCC": "self" - }, - "nodebugsymbols": { - "name": "noDbg", - "position": "bottomRow", - "commentIdx": "noDebugSymbols", - "status": "CLOSED", - "resolution": "INSUFFICIENT_DATA" - }, - "issuetrackerbtn": { - "position": "bottomRow", - "name": "RHEL", - "commentIdx": "RHELString", - "setNeedinfo": true - }, - "closeOnRetest": { - "position": "bottomRow", - "name": "Retest", - "commentIdx": "thankLettingUsKnow", - "status": "CLOSED", - "computeResolution": true - }, - "queryButton": { - "position": "-brElementPlacer_location", - "name": "Query for string", - "queryStringOurBugzilla": true - }, - "sendUpstream": { - "position": "-brElementPlacer_location", - "name": "Send upstream", - "sendBugUpstream": true - }, - "upstreamQuery": { - "position": "-brElementPlacer_location", - "name": "Query upstream", - "ifExist": "queryUpstreamBug", - "queryStringUpstreamBugzilla": true - }, - "setDefaultAssignee": { - "position": "+bz_assignee_edit_container", - "name": "Def. Assignee", - "ifExist": "defaultAssigneeTrigger", - "assignee": "default" - } - }, - "rh-gecko": { - "addgetffrepro": { - "name": "Repro", - "position": "topRow", - "commentIdx": "getAbrtReproInfo", - "setNeedinfo": true - }, - "addgetfirefoxinfo": { - "name": "GeckInf", - "position": "topRow", - "commentIdx": "getFirefoxBacktraceString", - "setNeedinfo": true - }, - "webfailure": { - "name": "Bad site", - "position": "topRow", - "commentIdx": "websiteFailure", - "status": "CLOSED", - "resolution": "NOTABUG" - }, - "crashInFlash": { - "name": "flashCrash", - "position": "topRow", - "commentIdx": "flashCrashString", - "status": "CLOSED", - "resolution": "CANTFIX" - } - }, - "rh-xorg": { - "addgetlogstext": { - "name": "X logs", - "position": "topRow", - "commentIdx": "getLogsString", - "setNeedinfo": true - }, - "closenvidia": { - "name": "nVidia", - "position": "bottomRow", - "commentIdx": "cantfixNvidiaString", - "status": "CLOSED", - "resolution": "CANTFIX" - }, - "xloglivecdbtn": { - "position": "bottomRow", - "name": "InstFail", - "commentIdx": "getLogsLiveCDString", - "setNeedinfo": true - }, - "chipMagic": { - "position": "+status_whiteboard", - "name": "Fill In", - "ifExist": "chipMagicTrigger", - "chipMagic": true - } - } - }, - "commentStrings": { - "noRHEL4String": "I don't think this will be fixed for RHEL4, which support covers now only security and major bugs.\n\nClosing as WONTFIX.", - "thankLettingUsKnow": "Thank you for letting us know.", - "noDebugSymbols": "Thank you for taking the time to report this bug report. Unfortunately, that stack trace is not very useful in determining the cause of the crash, because there are no debugging symbols loaded (probably abrt failed to load them).\n\nUnfortunately, we cannot use this backtrace.\n\nClosing as INSUFFICIENT_DATA.", - "noTriageString": "There is nothing to triage here.\n\nSwitching to ASSIGNED so that developers have responsibility to do whatever they want to do with it.", - "getAbrtReproInfo": "Reporter, could you please describe us what you have done to get to this point, and how we can reproduce this issue here? Is there anything special about your system, network, configuration which we need to replicate here in order to reproduce your problem please?", - "getLogsString": "Thanks for the bug report. We have reviewed the information you have provided above, and there is some additional information we require that will be helpful in our diagnosis of this issue.\n\nPlease add drm.debug=0x04 to the kernel command line, restart computer, and attach\n\n* your X server config file (/etc/X11/xorg.conf, if available),\n* X server log file (/var/log/Xorg.*.log)\n* output of the dmesg command, and\n* system log (/var/log/messages)\n\nto the bug report as individual uncompressed file attachments using the bugzilla file attachment link above.\n\nWe will review this issue again once you've had a chance to attach this information.\n\nThanks in advance.", - "getLogsLiveCDString": "Thanks for the bug report. We have reviewed the information you have provided above, and there is some additional information especially concerning your hardware we require that will be helpful in our diagnosis of this issue.\n\nIf the anaconda crashes during the switching to the graphic mode, most likely the problem lies in Xorg support for your graphics chip. There are couple of options how we can obtain information necessary for resolving the issue.\n\nIf the computer is not completely frozen when installation fails, switch to the console (Ctrl+Alt+F2) and copy /tmp/X* and /var/log/anaconda.xlog to some other place -- USB stick, some other computer via network, somewhere on the Internet, and please attach it to the bug report as individual uncompressed file attachments using the bugzilla file attachment link above.\n\nIf the computer is completely useless after installation fails, you can also install Fedora with a VESA mode driver (see http://docs.fedoraproject.org/en-US/Fedora/13/html/Installation_Guide/\nfor more information on that). Then after successful installation you can collect /var/log/anaconda.xlog, /var/log/Xorg.0.log, and the output of the program dmesg instead.\n\nOr you can install Fedora in a text mode completely, and then start X after that. If it fails, still /var/log/Xorg.0.log and the output of dmesg program from the failed attempt to start X would be useful.\n\nWe will review this issue again once you've had a chance to attach this information.\n\nThank you very much in advance.", - "getFirefoxBacktraceString": "Thanks for the bug report. We have reviewed the information you have provided above, and there is some additional information we require that will be helpful in our diagnosis of this issue.\n\nFirst of all, could we get output of the command\n\n\u0009rpm -qa \\*xulrun\\* \\*firefox\\* \\*mozilla\\* \\*flash\\* \\*plugin\\*\n\nPlease also install firefox-debuginfo (debuginfo-install is from\nyum-utils package).\n\n\u0009debuginfo-install firefox\n\nThen run firefox with a parameter -g. That will start firefox running inside of gdb debugger. Then use command run and do whatever you did to make firefox crash. When it happens, you should go back to the gdb and run\n\n\u0009(gdb) thread apply all backtrace\n\nThis produces usually many screens of the text. Copy all of them into a text editor and attach the file to the bug as an uncompressed attachment.\n\nPlease, install also valgrind (from valgrind package) and run\n\n\u0009valgrind --trace-children=yes --log-file=/tmp/firefox-valgrind-log.txt /usr/bin/firefox\n\n(that's one line command, browser breaking this line into two notwithstanding)\n\nPlease, attach the file /tmp/firefox-valgrind-log.txt to this bug as an attachment as well.\n\nWe will review this issue again once you've had a chance to attach this information.\n\nThanks in advance.", - "noResponseString": "Since there are insufficient details provided in this report for us to investigate the issue further, and we have not received feedback to the information we have requested above, we will assume the problem was not reproducible, or has been fixed in one of the updates we have released for the reporter's distribution.\n\nUsers who have experienced this problem are encouraged to upgrade to the latest update of their distribution, and if this issue turns out to still be reproducible in the latest update, please reopen this bug with additional information.\n\nClosing as INSUFFICIENT_DATA.", - "websiteFailure": "To report a broken website, first please make sure that you are running the latest release of Firefox (i.e., updated from updates-testing repository for your distribution or Rawhide).\n\nThen, if you can still reproduce the issue, pull down the 'Help' menu and select 'Report Broken Web Site'. This will start a wizard which will prompt you for the information required (privacy policy). This information is sent to a database and aggregated, so we have a good idea of which sites the most people are having problems with.\n\nIf you are interested, you can search the database of reports (http://reporter.mozilla.org/).\n\nClosing this bug as NOTABUG, if you don't agree with this resolution, please, reopen this bug and attach any relevant information to this bug.", - "sentUpstreamString": "We filed this bug in the upstream database (§§§) and believe that it is more appropriate to let it be resolved upstream.\n\nWe will continue to track the issue in the centralized upstream bug tracker, and will review any bug fixes that become available for consideration in future updates.\n\nThank you for the bug report.", - "moveYourButString": "Reporter, could you please reply to the previous question? If you won't reply in one month, I will have to close this bug as INSUFFICIENT_DATA. Thank you.", - "RHELString": "For official Red Hat Enterprise Linux support, please log into the Red Hat support website at http://www.redhat.com/support and file a support ticket. To understand how your bug is tracked through our system, please see https://www.redhat.com/support/process/production/#howrh", - "cantfixNvidiaString": "Thanks for the report. We are sorry that we cannot help you with your problem, but we are not able to support binary-only drivers. If you would be able to reproduce this issue using only open source software, please, reopen this bug with the additional information, but in meantime I have no choice than to close this bug as CANTFIX (because we really cannot fix it).\n\nThe open source 'nouveau' driver (in package xorg-x11-drv-nouveau) is the recommended alternative for users of Nvidia graphic chips. It is used by default in Fedora 11 and later if you remove any customizations that explicitly set the video driver. The older \"nv\" driver may be needed in some cases. It is also available in older Fedora releases. Install the packages xorg-x11-drv-nouveau or xorg-x11-drv-nv and override the X server's default choice if necessary. See https://fedoraproject.org/wiki/Features/NouveauAsDefault for more information.\n\nIf you used a non-packaged version of the driver from the Nvidia website please clean your system from additional libraries and software it installed. For users who are experiencing problems installing, configuring, or using the unsupported 3rd party proprietary \"nvidia\" video driver, Nvidia provides indirect customer support via an online web based support forum. Nvidia monitors these web forums for commonly reported problems and passes them on to Nvidia engineers for investigation. Once they've isolated a particular problem, it is often fixed in a future video driver update.\n\nThe NVNews Nvidia Linux driver forum is located at:\n\n\u0009http://www.nvnews.net/vbulletin/forumdisplay.php?s=&forumid=14\n\nOnce you have reported this issue in the Nvidia web forums, others who may have experienced the particular problem may be able to assist. If there is a real bug occuring, Nvidia will be able to determine this, and will likely resolve the issue in a future driver update for the operating system releases that they officially support.\n\nWhile we does not support the proprietary nvidia driver, users requiring technical support may also find the various X.Org, XFree86, and Red Hat/Fedora mailing lists helpful in finding assistance:\n\nX.Org mailing lists:\n\u0009http://www.freedesktop.org/XOrg/XorgMailingLists\n\nXFree86 mailing lists:\n\u0009http://www.xfree86.org/sos/lists.html\n\nRed Hat/Fedora mailing lists:\n\u0009https://listman.redhat.com/mailman/listinfo", - "flashCrashString": "Unfortunately, crash here happened in the binary-only flash player for which we don't have any source code, so unfortunately we cannot help you with it.\n\nClosing as CANTFIX (because that's our situation)", - "obsoleteRHELString": "This bug is filed against release of RHEL, which is in maintenance phase. During the maintenance phase, only security errata and select mission critical bug fixes will be released for enterprise products. Since this bug does not meet that criteria, it is now being closed.\n\nFor more information of the RHEL errata support policy, please visit:\n\nhttp://www.redhat.com/security/updates/errata/\n\nIf you feel this bug is indeed mission critical, please contact your support representative. You may be asked to provide detailed information on how this bug is affecting you.", - "getEOL": "Thank you for your bug report.\nWe are sorry, but the Fedora Project no longer maintains this version of Fedora. Please upgrade to the latest version and reopen this bug against that version if this bug exists there.\nAs a result we are setting this bug to CLOSED:WONTFIX" - }, - "configData": { - "queryButton": true, - "upstreamButton": true, - "parseAbrtBacktraces": true, - "submitsLogging": true, - "suspiciousComponents": [ - "xorg-x11", - "xorg-x11-drivers" - ], - "PCIIDsURL": "http://mcepl.fedorapeople.org/scripts/drm_pciids.json", - "objectStyle": "RH", - "signature": "" - }, - "constantData": { - "bugzillalabelNames": { - "bugzilla.mozilla.org": "Mozilla Foundation", - "bugs.freedesktop.org": "FreeDesktop.org", - "bugs.eclipse.org": "Eclipse Project", - "bugzilla.gnome.org": "GNOME Desktop", - "bugzilla.redhat.com": "Red Hat" - }, - "bugzillalabelAbbreviations": { - "bugzilla.mozilla.org": "MoFo", - "bugs.freedesktop.org": "FDo", - "bugs.eclipse.org": "Eclipse", - "bugzilla.gnome.org": "bgo", - "bugzilla.redhat.com": "RH" - }, - "defaultAssignee": [ - { - "regexp": "xorg-x11-drv-(ati|mach.*|r128)", - "addr": "jglisse@redhat.com" - }, - { - "regexp": "xorg-x11-drv-intel", - "addr": "ajax@redhat.com" - }, - { - "regexp": "xorg-x11-(server.*|drv-vesa|drv-mga)", - "addr": "ajax@redhat.com" - }, - { - "regexp": "xorg-x11-drv-(keyboard|mouse|evdev)|xkeyboard-config|linuxwacom", - "addr": "peter.hutterer@redhat.com" - }, - { - "regexp": "(seamonkey|nss.*)", - "addr": "kengert@redhat.com" - }, - { - "regexp": "thunderbird", - "addr": "jhorak@redhat.com" - }, - { - "regexp": "xorg-x11-init", - "addr": "sandmann@redhat.com" - }, - { - "regexp": "(firefox|xulrunner)", - "addr": "stransky@redhat.com" - }, - { - "regexp": "xorg-x11-drv-(nv|nouveau)", - "addr": "bskeggs@redhat.com" - } - ], - "CCmaintainer": [ - { - "regexp": "xorg|X11|compiz|chkfontpath|imake|libdmx|libdrm|libfontenc|libFS|libICE|libSM|libwnck|libxkbfile|mesa|pyxf86config|system-config-display|xkeyboard-config|xrestop|xsri", - "addr": ["xgl-maint@redhat.com"] - }, - { - "regexp": "epiphany.*|firefox|galeon|gecko-sharp2|htmlview|^mozilla|seamonkey|thunderbird|xulrunner|nspluginwrapper", - "addr": ["gecko-bugs-nobody@fedoraproject.org" , "gecko-bugs-nobody@redhat.com" ] - } - ], - "newUpstreamBug": [ - { - "regexp": "thunderbird", - "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird" - }, - { - "regexp": "firefox", - "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox" - }, - { - "regexp": "xulrunner", - "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Core" - } - ], - "queryUpstreamBug": [ - { - "regexp": "thunderbird|firefox|xulrunner", - "addr": "https://bugzilla.mozilla.org/buglist.cgi?quicksearch=" - } - ], - "chipIDsGroupings": [ - { - "regexp": "RADEON,R(100|[VS][12]00|S200M|S250|N50)", - "addr": "R100" - }, - { - "regexp": "RADEON,R(200|V2[58]0|C350|S3[05]0)", - "addr": "R200" - }, - { - "regexp": "RADEON,R(3[056]0|V3[56][10])", - "addr": "R300" - }, - { - "regexp": "RADEON,RV3[78]0", - "addr": "R300e" - }, - { - "regexp": "RADEON,RS4[08][025]", - "addr": "IGP300" - }, - { - "regexp": "RADEON,R(4[123]0|481)", - "addr": "R400" - }, - { - "regexp": "RADEON,R(V410|423|4[38]0)", - "addr": "R420" - }, - { - "regexp": "RADEON,R(V51[56]|V53[05]|V5[67]0|5[28]0|580\\+)", - "addr": "R500" - }, - { - "regexp": "RADEON,RS(6[09]|74)0C?", - "addr": "IGP600" - }, - { - "regexp": "RADEON,R(V6[1273][50]|R6[80]0).*", - "addr": "R600" - }, - { - "regexp": "RADEON,RS([78]80)[CD]?", - "addr": "IGP700" - }, - { - "regexp": "RADEON,R(V7[13479]0.*|700)", - "addr": "R700" - }, - { - "regexp": "RADEON,(Juniper|Cypress|Hemlock).*", - "addr": "R800" - }, - { - "regexp": "RADEON,M(9|10).*", - "addr": "FireGL" - }, - { - "regexp": "NOUVEAU,NV[13456]", - "addr": "preGeForce" - }, - { - "regexp": "NOUVEAU,NV10", - "addr": "GeForce" - }, - { - "regexp": "NOUVEAU,NV1[156]", - "addr": "GeForce2" - }, - { - "regexp": "NOUVEAU,NV20", - "addr": "GeForce3" - }, - { - "regexp": "INTEL,865PE", - "addr": "AGP8x" - } - ] - } -} diff --git a/data/BugZappers_data.json b/jsons/BugZappers_data.json index d76aaef..d76aaef 100644 --- a/data/BugZappers_data.json +++ b/jsons/BugZappers_data.json diff --git a/jsons/RH_Data-packages.json b/jsons/RH_Data-packages.json new file mode 100644 index 0000000..8414794 --- /dev/null +++ b/jsons/RH_Data-packages.json @@ -0,0 +1,169 @@ +{ + "constantData": { + "bugzillalabelNames": { + "bugzilla.mozilla.org": "Mozilla Foundation", + "bugs.freedesktop.org": "FreeDesktop.org", + "bugs.eclipse.org": "Eclipse Project", + "bugzilla.gnome.org": "GNOME Desktop", + "bugzilla.redhat.com": "Red Hat" + }, + "bugzillalabelAbbreviations": { + "bugzilla.mozilla.org": "MoFo", + "bugs.freedesktop.org": "FDo", + "bugs.eclipse.org": "Eclipse", + "bugzilla.gnome.org": "bgo", + "bugzilla.redhat.com": "RH" + }, + "defaultAssignee": [ + { + "regexp": "xorg-x11-drv-(ati|mach.*|r128)", + "addr": "jglisse@redhat.com" + }, + { + "regexp": "xorg-x11-drv-intel", + "addr": "ajax@redhat.com" + }, + { + "regexp": "xorg-x11-(server.*|drv-vesa|drv-mga)", + "addr": "ajax@redhat.com" + }, + { + "regexp": "xorg-x11-drv-(keyboard|mouse|evdev)|xkeyboard-config|linuxwacom", + "addr": "peter.hutterer@redhat.com" + }, + { + "regexp": "(seamonkey|nss.*)", + "addr": "kengert@redhat.com" + }, + { + "regexp": "thunderbird", + "addr": "jhorak@redhat.com" + }, + { + "regexp": "xorg-x11-init", + "addr": "sandmann@redhat.com" + }, + { + "regexp": "(firefox|xulrunner)", + "addr": "stransky@redhat.com" + }, + { + "regexp": "xorg-x11-drv-(nv|nouveau)", + "addr": "bskeggs@redhat.com" + } + ], + "CCmaintainer": [ + { + "regexp": "xorg|X11|compiz|chkfontpath|imake|libdmx|libdrm|libfontenc|libFS|libICE|libSM|libwnck|libxkbfile|mesa|pyxf86config|system-config-display|xkeyboard-config|xrestop|xsri", + "addr": [ + "xgl-maint@redhat.com" + ] + }, + { + "regexp": "epiphany.*|firefox|galeon|gecko-sharp2|htmlview|^mozilla|seamonkey|thunderbird|xulrunner|nspluginwrapper", + "addr": [ + "gecko-bugs-nobody@fedoraproject.org" , + "gecko-bugs-nobody@redhat.com" + ] + } + ], + "newUpstreamBug": [ + { + "regexp": "thunderbird", + "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Thunderbird" + }, + { + "regexp": "firefox", + "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox" + }, + { + "regexp": "xulrunner", + "addr": "https://bugzilla.mozilla.org/enter_bug.cgi?product=Core" + } + ], + "queryUpstreamBug": [ + { + "regexp": "thunderbird|firefox|xulrunner", + "addr": "https://bugzilla.mozilla.org/buglist.cgi?quicksearch=" + } + ] + }, + "childIDsGroupings": [ + { + "regexp": "RADEON,R(100|[VS][12]00|S200M|S250|N50)", + "addr": "R100" + }, + { + "regexp": "RADEON,R(200|V2[58]0|C350|S3[05]0)", + "addr": "R200" + }, + { + "regexp": "RADEON,R(3[056]0|V3[56][10])", + "addr": "R300" + }, + { + "regexp": "RADEON,RV3[78]0", + "addr": "R300e" + }, + { + "regexp": "RADEON,RS4[08][025]", + "addr": "IGP300" + }, + { + "regexp": "RADEON,R(4[123]0|481)", + "addr": "R400" + }, + { + "regexp": "RADEON,R(V410|423|4[38]0)", + "addr": "R420" + }, + { + "regexp": "RADEON,R(V51[56]|V53[05]|V5[67]0|5[28]0|580\\+)", + "addr": "R500" + }, + { + "regexp": "RADEON,RS(6[09]|74)0C?", + "addr": "IGP600" + }, + { + "regexp": "RADEON,R(V6[1273][50]|R6[80]0).*", + "addr": "R600" + }, + { + "regexp": "RADEON,RS([78]80)[CD]?", + "addr": "IGP700" + }, + { + "regexp": "RADEON,R(V7[13479]0.*|700)", + "addr": "R700" + }, + { + "regexp": "RADEON,(Juniper|Cypress|Hemlock).*", + "addr": "R800" + }, + { + "regexp": "RADEON,M(9|10).*", + "addr": "FireGL" + }, + { + "regexp": "NOUVEAU,NV[13456]", + "addr": "preGeForce" + }, + { + "regexp": "NOUVEAU,NV10", + "addr": "GeForce" + }, + { + "regexp": "NOUVEAU,NV1[156]", + "addr": "GeForce2" + }, + { + "regexp": "NOUVEAU,NV20", + "addr": "GeForce3" + }, + { + "regexp": "INTEL,865PE", + "addr": "AGP8x" + } + ] +}
\ No newline at end of file diff --git a/data/drm_pciids.awk b/jsons/drm_pciids.awk index dea8fd2..dea8fd2 100755 --- a/data/drm_pciids.awk +++ b/jsons/drm_pciids.awk diff --git a/data/drm_pciids.json b/jsons/drm_pciids.json index ee45add..ee45add 100644 --- a/data/drm_pciids.json +++ b/jsons/drm_pciids.json diff --git a/lib/bzpage.js b/lib/bzpage.js index bad7b5e..8f11eb5 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -3,13 +3,13 @@ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; -var utilMod = require("util"); +var util = require("util"); +var simpleStorage = require("simple-storage"); var TriagedDistro = 13; var NumberOfFrames = 7; var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; -var myStorage = jetpack.storage.simple; // ==================================================================================== // BZPage's methods @@ -20,20 +20,6 @@ exports.BZPage = function BZPage(doc) { // 85 this.ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2, // 83 - this.RE = { - Comment: new RegExp("^\\s*#"), // unsused - BlankLine: new RegExp("^\\s*$"), // unused - // nová řádka - // [ 65.631] (--) intel(0): Chipset: "845G" - Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ - "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"), - ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"), - Abrt: new RegExp("^\\s*\\[abrt\\]"), - signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"), - frameNo: new RegExp("^\\s*#([0-9]*)\\s") - }; - - // initialize dynamic properties this.doc = doc; this.packages = this.getInstalledPackages(); @@ -41,7 +27,11 @@ exports.BZPage = function BZPage(doc) { this.commentStrings = config.gJSONData.commentStrings; } + if ("constantData" in config.gJSONData) { + // this is wrong, I shouldn't bother anybody with my Xorg data, and + // I should load it from URL + // var stuff = JSON.parse(self.data.load("chiIDsGroupings.json")); this.constantData = config.gJSONData.constantData; } @@ -56,7 +46,7 @@ exports.BZPage = function BZPage(doc) { } this.submitHandlerInstalled = false; - this.bugNo = utilMod.getBugNo(this.doc.location.toString()); + this.bugNo = util.getBugNo(this.doc.location.toString()); this.reporter = this.getReporter(); this.product = this.getOptionValue("product"); this.component = this.getOptionValue("component"); @@ -452,28 +442,6 @@ BZPage.prototype.clickMouse = function(targetID) { }; /** - * select element of the array where regexp in the first element matches second - * parameter of this function - * - * @param list Array with regexps and return values - * @param chosingMark String by which the element of array is to be matched - * @return Object chosen element - */ -BZPage.prototype.filterByRegexp = function(list, chosingMark) { - let chosenPair = []; - if (list.length > 0) { - chosenPair = list.filter(function(pair) { - return new RegExp(pair.regexp, "i").test(chosingMark); - }); - } - if (chosenPair.length > 0) { - return chosenPair[0].addr; - } else { - return ""; - } -}; - -/** * Add object to the text box (comment box or status whiteboard) * * @param id String with the id of the element @@ -487,7 +455,7 @@ BZPage.prototype.addStuffToTextBox = function(id, stuff) { stuff = textBox.value ? "\n\n" + stuff : stuff; textBox.value += stuff; } else { - textBox.value = utilMod.addCSVValue(textBox.value,stuff); + textBox.value = util.addCSVValue(textBox.value,stuff); } }; @@ -499,7 +467,7 @@ BZPage.prototype.addStuffToTextBox = function(id, stuff) { */ BZPage.prototype.removeStuffFromTextBox = function(id, stuff) { let changedElement = this.getElementById(id); - changedElement.value = utilMod.removeCSVValue(changedElement.value,stuff); + changedElement.value = util.removeCSVValue(changedElement.value,stuff); } /** @@ -587,7 +555,7 @@ BZPage.prototype.getLogin = function () { * @return String with the maintainer's email address */ BZPage.prototype.getDefaultBugzillaMaintainer = function(component) { - let address = this.filterByRegexp(this.defBugzillaMaintainerArr, component); + let address = util.filterByRegexp(this.defBugzillaMaintainerArr, component); return address; } @@ -724,7 +692,7 @@ BZPage.prototype.addToCCList = function(who) { this.doc.getElementById("addselfcc").checked = true; } else { this.clickMouse("cc_edit_area_showhide"); - if (!utilMod.isInList(who, this.CCList)) { + if (!util.isInList(who, this.CCList)) { this.addStuffToTextBox("newcc",who); } } diff --git a/lib/main.js b/lib/main.js index 03bc69d..eca533e 100644 --- a/lib/main.js +++ b/lib/main.js @@ -12,19 +12,15 @@ // http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 // "use strict"; -var utilMod = require("util"); -var logMod = require("logger"); - -jetpack.future.import("pageMods"); -jetpack.future.import("storage.simple"); -jetpack.future.import("selection"); -jetpack.future.import("clipboard"); +var util = require("util"); +var logger = require("logger"); +var file = require("file"); +var myStorage = require("simple-storage").storage; var TriagedDistro = 13; var NumberOfFrames = 7; var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; -var myStorage = jetpack.storage.simple; // ============================================================== // https://wiki.mozilla.org/Labs/Jetpack/JEP/24 @@ -67,7 +63,7 @@ config.matches = [ "https://bugzilla.redhat.com/show_bug.cgi", "https://bugzilla.mozilla.org/show_bug.cgi" ]; -utilMod.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) { +util.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) { config.gJSONData = parsedData; // Get card translation table @@ -76,12 +72,12 @@ utilMod.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) { keys += key + " "; } if ("PCIIDsURL" in config.gJSONData.configData) { - utilMod.loadJSON(config.gJSONData.configData.PCIIDsURL, function(response) { + util.loadJSON(config.gJSONData.configData.PCIIDsURL, function(response) { config.PCI_ID_Array = response; }); } - config.logger = new logMod.Logger(myStorage.logs, + config.logger = new logger.Logger(myStorage.logs, config.gJSONData.constantData.bugzillalabelAbbreviations); let callback = function(doc) { @@ -93,4 +89,4 @@ utilMod.loadJSON(jetpack.storage.settings.JSONURL, function(parsedData) { }; jetpack.pageMods.add(callback, config); -}, this); +}, this);
\ No newline at end of file diff --git a/lib/offline-support.js b/lib/offline-support.js new file mode 100644 index 0000000..4849bd3 --- /dev/null +++ b/lib/offline-support.js @@ -0,0 +1,153 @@ +/*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 */ +/*global jetpack */ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php +"use strict"; + +/* Offline supporting functions */ +/** + * + * @todo FIXME this probably makes a closure and a memory leak name='changeform' + * investigate + * https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion + * + * <form method="post" action="process_bug.cgi" autocomplete="off"> + * + * Reading + * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13 + * random notes: - 17.13.3 provides all steps necessary - enctype != + * application/x-www-form-urlencoded => SHOULD fails (no further questions + * needed) - http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1. is + * nice explanation (albeit quite dated) - on multiple values + * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.6.1 - + * příliš jednoduché + * http://www.innovation.ch/java/HTTPClient/emulating_forms.html - + */ +RHBugzillaPage.prototype.serializeForm = function(form) { + let serialForm = { + dataOut : "", + name : form.name, + method : form.method, + acceptCharset : form.acceptCharset, + action : form.action, // TODO shouldn't we get a non-relative URL? + enctype : form.enctype, + cookie : this.doc.cookie, + autocomplete : form.getAttribute("autocomplete"), + bugNo : this.bugNo + }; + + function genURIElement(sName, sValue) { + return encodeURIComponent(sName) + "=" + encodeURIComponent(sValue); + } + + /** + * @param o + * control to be serialized + * @return String with the serialized control + */ + function serializeControl(element) { + let val = element.value; + // console.log("val.toSource() = " + val.toSource()); + /* + * on HTMLSelectElement we have an attribute 'type' of type DOMString, + * readonly The type of this form control. This is the string + * "select-multiple" when the multiple attribute is true and the string + * "select-one" when false. + */ + if ((val == null) || (val == undefined) || (val == "")) { + return; + } else if (val instanceof Array) { + return val.map(function(x) { + return genURIElement(element.name, x.value); + }).join("&"); + } else if (val instanceof String) { + return genURIElement(element.name, val); + } else { // assume HTMLCollection + return Array.map(val, function(x) { + return genURIElement(element.name, x.value); + }).join("&"); + } + } + + serialForm.dataOut = Array.filter(form.elements,function(el) { + return !el.disabled && el.name && + // FIXME shouldn't I just add && el.value here? + (el.checked || /select|textarea/i.test(el.nodeName) || + /text|hidden|password|search/i.test(el.type)); + }).map(serializeControl).join("&"); + return serialForm; +}; + +//RHBugzillaPage.prototype.submitCallback = function(evt) { +// console.log("Submit Callback!"); +// if (jetpack.__parent__.navigator.onLine) { +// let serForm = this +// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms +// .namedItem("changeform")); +//// console.log("serForm:\n" + serForm.toSource()); +// } else { +// let serForm = this +// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms +// .namedItem("changeform")); +// myStorage.forms[this.bugNo] = serForm; +// evt.stopPropagation(); +// evt.preventDefault(); +// } +//}; + +/** + * + * + * Yes, this is correct, this is NOT method of RHBugzillaPage! + */ +/*function onlineCallback() { + function deserializeAndSend(formData) { + // FIXME notImplemented + // is it enough to just + // run XMLHttpRequest? Probably yes, this is just a form + // and this is just a HTTP request + // it is probably better to get already processed + // application/x-www-form-urlencoded + // see http://htmlhelp.com/reference/html40/forms/form.html for details + // and also https://developer.mozilla.org/en/AJAX/Getting_Started + // what's? + // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\ + // /Global_Functions/encodeURI & co. + // this seems to be also interesting + // https://developer.mozilla.org/en/Code_snippets/Post_data_to_window + console.error("Sending bugs not implemented yet!"); + return ""; // FIXME check other HTTP headers to be set + + let bugID = formData.bugNo; + let req = new XMLHttpRequest(); + req.open("POST", formData.action, true); + // FIXME co očekávám za odpověď? req.overrideMimeType("text/xml"); + // * Accept-Encoding + // * Accept-Language + // * Accept (MIME types) + req.setRequestHeader("Connection", "keep-alive"); + req.setRequestHeader("Keep-Alive", 300); + req.setRequestHeader("Content-Type", formData.enctype); + req.setRequestHeader("Referer", bugURL + bugID); + req.setRequestHeader("Accept-Charset", formData.acceptCharset); + req.setRequestHeader("Cookie", formData.cookie); + req.onreadystatechange = function(aEvt) { + if (req.readyState == 4) { + if (req.status == 200) { + console.log("Sent form for bug " + bugID); + delete myStorage.forms[bugID]; + } else { + console.error("Sending form for bug " + bugID + "failed!"); + } + } + }; + req.send(formData.data); + } + + if (myStorage.forms.length > 0) { + myStorage.forms.forEach(function(x) { + deserializeAndSend(x); + }); + } +} +*/
\ No newline at end of file diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index f318528..c885699 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -3,7 +3,7 @@ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; -var utilMod = require("util"); +var util = require("util"); var xrpc = require("xmlrpc"); var xhr = require("xhr"); // var TriagedDistro = 13; @@ -29,6 +29,20 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc) { // HSL // 120, 0, 23 this.RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 + + this.RE = { + Comment: new RegExp("^\\s*#"), // unsused + BlankLine: new RegExp("^\\s*$"), // unused + // new line + // [ 65.631] (--) intel(0): Chipset: "845G" + Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ + "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"), + ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"), + Abrt: new RegExp("^\\s*\\[abrt\\]"), + signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"), + frameNo: new RegExp("^\\s*#([0-9]*)\\s") + }; + // END OF CONSTANTS // Prepare for query buttons @@ -104,7 +118,7 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc) { } } // END OF RHBugzillaPage CONSTRUCTOR -RHBugzillaPage.prototype = utilMod.heir(BZPage); +RHBugzillaPage.prototype = util.heir(BZPage); RHBugzillaPage.prototype.constructor = RHBugzillaPage; /** @@ -114,7 +128,7 @@ RHBugzillaPage.prototype.constructor = RHBugzillaPage; * we haven't set it up. */ RHBugzillaPage.prototype.getDefaultAssignee = function() { - return this.filterByRegexp(this.constantData.defaultAssignee, + return util.filterByRegexp(this.constantData.defaultAssignee, this.component).toLowerCase(); } @@ -199,153 +213,6 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) }; -/* Offline supporting functions */ -/** - * - * @todo FIXME this probably makes a closure and a memory leak name='changeform' - * investigate - * https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion - * - * <form method="post" action="process_bug.cgi" autocomplete="off"> - * - * Reading - * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13 - * random notes: - 17.13.3 provides all steps necessary - enctype != - * application/x-www-form-urlencoded => SHOULD fails (no further questions - * needed) - http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1. is - * nice explanation (albeit quite dated) - on multiple values - * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.6.1 - - * příliš jednoduché - * http://www.innovation.ch/java/HTTPClient/emulating_forms.html - - */ -RHBugzillaPage.prototype.serializeForm = function(form) { - let serialForm = { - dataOut : "", - name : form.name, - method : form.method, - acceptCharset : form.acceptCharset, - action : form.action, // TODO shouldn't we get a non-relative URL? - enctype : form.enctype, - cookie : this.doc.cookie, - autocomplete : form.getAttribute("autocomplete"), - bugNo : this.bugNo - }; - - function genURIElement(sName, sValue) { - return encodeURIComponent(sName) + "=" + encodeURIComponent(sValue); - } - - /** - * @param o - * control to be serialized - * @return String with the serialized control - */ - function serializeControl(element) { - let val = element.value; - // console.log("val.toSource() = " + val.toSource()); - /* - * on HTMLSelectElement we have an attribute 'type' of type DOMString, - * readonly The type of this form control. This is the string - * "select-multiple" when the multiple attribute is true and the string - * "select-one" when false. - */ - if ((val == null) || (val == undefined) || (val == "")) { - return; - } else if (val instanceof Array) { - return val.map(function(x) { - return genURIElement(element.name, x.value); - }).join("&"); - } else if (val instanceof String) { - return genURIElement(element.name, val); - } else { // assume HTMLCollection - return Array.map(val, function(x) { - return genURIElement(element.name, x.value); - }).join("&"); - } - } - - serialForm.dataOut = Array.filter(form.elements,function(el) { - return !el.disabled && el.name && - // FIXME shouldn't I just add && el.value here? - (el.checked || /select|textarea/i.test(el.nodeName) || - /text|hidden|password|search/i.test(el.type)); - }).map(serializeControl).join("&"); - return serialForm; -}; - -//RHBugzillaPage.prototype.submitCallback = function(evt) { -// console.log("Submit Callback!"); -// if (jetpack.__parent__.navigator.onLine) { -// let serForm = this -// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms -// .namedItem("changeform")); -//// console.log("serForm:\n" + serForm.toSource()); -// } else { -// let serForm = this -// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms -// .namedItem("changeform")); -// myStorage.forms[this.bugNo] = serForm; -// evt.stopPropagation(); -// evt.preventDefault(); -// } -//}; - -/** - * - * - * Yes, this is correct, this is NOT method of RHBugzillaPage! - */ -/*function onlineCallback() { - function deserializeAndSend(formData) { - // FIXME notImplemented - // is it enough to just - // run XMLHttpRequest? Probably yes, this is just a form - // and this is just a HTTP request - // it is probably better to get already processed - // application/x-www-form-urlencoded - // see http://htmlhelp.com/reference/html40/forms/form.html for details - // and also https://developer.mozilla.org/en/AJAX/Getting_Started - // what's? - // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\ - // /Global_Functions/encodeURI & co. - // this seems to be also interesting - // https://developer.mozilla.org/en/Code_snippets/Post_data_to_window - console.error("Sending bugs not implemented yet!"); - return ""; // FIXME check other HTTP headers to be set - - let bugID = formData.bugNo; - let req = new XMLHttpRequest(); - req.open("POST", formData.action, true); - // FIXME co očekávám za odpověď? req.overrideMimeType("text/xml"); - // * Accept-Encoding - // * Accept-Language - // * Accept (MIME types) - req.setRequestHeader("Connection", "keep-alive"); - req.setRequestHeader("Keep-Alive", 300); - req.setRequestHeader("Content-Type", formData.enctype); - req.setRequestHeader("Referer", bugURL + bugID); - req.setRequestHeader("Accept-Charset", formData.acceptCharset); - req.setRequestHeader("Cookie", formData.cookie); - req.onreadystatechange = function(aEvt) { - if (req.readyState == 4) { - if (req.status == 200) { - console.log("Sent form for bug " + bugID); - delete myStorage.forms[bugID]; - } else { - console.error("Sending form for bug " + bugID + "failed!"); - } - } - }; - req.send(formData.data); - } - - if (myStorage.forms.length > 0) { - myStorage.forms.forEach(function(x) { - deserializeAndSend(x); - }); - } -} -*/ /* Bugzilla functions. */ RHBugzillaPage.prototype.ProfessionalProducts = [ @@ -394,7 +261,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { attURL = "https://bugzilla.redhat.com/attachment.cgi?id=" + x[1]; if (!this.btSnippet) { - let btRaw = utilMod.loadText(attURL, function(ret) { + let btRaw = util.loadText(attURL, function(ret) { this.btSnippet = this.parseBacktrace(ret); if (this.btSnippet) { this.addStuffToTextBox("comment", this.btSnippet); @@ -414,7 +281,7 @@ RHBugzillaPage.prototype.markBadAttachments = function() { let badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; let badAttachments = this.attachments.filter(function(att, idx, arr) { - return (utilMod.isInList(att[2], badMIMEArray)); + return (util.isInList(att[2], badMIMEArray)); }); if (badAttachments.length > 0) { @@ -514,7 +381,7 @@ RHBugzillaPage.prototype.setBranding = function() { } // we should make visible whether maintCCAddr is in CCList - if (utilMod.isInList(this.maintCCAddr, this.CCList)) { + if (util.isInList(this.maintCCAddr, this.CCList)) { let ccEditBoxElem = this.doc.getElementById("cc_edit_area_showhide"); // ccEditBoxElem.textContent = "*"+ccEditBoxElem.textContent; ccEditBoxElem.style.color = "navy"; @@ -526,7 +393,7 @@ RHBugzillaPage.prototype.setBranding = function() { let compElems; let suspiciousComponents = config.gJSONData.configData.suspiciousComponents; if (suspiciousComponents - && utilMod.isInList(this.component, suspiciousComponents) + && util.isInList(this.component, suspiciousComponents) && (compElems = this.doc .getElementById("bz_component_edit_container"))) { compElems.style.background = "red none"; @@ -545,7 +412,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { let that = this; function groupIDs(manStr, cardStrID) { - let outStr = that.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID); + let outStr = util.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID); if (outStr.length === 0) { outStr = "UNGROUPED_" + manStr + "/" + cardStrID; } @@ -623,6 +490,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { * @return None */ RHBugzillaPage.prototype.fillInChipMagic = function () { + let that = this; let XorgLogURL = ""; let XorgLogAttID = ""; let XorgLogFound = false; @@ -643,34 +511,25 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID; that = this; - let req = new xhrMod.XMLHttpRequest(); - req.open("GET",attURL,true); - req.onreadystatechange = function (aEvt) { - if (req.readyState == 4) { - if (req.status == 200) { - let ret = req.responseText; - let interestingLineArr = ret.split("\n"). - filter(function (v,i,a) { - return this.RE.Chipset.test(v); - }); - if (interestingLineArr.length >0) { - interestingArray = this.RE.Chipset.exec(interestingLineArr[0]); - interestingLine = interestingArray[2]. - replace(/[\s"]+/g," ").trim(); - // Persuade createNewButton to have mercy and to actually add - // non-default button - this.constantData.chipMagicTrigger = true; - this.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1] - .toUpperCase(); - this.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic"); - } - } else { - throw "Getting attachment " + attURL + "failed!"; - } + // parse Xorg.0.log + util.loadText(attURL, function(ret){ + let interestingLineArr = ret.split("\n"). + filter(function (v,i,a) { + return that.RE.Chipset.test(v); + }); + if (interestingLineArr.length >0) { + // TODO we are parsing only the first found line; is it alright? + interestingArray = that.RE.Chipset.exec(interestingLineArr[0]); + interestingLine = interestingArray[2]. + replace(/[\s"]+/g," ").trim(); + // Persuade createNewButton to have mercy and to actually add + // non-default button + that.constantData.chipMagicTrigger = true; + that.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1] + .toUpperCase(); + that.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic"); } - }; - req.send(""); - + }); this.XorgLogAttListIndex++; }; @@ -750,7 +609,7 @@ RHBugzillaPage.prototype.queryUpstream = function() { if (text) { let text = encodeURIComponent(text.trim()); let queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; - let url = this.filterByRegexp(queryUpstreamBugsURLArray, this.component); + let url = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); jetpack.tabs.open(url + text); } } @@ -759,7 +618,7 @@ RHBugzillaPage.prototype.queryUpstream = function() { * */ RHBugzillaPage.prototype.sendBugUpstream = function() { - let url = this.filterByRegexp(this.constantData.newUpstreamBug, this + let url = util.filterByRegexp(this.constantData.newUpstreamBug, this .getOptionValue("component")); let ret = jetpack.tabs.open(url); diff --git a/lib/util.js b/lib/util.js index b6691af..3ce50c5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -50,6 +50,28 @@ var isInList = exports.isInList = function isInList(mbr, list) { }; /** + * select element of the array where regexp in the first element matches second + * parameter of this function + * + * @param list Array with regexps and return values + * @param chosingMark String by which the element of array is to be matched + * @return Object chosen element + */ +exports.filterByRegexp = function filterByRegexp(list, chosingMark) { + let chosenPair = []; + if (list.length > 0) { + chosenPair = list.filter(function(pair) { + return new RegExp(pair.regexp, "i").test(chosingMark); + }); + } + if (chosenPair.length > 0) { + return chosenPair[0].addr; + } else { + return ""; + } +}; + +/** * format date to be in ISO format (just day part) * * @param date diff --git a/tests/test-util.js b/tests/test-util.js index 0621ad9..a9d0e6a 100644 --- a/tests/test-util.js +++ b/tests/test-util.js @@ -73,6 +73,27 @@ exports.ensureIsInListNoMember = function (test) { "conversion of a string to an array"); }; +// testing util.filterByRegexp +exports.ensureFilterByRegexp = function (test) { + var list = [ + { + "regexp": "test(ing|ed)", + "addr": "correct" + }, + { + "regexp": "ba.*d", + "addr": true + } + ]; + + test.assertEqual(util.filterByRegexp(list,"testing"),"correct", + "simple testing of filterByRegexp"); + test.assertEqual(util.filterByRegexp(list,"unknown value"),"", + "simple testing of filterByRegexp with non-found address"); + test.assert(util.filterByRegexp(list,"baaad"), + "simple testing of filterByRegexp with non-string return value"); +}; + // testing util.getISODate exports.ensureGetISODate = function (test) { test.assertEqual(util.getISODate("Mon May 31 2010 23:29:09 GMT+0200 (CET)"), @@ -160,14 +181,15 @@ exports.ensureLoadText = function (test) { }); }; -//exports.ensureLoadTextUnicode = function (test) { -// var url = "http://matej.ceplovi.cz/progs/data/pushkin.txt", text = ""; -// test.waitUntilDone(); -// util.loadText(url, function (txt) { -// test.assertEqual(txt, pushkinTestString); -// test.done(); -// }); -//}; +// exports.ensureLoadTextUnicode = function (test) { +// var url = "http://matej.ceplovi.cz/progs/data/pushkin.txt", text = ""; +// test.waitUntilDone(); +// util.loadText(url, function (txt) { +// console.log(txt); +// //test.assertEqual(txt, pushkinTestString); +// test.done(); +// }); +// }; //// testing util.loadJSON exports.ensureLoadJSON = function (test) { |