Created
November 5, 2015 12:42
-
-
Save wolph/81da08a4d7ccb4b35886 to your computer and use it in GitHub Desktop.
Bugzilla fetcher for google sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @fileoverview Provides the custom function BUGZILLA_TITLE and | |
* the helper functions that it uses. | |
*/ | |
/** | |
* Runs when the add-on is installed. | |
*/ | |
function onInstall() { | |
onOpen(); | |
} | |
/** | |
* Runs when the document is opened, creating the add-on's menu. Custom function | |
* add-ons need at least one menu item, since the add-on is only enabled in the | |
* current spreadsheet when a function is run. | |
*/ | |
function onOpen() { | |
SpreadsheetApp.getUi().createAddonMenu() | |
.addItem('Use in this spreadsheet', 'use') | |
.addToUi(); | |
} | |
/** | |
* Enables the add-on on for the current spreadsheet (simply by running) and | |
* shows a popup informing the user of the new functions that are available. | |
*/ | |
function use() { | |
var title = 'Bugzilla Functions'; | |
var message = 'The functions BUGZILLA_TITLE is now available in ' + | |
'this spreadsheet. More information is available in the function help ' + | |
'box that appears when you start using them in a formula.'; | |
var ui = SpreadsheetApp.getUi(); | |
ui.alert(title, message, ui.ButtonSet.OK); | |
} | |
/** | |
* Adds some amount of time to a date. | |
* @param {number} The Bugzilla ID. | |
* @return {String} The Bugzilla Title. | |
* @customFunction | |
*/ | |
function BUGZILLA_TITLE(bug_id) { | |
var response = UrlFetchApp.fetch('http://bugzilla.dev-ict.tudelft.nl/show_bug.cgi?id=' + bug_id); | |
return response.getContentText().match(/<title>.+? - (.+?)<\/title>/)[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment