Form Examples

Well-designed Omni Automation actions often prompt and query the user to provide data, or make a selection, choice, or decision as to how the script should proceed. The Form class enables scripts to gather information from the user, by presenting dialogs containing data expressed using standard interface elements: text input fields, date pickers, option menus, and checkboxes.

The following example forms address common scripting scenarios and can be easily added to your Omni Automaton action templates and customized to suit the individual script requirements.

Single Text Input

In this form example, the user is prompted to provide text input. The form’s validation function ensures that the approval button will not be enabled without the user first providing such input.

single-text-input
var textInputField = new Form.Field.String( "textInput", "Field Label", null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Form prompt:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ inputText = formObject.values['textInput'] return ((!inputText)?false:true) } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

URL Input Form

This form presents a single text input field that accepts a text string that can be made into a valid URL object:

url-input-dialog
// CREATE FORM FOR GATHERING USER INPUT var inputForm = new Form() // CREATE TEXT FIELD var textField = new Form.Field.String( "textInput", null, null ) // ADD THE FIELDS TO THE FORM inputForm.addField(textField) // PRESENT THE FORM TO THE USER var formPrompt = "Enter the full URL:" var formPromise = inputForm.show(formPrompt,"Continue") // VALIDATE THE USER INPUT inputForm.validate = function(formObject){ var textValue = formObject.values["textInput"] return (textValue && URL.fromString(textValue)) ? true : false } // PROCESSING USING THE DATA EXTRACTED FROM THE FORM formPromise.then(function(formObject){ var textValue = formObject.values["textInput"] var url = URL.fromString(textValue) // PROCESSING STATEMENTS GO HERE }) // PROMISE FUNCTION CALLED UPON FORM CANCELLATION formPromise.catch(function(err){ console.log("form cancelled", err.message) })

To limit the validation to only URLs beginning with specific schema:

// CREATE FORM FOR GATHERING USER INPUT var inputForm = new Form() // CREATE TEXT FIELD var textField = new Form.Field.String( "textInput", null, null ) // ADD THE FIELDS TO THE FORM inputForm.addField(textField) // PRESENT THE FORM TO THE USER var formPrompt = "Enter the full URL:" var formPromise = inputForm.show(formPrompt,"Continue") // VALIDATE THE USER INPUT inputForm.validate = function(formObject){ var textValue = formObject.values["textInput"] var textStatus = (textValue && textValue.length > 0) ? true:false var schema = [ "http://", "https://", "mailto:", "omnioutliner://", "omniplan://", "omnigraffle://", "omnifocus://" ] if (textStatus){ var i; for (i = 0; i < schema.length; i++) { if (textValue.startsWith(schema[i], 0) && URL.fromString(textValue)){return true} } } return false } // PROCESSING USING THE DATA EXTRACTED FROM THE FORM formPromise.then(function(formObject){ var textValue = formObject.values["textInput"] var url = URL.fromString(textValue) // PROCESSING STATEMENTS GO HERE }) // PROMISE FUNCTION CALLED UPON FORM CANCELLATION formPromise.catch(function(err){ console.log("form cancelled", err.message) })

Enter an Existing OmniFocus Tag

Here’s an example form containing a single text input field in which the user enters the title of an existing tag.

try { var tagNames = new Array() tags.apply(tag => tagNames.push(tag.name)) if (tagNames.length === 0){throw Error("No tags in database")} var textInputField = new Form.Field.String( "textInput", "Tag", null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Enter the title of an existing tag:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var inputText = formObject.values['textInput'] var textStatus = ((!inputText)?false:true) return (textStatus && tagNames.includes(inputText)) ? true : false } formPromise.then(function(formObject){ var tagTitle = formObject.values['textInput'] var targetTag = null tags.apply(function(tag){ if(tag.name == tagTitle){ targetTag = tag return ApplyResult.Stop } }) console.log('tag: ',targetTag) // PROCESS STATEMENTS }) formPromise.catch(function(err){ console.error("form cancelled", err.message) }) } catch (err){ new Alert('SCRIPT ERROR', err.message).show() }

Text Input with Mandatory Checkbox

In this example form, the dialog cannot be approved without the user providing text and selecting the provided checkbox.

text-input-with-mandatory-checkbox
var textInputField = new Form.Field.String( "textInput", "Field Label", null ) var checkSwitchField = new Form.Field.Checkbox( "checkboxSwitch", "I accept the standard terms and conditions", null ) var inputForm = new Form() inputForm.addField(textInputField) inputForm.addField(checkSwitchField) var formPrompt = "Form prompt:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var inputText = formObject.values['textInput'] var textStatus = ((!inputText)?false:true) var checkboxStatus = formObject.values['checkboxSwitch'] return (textStatus && checkboxStatus) } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Multiple Mandatory Text Input

In this example, the user must supply textual input in all of the provided fields before the approval button will be enabled. NOTE: to change a text field to “optional input” simply remove its status variable from the statement on line 38.

multiple-text-input
var textInputField01 = new Form.Field.String( "textInput01", "Field Label 1", null ) var textInputField02 = new Form.Field.String( "textInput02", "Field Label 2", null ) var textInputField03 = new Form.Field.String( "textInput03", "Field Label 3", null ) var inputForm = new Form() inputForm.addField(textInputField01) inputForm.addField(textInputField02) inputForm.addField(textInputField03) var formPrompt = "Form prompt:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var inputText01 = formObject.values['textInput01'] var inputText01Status = (!inputText01)?false:true var inputText02 = formObject.values['textInput02'] var inputText02Status = (!inputText02)?false:true var inputText03 = formObject.values['textInput03'] var inputText03Status = (!inputText03)?false:true // ALL CONDITIONS MUST BE TRUE TO VALIDATE var validation = (inputText01Status && inputText02Status && inputText03Status) ? true:false return validation } formPromise.then(function(formObject){ var textValue01 = formObject.values['textInput01'] var textValue02 = formObject.values['textInput02'] var textValue03 = formObject.values['textInput03'] console.log('textInput01: ',textValue01) console.log('textInput02: ',textValue02) console.log('textInput03: ',textValue03) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Text Input is Integer

In this example, the user must enter an integer (whole number):

var textInputField = new Form.Field.String( "textInput", null, null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Enter a whole number:" var buttonTitle = "Continue" var formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ inputText = formObject.values['textInput'] if (!inputText) {return false} var isnum = /^[0-9]+$/i.test(inputText) return isnum } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Text Input is Integer within Range

In this example, the user must enter an integer (whole number) that falls between the specified range, before the approval button is enabled. You can set the range by changing the values of the first two statements of the form.

integer-input
var minValue = 1 var maxValue = 34 var textInputField = new Form.Field.String( "textInput", String("(" + minValue + "-" + maxValue + ")"), null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Enter a whole number:" var buttonTitle = "Continue" var formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ inputText = formObject.values['textInput'] if (!inputText) {return false} var isnum = /^[0-9]+$/i.test(inputText) if (isnum){ var intValue = parseInt(inputText) return ((intValue <= maxValue && intValue >= minValue) ? true:false) } return false } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Text Input with Only Alpha-Numeric Characters

In this form example, the text input field will only accept alpha numeric characters (a-z A-Z and 0-9).

alpha-numeric-input
var textInputField = new Form.Field.String( "textInput", "(a-z, 0-9)", null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Enter an alpha-numeric string:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var textValue = formObject.values['textInput'] if(!textValue){return false} return (/^[a-z0-9]+$/i.test(textValue)) } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log("textValue: ",textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Enter Valid eMail Address

In this form example, the approval button will only become enabled when a fully-formed email address is entered in the text input field. For example: bob123@omniapps.uk or carla486@outlinerworld.com

email-address-input
var textInputField = new Form.Field.String( "textInput", null, null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Enter an eMail address:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var textValue = formObject.values['textInput'] if(!textValue){return false} if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(textValue)){ return true } else { throw "ERROR: not a valid eMail address." } } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log("textValue: ",textValue) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Basic Options Menu

The following form will display a single options menu:

basic-options-form
// COPY & PASTE into editor app. EDIT & SAVE with “.omnijs” file extension. /*{ "type": "action", "targets": ["omnifocus","omnigraffle","omniplan","omnioutliner"], "author": "Action Author", "identifier": "com.youOrCompany.actionName", "version": "1.0", "description": "Action Description", "label": "Menu Item Title", "shortLabel": "Toolbar Item Title" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ // action code var textInputField = new Form.Field.String( "textInput", "Field Label", null ) var inputForm = new Form() inputForm.addField(textInputField) var formPrompt = "Form prompt:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ inputText = formObject.values['textInput'] return ((!inputText)?false:true) } formPromise.then(function(formObject){ var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) // PROCESSING STATEMENTS GO HERE }) formPromise.catch(function(err){ console.error("form cancelled", err.message) }) }); action.validate = function(selection, sender){ // validation code return true }; return action; })();
var menuItems = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"] var menuIndexes = [0,1,2,3,4,5,6] var menuElement = new Form.Field.Option( "menuElement", null, menuIndexes, menuItems, 0 ) var inputForm = new Form() inputForm.addField(menuElement) var formPrompt = "Choose one of the items:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ return true } formPromise.then(function(formObject){ var menuIndex = formObject.values['menuElement'] var chosenItem = menuItems[menuIndex] console.log('Chosen item: ',chosenItem) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

(OmniFocus) Menu of Selected Tasks

In this form example (shown within an enclosing Omni Automation action), a popup menu of the titles of the selected OmniFocus tasks is displayed. When the user selects a task from the menu, its corresponding task object can be processed by the script (line 43).

menu-of-selected-tasks

(OmniFocus) Menu of Active Inbox Tasks

In this form example (shown within an enclosing Omni Automation action), a popup menu of the titles of the OmniFocus inbox tasks is displayed. When the user selects a task from the menu, its corresponding task object can be processed by the script (line 41).

menu-of-inbox-tasks

(OmniFocus) Menu of Projects with Specific Tag

In the following form example, a selection menu is displayed that lists projects that are tagged with a pre-specified tag.

projects-with-tag-menu

To use the form, change the name of the target tag from “Camera-Ready” to the title of the tag you wish to specify:

try { var targetTagName = "Camera-Ready" var targetTag = null tags.apply(function(tag){ if(tag.name == targetTagName){ targetTag = tag return ApplyResult.Stop } }) if (!targetTag){ var errMsg1 = "There is no tag titled: ”" + targetTagName + "”" throw new Error(errMsg1) } var projectsWithTag = targetTag.projects if (projectsWithTag.length === 0){ var errMsg2 = "No projects are tagged with: ”" + targetTagName + "”" throw new Error(errMsg2) } projectsWithTag.sort((a, b) => { var x = a.name.toLowerCase() var y = b.name.toLowerCase() if (x < y) {return -1} if (x > y) {return 1} return 0 }) var projectNames = projectsWithTag.map(project => {return project.name}) var projectIndxs = new Array() projectNames.forEach(function(name, index){ projectIndxs.push(index) }) var projectsMenu = new Form.Field.Option( "projectMenu", null, projectIndxs, projectNames, 0 ) var inputForm = new Form() inputForm.addField(projectsMenu) var formPrompt = "Choose a “" + targetTagName + "” project:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ return true } formPromise.then(function(formObject){ var projectIndex = formObject.values['projectMenu'] var chosenProject = projectsWithTag[projectIndex] console.log(chosenProject) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) }) } catch(err){ new Alert("ERROR", err.message).show() }

(OmniFocus) Menu of Built-in Perspectives

This plug-in will display a form containing a list of the built-in perspectives from which the user selects the one to be displayed.

perspectives-menu

NOTE: Since the function code changes the current view of the OmniFocus window, an instance of the Timer class (lines 22-24) is used to delay the code processing until the sheet (macOS) or dialog (iPadOS, iOS) are fully dismissed.

var perspectiveMenu = new Form.Field.Option( "perspective", "Perspective", Perspective.BuiltIn.all, null, Perspective.BuiltIn.all[0] ) var inputForm = new Form() inputForm.addField(perspectiveMenu) var formPrompt = "Choose the perspective:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ return true } formPromise.then(function(formObject){ var chosenPerspective = formObject.values['perspective'] console.log(chosenPerspective) Timer.once(1,function(timer){ document.windows[0].perspective = chosenPerspective }) }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })

Enter Date after Today

In the following example form, the user is prompted to provide a date after today.

date-after-today

NOTE: Date fields will accept a variety of shortcut values. Reference the page on Date Input Fields to learn all of the available date referencing options.

today = new Date(new Date().setHours(0,0,0,0)) var tomorrow = new Date(today.setDate(today.getDate() + 1)) dateInputField = new Form.Field.Date( "dateInput", null, null ) inputForm = new Form() inputForm.addField(dateInputField) formPrompt = "Enter a date/time after today:" buttonTitle = "Continue" formPromise = inputForm.show(formPrompt, buttonTitle) inputForm.validate = function(formObject){ dateInput = formObject.values["dateInput"] var status = (dateInput && dateInput >= tomorrow) ? true:false console.log(status) return status } formPromise.then(function(formObject){ dateInput = formObject.values["dateInput"] console.log(dateInput) }) formPromise.catch(function(error){ console.log("form cancelled", error.message) })

Select Date from Menus

In the following form example, the user selects a date using the year, month, and day menus:

select-date-from-menus
var locale = "en-us" var monthNames = [] for (i = 0; i < 12; i++) { var objDate = new Date() objDate.setDate(1) objDate.setMonth(i) monthName = objDate.toLocaleString(locale,{month:"long"}) monthNames.push(monthName) } var now = new Date() var currentYear = now.getFullYear() var yearNames = new Array() var yearIndexes = new Array() for (i = 0; i < 4; i++) { yearNames.push(String(currentYear + i)) yearIndexes.push(i) } var dayCount = new Date(currentYear, 1, 0).getDate() var dayIndexes = new Array() var dayIndexStrings = new Array() for (var i = 0; i < dayCount; i++){ dayIndexes.push(i) dayIndexStrings.push(String(i + 1)) } var inputForm = new Form() var yearMenu = new Form.Field.Option( "yearMenu", "Year", yearIndexes, yearNames, 0 ) var currentYearIndex = 0 var monthMenu = new Form.Field.Option( "monthMenu", "Month", [0,1,2,3,4,5,6,7,8,9,10,11], monthNames, 0 ) var currentMonthIndex = 0 var dayMenu = new Form.Field.Option( "dayMenu", "Day", dayIndexes, dayIndexStrings, 0 ) inputForm.addField(yearMenu) inputForm.addField(monthMenu) inputForm.addField(dayMenu) var formPrompt = "Select the date:" var buttonTitle = "OK" var formPromise = inputForm.show(formPrompt, buttonTitle) inputForm.validate = function(formObject){ var yearMenuIndex = formObject.values["yearMenu"] var chosenYear = parseInt(yearNames[yearMenuIndex]) var monthMenuIndex = formObject.values["monthMenu"] if(monthMenuIndex != currentMonthIndex || yearMenuIndex != currentYearIndex){ inputForm.removeField(inputForm.fields[2]) currentMonthIndex = monthMenuIndex currentYearIndex = yearMenuIndex } if (formObject.fields.length == 2){ var dayCount = new Date(chosenYear, monthMenuIndex + 1, 0).getDate() var dayIndexes = new Array() var dayIndexStrings = new Array() for (var i = 0; i < dayCount; i++){ dayIndexes.push(i) dayIndexStrings.push(String(i + 1)) } var dayMenu = new Form.Field.Option( "dayMenu", "Day", dayIndexes, dayIndexStrings, 0 ) inputForm.addField(dayMenu) } return true } formPromise.then(function(formObject){ var yearMenuIndex = formObject.values["yearMenu"] var yearName = yearNames[yearMenuIndex] var monthMenuIndex = formObject.values["monthMenu"] var monthName = monthNames[monthMenuIndex] var dayMenuIndex = formObject.values["dayMenu"] var dayIndexString = dayIndexStrings[dayMenuIndex] var targetDate = new Date(monthName + " " + dayIndexString + " " + yearName) console.log(targetDate) }) formPromise.catch(function(error){ console.log("form cancelled", error.message) })

Start and End Dates

The following example presents two date input fields for entering start and end dates:

select-date-from-menus
var inputForm = new Form() var startDateField = new Form.Field.Date( "startDate", "Start Date", null ) var endDateField = new Form.Field.Date( "endDate", "End Date", null ) inputForm.addField(startDateField) inputForm.addField(endDateField) var formPrompt = "Enter the start and end dates:" var buttonTitle = "Continue" formPromise = inputForm.show(formPrompt, buttonTitle) inputForm.validate = function(formObject){ currentDateTime = new Date() startDateObject = formObject.values["startDate"] startDateStatus = (startDateObject && startDateObject > currentDateTime) ? true:false endDateObject = formObject.values["endDate"] endDateStatus = (endDateObject && endDateObject > startDateObject) ? true:false validation = (startDateStatus && endDateStatus) ? true:false return validation } formPromise.then(function(formObject){ var StartDate = formObject.values['startDate'] var EndDate = formObject.values['endDate'] }) formPromise.catch(function(err){ console.log("form cancelled", err.message) })
 

Currency Conversion Interface

The following example demonstrates an interface for gathering data for a currency conversion calculation. (Codes from Calculator.net)

Currency Conversion Interface
var currencyCodes = ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTC", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNH", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JEP", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VES", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "YER", "ZAR", "ZMW", "ZWL"] var currencyStrings = ["United Arab Emirates Dirham", "Afghan Afghani", "Albanian Lek", "Armenian Dram", "Netherlands Antillean Guilder", "Angolan Kwanza", "Argentine Peso", "Australian Dollar", "Aruban Florin", "Azerbaijani Manat", "Bosnia-Herzegovina Convertible Mark", "Barbadian Dollar", "Bangladeshi Taka", "Bulgarian Lev", "Bahraini Dinar", "Burundian Franc", "Bermudan Dollar", "Brunei Dollar", "Bolivian Boliviano", "Brazilian Real", "Bahamian Dollar", "Bitcoin", "Bhutanese Ngultrum", "Botswanan Pula", "Belarusian Ruble", "Belize Dollar", "Canadian Dollar", "Congolese Franc", "Swiss Franc", "Chilean Unit of Account (UF)", "Chilean Peso", "Chinese Yuan (Offshore)", "Chinese Yuan", "Colombian Peso", "Costa Rican Colón", "Cuban Convertible Peso", "Cuban Peso", "Cape Verdean Escudo", "Czech Republic Koruna", "Djiboutian Franc", "Danish Krone", "Dominican Peso", "Algerian Dinar", "Egyptian Pound", "Eritrean Nakfa", "Ethiopian Birr", "Euro", "Fijian Dollar", "Falkland Islands Pound", "British Pound Sterling", "Georgian Lari", "Guernsey Pound", "Ghanaian Cedi", "Gibraltar Pound", "Gambian Dalasi", "Guinean Franc", "Guatemalan Quetzal", "Guyanaese Dollar", "Hong Kong Dollar", "Honduran Lempira", "Croatian Kuna", "Haitian Gourde", "Hungarian Forint", "Indonesian Rupiah", "Israeli New Sheqel", "Manx pound", "Indian Rupee", "Iraqi Dinar", "Iranian Rial", "Icelandic Króna", "Jersey Pound", "Jamaican Dollar", "Jordanian Dinar", "Japanese Yen", "Kenyan Shilling", "Kyrgystani Som", "Cambodian Riel", "Comorian Franc", "North Korean Won", "South Korean Won", "Kuwaiti Dinar", "Cayman Islands Dollar", "Kazakhstani Tenge", "Laotian Kip", "Lebanese Pound", "Sri Lankan Rupee", "Liberian Dollar", "Lesotho Loti", "Libyan Dinar", "Moroccan Dirham", "Moldovan Leu", "Malagasy Ariary", "Macedonian Denar", "Myanma Kyat", "Mongolian Tugrik", "Macanese Pataca", "Mauritanian Ouguiya (pre-2018)", "Mauritanian Ouguiya", "Mauritian Rupee", "Maldivian Rufiyaa", "Malawian Kwacha", "Mexican Peso", "Malaysian Ringgit", "Mozambican Metical", "Namibian Dollar", "Nigerian Naira", "Nicaraguan Córdoba", "Norwegian Krone", "Nepalese Rupee", "New Zealand Dollar", "Omani Rial", "Panamanian Balboa", "Peruvian Nuevo Sol", "Papua New Guinean Kina", "Philippine Peso", "Pakistani Rupee", "Polish Zloty", "Paraguayan Guarani", "Qatari Rial", "Romanian Leu", "Serbian Dinar", "Russian Ruble", "Rwandan Franc", "Saudi Riyal", "Solomon Islands Dollar", "Seychellois Rupee", "Sudanese Pound", "Swedish Krona", "Singapore Dollar", "Saint Helena Pound", "Sierra Leonean Leone", "Somali Shilling", "Surinamese Dollar", "South Sudanese Pound", "São Tomé and Príncipe Dobra (pre-2018)", "São Tomé and Príncipe Dobra", "Salvadoran Colón", "Syrian Pound", "Swazi Lilangeni", "Thai Baht", "Tajikistani Somoni", "Turkmenistani Manat", "Tunisian Dinar", "Tongan Pa anga", "Turkish Lira", "Trinidad and Tobago Dollar", "New Taiwan Dollar", "Tanzanian Shilling", "Ukrainian Hryvnia", "Ugandan Shilling", "United States Dollar", "Uruguayan Peso", "Uzbekistan Som", "Venezuelan Bolívar Fuerte (Old)", "Venezuelan Bolívar Soberano", "Vietnamese Dong", "Vanuatu Vatu", "Samoan Tala", "CFA Franc BEAC", "Silver Ounce", "Gold Ounce", "East Caribbean Dollar", "Special Drawing Rights", "CFA Franc BCEAO", "Palladium Ounce", "CFP Franc", "Platinum Ounce", "Yemeni Rial", "South African Rand", "Zambian Kwacha", "Zimbabwean Dollar"] var menuStrings = ["AED · United Arab Emirates Dirham", "AFN · Afghan Afghani", "ALL · Albanian Lek", "AMD · Armenian Dram", "ANG · Netherlands Antillean Guilder", "AOA · Angolan Kwanza", "ARS · Argentine Peso", "AUD · Australian Dollar", "AWG · Aruban Florin", "AZN · Azerbaijani Manat", "BAM · Bosnia-Herzegovina Convertible Mark", "BBD · Barbadian Dollar", "BDT · Bangladeshi Taka", "BGN · Bulgarian Lev", "BHD · Bahraini Dinar", "BIF · Burundian Franc", "BMD · Bermudan Dollar", "BND · Brunei Dollar", "BOB · Bolivian Boliviano", "BRL · Brazilian Real", "BSD · Bahamian Dollar", "BTC · Bitcoin", "BTN · Bhutanese Ngultrum", "BWP · Botswanan Pula", "BYN · Belarusian Ruble", "BZD · Belize Dollar", "CAD · Canadian Dollar", "CDF · Congolese Franc", "CHF · Swiss Franc", "CLF · Chilean Unit of Account (UF)", "CLP · Chilean Peso", "CNH · Chinese Yuan (Offshore)", "CNY · Chinese Yuan", "COP · Colombian Peso", "CRC · Costa Rican Colón", "CUC · Cuban Convertible Peso", "CUP · Cuban Peso", "CVE · Cape Verdean Escudo", "CZK · Czech Republic Koruna", "DJF · Djiboutian Franc", "DKK · Danish Krone", "DOP · Dominican Peso", "DZD · Algerian Dinar", "EGP · Egyptian Pound", "ERN · Eritrean Nakfa", "ETB · Ethiopian Birr", "EUR · Euro", "FJD · Fijian Dollar", "FKP · Falkland Islands Pound", "GBP · British Pound Sterling", "GEL · Georgian Lari", "GGP · Guernsey Pound", "GHS · Ghanaian Cedi", "GIP · Gibraltar Pound", "GMD · Gambian Dalasi", "GNF · Guinean Franc", "GTQ · Guatemalan Quetzal", "GYD · Guyanaese Dollar", "HKD · Hong Kong Dollar", "HNL · Honduran Lempira", "HRK · Croatian Kuna", "HTG · Haitian Gourde", "HUF · Hungarian Forint", "IDR · Indonesian Rupiah", "ILS · Israeli New Sheqel", "IMP · Manx pound", "INR · Indian Rupee", "IQD · Iraqi Dinar", "IRR · Iranian Rial", "ISK · Icelandic Króna", "JEP · Jersey Pound", "JMD · Jamaican Dollar", "JOD · Jordanian Dinar", "JPY · Japanese Yen", "KES · Kenyan Shilling", "KGS · Kyrgystani Som", "KHR · Cambodian Riel", "KMF · Comorian Franc", "KPW · North Korean Won", "KRW · South Korean Won", "KWD · Kuwaiti Dinar", "KYD · Cayman Islands Dollar", "KZT · Kazakhstani Tenge", "LAK · Laotian Kip", "LBP · Lebanese Pound", "LKR · Sri Lankan Rupee", "LRD · Liberian Dollar", "LSL · Lesotho Loti", "LYD · Libyan Dinar", "MAD · Moroccan Dirham", "MDL · Moldovan Leu", "MGA · Malagasy Ariary", "MKD · Macedonian Denar", "MMK · Myanma Kyat", "MNT · Mongolian Tugrik", "MOP · Macanese Pataca", "MRO · Mauritanian Ouguiya (pre-2018)", "MRU · Mauritanian Ouguiya", "MUR · Mauritian Rupee", "MVR · Maldivian Rufiyaa", "MWK · Malawian Kwacha", "MXN · Mexican Peso", "MYR · Malaysian Ringgit", "MZN · Mozambican Metical", "NAD · Namibian Dollar", "NGN · Nigerian Naira", "NIO · Nicaraguan Córdoba", "NOK · Norwegian Krone", "NPR · Nepalese Rupee", "NZD · New Zealand Dollar", "OMR · Omani Rial", "PAB · Panamanian Balboa", "PEN · Peruvian Nuevo Sol", "PGK · Papua New Guinean Kina", "PHP · Philippine Peso", "PKR · Pakistani Rupee", "PLN · Polish Zloty", "PYG · Paraguayan Guarani", "QAR · Qatari Rial", "RON · Romanian Leu", "RSD · Serbian Dinar", "RUB · Russian Ruble", "RWF · Rwandan Franc", "SAR · Saudi Riyal", "SBD · Solomon Islands Dollar", "SCR · Seychellois Rupee", "SDG · Sudanese Pound", "SEK · Swedish Krona", "SGD · Singapore Dollar", "SHP · Saint Helena Pound", "SLL · Sierra Leonean Leone", "SOS · Somali Shilling", "SRD · Surinamese Dollar", "SSP · South Sudanese Pound", "STD · São Tomé and Príncipe Dobra (pre-2018)", "STN · São Tomé and Príncipe Dobra", "SVC · Salvadoran Colón", "SYP · Syrian Pound", "SZL · Swazi Lilangeni", "THB · Thai Baht", "TJS · Tajikistani Somoni", "TMT · Turkmenistani Manat", "TND · Tunisian Dinar", "TOP · Tongan Pa anga", "TRY · Turkish Lira", "TTD · Trinidad and Tobago Dollar", "TWD · New Taiwan Dollar", "TZS · Tanzanian Shilling", "UAH · Ukrainian Hryvnia", "UGX · Ugandan Shilling", "USD · United States Dollar", "UYU · Uruguayan Peso", "UZS · Uzbekistan Som", "VEF · Venezuelan Bolívar Fuerte (Old)", "VES · Venezuelan Bolívar Soberano", "VND · Vietnamese Dong", "VUV · Vanuatu Vatu", "WST · Samoan Tala", "XAF · CFA Franc BEAC", "XAG · Silver Ounce", "XAU · Gold Ounce", "XCD · East Caribbean Dollar", "XDR · Special Drawing Rights", "XOF · CFA Franc BCEAO", "XPD · Palladium Ounce", "XPF · CFP Franc", "XPT · Platinum Ounce", "YER · Yemeni Rial", "ZAR · South African Rand", "ZMW · Zambian Kwacha", "ZWL · Zimbabwean Dollar"] var menuIndexes = new Array() currencyCodes.forEach((item, index) => {menuIndexes.push(index)}) var defaultFromIndex = menuStrings.indexOf("USD · United States Dollar") var defaultToIndex = menuStrings.indexOf("BTC · Bitcoin") var fromCurrencyMenu = new Form.Field.Option( "fromCurrency", "From", menuIndexes, menuStrings, defaultFromIndex ) var toCurrencyMenu = new Form.Field.Option( "toCurrency", "To", menuIndexes, menuStrings, defaultToIndex ) var textInputField = new Form.Field.String( "conversionAmount", "Amount", null ) var inputForm = new Form() inputForm.addField(fromCurrencyMenu) inputForm.addField(toCurrencyMenu) inputForm.addField(textInputField) var formPrompt = "Convert currency amount:" var buttonTitle = "Continue" var formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ var conversionAmount = formObject.values['conversionAmount'] if (!conversionAmount){return false} var isnum = /^[0-9]+$/i.test(conversionAmount) if (isnum){ var intValue = parseInt(conversionAmount) return ((intValue > 0) ? true:false) } return false } formPromise.then(function(formObject){ var fromIndex = formObject.values['fromCurrency'] var toIndex = formObject.values['toCurrency'] var fromCode = currencyCodes[fromIndex] var toCode = currencyCodes[toIndex] var conversionAmount = formObject.values['conversionAmount'] // PROCESSING STATEMENTS GO HERE new Alert("Conversion:", String(conversionAmount) + "\n" + fromCode + " --> " + toCode).show() }) formPromise.catch(function(err){ console.error("form cancelled", err.message) })
UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER