├── .gitignore
├── demo
└── img
│ ├── reload.png
│ └── bizcard_action.png
├── src
├── custom-directory-search
│ ├── index.html
│ └── script.js
├── live-text
│ ├── sample1.html
│ └── sample2.html
├── samples
│ ├── templatedLink.js
│ ├── templatedLink.html
│ ├── actions.html
│ └── actions.js
├── hook-before-send
│ ├── index.html
│ └── script.js
├── hook-before-send-disable
│ ├── index.html
│ └── script.js
├── manifest.json
├── applications.json
├── contentscript.js
├── page.js
└── custom-name-picker
│ ├── index.html
│ └── ui.js
├── tutorial_directory_search_extension
└── applications.json
├── tutorial_custom_name_picker
└── step1
│ └── applications.json
├── tutorial_getting_started
├── step2
│ └── manifest.json
├── step5
│ └── applications.json
├── step3
│ └── applications.json
├── step6
│ └── action.js
└── step4
│ └── applications.json
├── tutorial_hook_before_send
├── step1
│ └── applications.json
└── step2
│ └── applications.json
├── tutorial_css_extension
└── applications.json
├── firefox.xml
├── tutorial_live_text
├── live-text-single-action
│ └── applications.json
└── live-text-multiple-actions
│ └── applications.json
├── tutorial_third_party_file_repository_integration
└── applications.json
├── LICENSE
├── README.md
├── tutorial_navigation_bar_extension
├── cascading_menu
│ └── applications.json
├── branding
│ └── applications.json
└── add_delete_link
│ └── applications.json
└── tutorial_chat_service
└── applications.json
/.gitignore:
--------------------------------------------------------------------------------
1 | /.project
--------------------------------------------------------------------------------
/demo/img/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ibmverse/verse-developer/HEAD/demo/img/reload.png
--------------------------------------------------------------------------------
/demo/img/bizcard_action.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ibmverse/verse-developer/HEAD/demo/img/bizcard_action.png
--------------------------------------------------------------------------------
/src/custom-directory-search/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Directory Search Extension Sample
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/live-text/sample1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Live Text Widget Sample
6 |
7 |
8 |
9 | Sample 1 for the Verse Live Text Extension
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/live-text/sample2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Live Text Widget Sample
6 |
7 |
8 |
9 | Sample 2 for the Verse Live Text Extension
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/samples/templatedLink.js:
--------------------------------------------------------------------------------
1 | document.getElementById("query-str").innerHTML = "Query String for Person Action Sample"
2 | + "
" + window.location.search + "
";
3 |
4 | var href = window.location.href;
5 | console.log("window location href" + href);
6 |
7 | if (href.startsWith("chrome")) {
8 | alert("Your web page has been opened in a hidden iframe. Query String for Person Action Sample: " + window.location.search);
9 | }
10 |
--------------------------------------------------------------------------------
/src/hook-before-send/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Verse Hook Before Send
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/hook-before-send-disable/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Verse Hook Before Send
7 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tutorial_directory_search_extension/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Directory Search Extension Sample",
4 | "title": "Directory Search Extension Sample",
5 | "description": "This is a sample of directory search extension",
6 | "extensions": [
7 | {
8 | "type": "com.ibm.verse.ext.directorySearch",
9 | "payload": {
10 | "url": "${extensionPath}/custom-directory-search/index.html",
11 | "enableBuiltinDirectorySearch": false
12 | }
13 | }
14 | ],
15 | "services": ["Verse"]
16 | }
17 | ]
--------------------------------------------------------------------------------
/src/samples/templatedLink.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Verse Developer Templated Link Sample
6 |
11 |
12 |
13 | Verse Developer Templated Link Sample
14 | Templated Link Query.
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/tutorial_custom_name_picker/step1/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Custom Name Picker",
4 | "title": "Custom Name Picker",
5 | "description": "Sample that shows how to add a custom name picker in mail compose view",
6 | "extensions": [
7 | {
8 | "type": "com.ibm.verse.ext.namePicker",
9 | "name": "Custom name picker in mail compose",
10 | "title": "Add Contact",
11 | "payload": {
12 | "url": "${extensionPath}/custom-name-picker/index.html"
13 | }
14 | }
15 | ],
16 | "services": [
17 | "Verse"
18 | ]
19 | }
20 | ]
21 |
--------------------------------------------------------------------------------
/tutorial_getting_started/step2/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "IBM Verse Developer Extension for Google Chrome",
3 | "version": "1.0.0",
4 | "manifest_version": 2,
5 | "content_scripts": [ {
6 | "js": [ "contentscript.js"],
7 | "matches": [
8 | "https://mail.notes.na.collabserv.com/verse*",
9 | "https://mail.notes.ap.collabserv.com/verse*",
10 | "https://mail.notes.ce.collabserv.com/verse*",
11 | "https:///verse*"
12 | ],
13 | "run_at": "document_start"
14 | }],
15 | "web_accessible_resources": [
16 | "page.js",
17 | "applications.json"
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/src/samples/actions.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Verse Developer Action Sample
6 |
11 |
12 |
13 |
14 |
15 | Verse Developer Action Sample
16 | Waiting for messages from Verse.
17 |
18 |
19 | Messages received:
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/tutorial_hook_before_send/step1/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Hook Before Send Sample",
4 | "title": "Hook Before Send Sample",
5 | "description": "Sample that shows how to check for a credit card number in mail being sent",
6 | "extensions": [
7 | {
8 | "type": "com.ibm.verse.ext.beforeOnSend",
9 | "ext_id": "com.ibm.verse.ext.sample.beforeOnSend",
10 | "name": "Hook Before Send Extension",
11 | "title": "Hook Before Send Extension",
12 | "payload": {
13 | "url": "${extensionPath}/hook-before-send/index.html"
14 | }
15 | }
16 | ],
17 | "services": [
18 | "Verse"
19 | ]
20 | }
21 | ]
--------------------------------------------------------------------------------
/tutorial_css_extension/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "CSS Extension Sample",
4 | "description": "The sample shows how to customize Verse UI",
5 | "title": "CSS Extension Sample",
6 | "extensions": [
7 | {
8 | "type": "com.ibm.verse.ext.css",
9 | "name": "CSS extension sample",
10 | "payload": {
11 | "css": ".ics-scbanner {background-color:green!important;} .seq-window .compose-button {font-size:16px!important;background-color:red!important;} .message-list-container .seq-msg-row {background-color:yellow!important;} .createEvent {display:none!important;}"
12 | }
13 | }
14 | ],
15 | "services": [
16 | "Verse"
17 | ]
18 | }
19 | ]
--------------------------------------------------------------------------------
/tutorial_hook_before_send/step2/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Hook Before Send Sample",
4 | "title": "Hook Before Send Sample",
5 | "description": "Sample that shows how to check for a credit card number in mail being sent",
6 | "extensions": [
7 | {
8 | "type": "com.ibm.verse.ext.beforeOnSend",
9 | "ext_id": "com.ibm.verse.ext.sample.beforeOnSend",
10 | "name": "Hook Before Send Extension",
11 | "title": "Hook Before Send Extension",
12 | "payload": {
13 | "url": "${extensionPath}/hook-before-send-disable/index.html",
14 | "disableSend": true
15 | }
16 | }
17 | ],
18 | "services": [
19 | "Verse"
20 | ]
21 | }
22 | ]
23 |
--------------------------------------------------------------------------------
/tutorial_getting_started/step5/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Templated Link Sample",
4 | "title": "Templated Link Sample",
5 | "description": "This samples demonstrates using the templated link extension point",
6 | "extensions": [
7 | {
8 | "name": "Person Templated Link",
9 | "type": "com.ibm.appreg.ext.templatedLink",
10 | "object": "com.ibm.appreg.object.person",
11 | "payload": {
12 | "text": "Person Templated Link",
13 | "title": "Person Templated Link",
14 | "href": "http://127.0.0.1:8887/samples/templatedLink.html?searchFor=${profile.primaryEmail}"
15 | }
16 | }
17 | ],
18 | "services": [
19 | "Verse"
20 | ]
21 | }
22 | ]
--------------------------------------------------------------------------------
/firefox.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | firefox
8 | verse_dev_extension@ibm.com
9 | true
10 |
11 | zip
12 |
13 |
14 |
15 |
16 | src
17 | /
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "IBM Verse Developer Browser Extension",
3 | "version": "1.1.0",
4 | "manifest_version": 2,
5 | "applications": { "gecko": {"id": "verse_dev_extension@ibm.com", "strict_min_version": "45.0"} },
6 | "content_scripts": [ {
7 | "js": [ "contentscript.js"],
8 | "matches": [
9 | "https://mail.notes.na.collabserv.com/verse*",
10 | "https://mail.notes.ap.collabserv.com/verse*",
11 | "https://mail.notes.ce.collabserv.com/verse*"
12 | ],
13 | "run_at": "document_start"
14 | }],
15 | "web_accessible_resources": [
16 | "page.js",
17 | "applications.json",
18 | "samples/templatedLink.html",
19 | "samples/actions.html",
20 | "custom-name-picker/index.html",
21 | "hook-before-send/index.html",
22 | "hook-before-send-disable/index.html",
23 | "custom-directory-search/index.html"
24 | ]
25 | }
26 |
--------------------------------------------------------------------------------
/tutorial_live_text/live-text-single-action/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Live Text Widget Sample application",
4 | "title": "Live Text Widget Sample application",
5 | "description": "The sample shows how to contribute a live text extension in Verse",
6 | "extensions": [
7 | {
8 | "name": "Live Text Widget Sample Extension",
9 | "ext_id": "com.ibm.verse.livetext.sample",
10 | "type": "com.ibm.verse.ext.liveText",
11 | "payload": {
12 | "text": "Live Text Widget Action",
13 | "href": "${extensionPath}/${1}/sample1.html?tel=${2}",
14 | "recognizer": "Path:([a-z].*), Tel:([0-9]{8}).*",
15 | "location": "window",
16 | "renderParams": {
17 | "width": "800",
18 | "height": "400"
19 | }
20 | }
21 | }
22 | ],
23 | "payload": {},
24 | "services": [
25 | "Verse"
26 | ]
27 | }
28 | ]
--------------------------------------------------------------------------------
/src/samples/actions.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Print out Verse API data for all the action samples
3 | */
4 | window.addEventListener("message", function(event) {
5 | // Add check for the event origin here
6 | console.log(event);
7 |
8 | document.getElementById("status").innerHTML = "";
9 |
10 | var jsonNode = document.getElementById("json");
11 | jsonNode.innerText = jsonNode.innerText + "\n" + JSON.stringify(event.data, null, 2);
12 |
13 | /**
14 | * Message from Verse to check whether your web application is ready.
15 | */
16 | if (event.data.verseApiType === "com.ibm.verse.ping.application.loaded") {
17 | var loaded_message = {
18 | verseApiType: 'com.ibm.verse.application.loaded'
19 | };
20 | /**
21 | * Your application must send a message back to Verse
22 | * to identify that it's ready to receive data from Verse.
23 | */
24 | event.source.postMessage(loaded_message, event.origin);
25 | }
26 | }, false);
27 |
--------------------------------------------------------------------------------
/src/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Widget Samples",
4 | "title": "Widget Samples",
5 | "description": "This samples demonstrates using the widget extension point",
6 | "extensions": [
7 | {
8 | "name": "Person Action Sample",
9 | "type": "com.ibm.verse.ext.widget",
10 | "payload": {
11 | "url": "${extensionPath}/samples/actions.html",
12 | "features": [
13 | "core"
14 | ],
15 | "actions": [
16 | {
17 | "id": "com.ibm.verse.ext.person.action",
18 | "object": "com.ibm.appreg.object.person",
19 | "text": "Person Action",
20 | "title": "Person Action",
21 | "location": "window",
22 | "renderParams": {
23 | "width": "900",
24 | "height": "500"
25 | }
26 | }
27 | ]
28 | }
29 | }
30 | ],
31 | "services": [
32 | "Verse"
33 | ]
34 | }
35 | ]
36 |
--------------------------------------------------------------------------------
/tutorial_third_party_file_repository_integration/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Third-party file repository integration",
4 | "title": "Third-party file repository integration",
5 | "description": "Integrate third-party file repository in Verse",
6 | "extensions": [{
7 | "type": "com.ibm.verse.ext.file",
8 | "name": "Third-party file repository extension",
9 | "payload": {
10 | "text": "Third-Party File Repository",
11 | "url": "https://",
12 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAGpJREFUOE+1k4EKgDAIRC36b/3z6kLJFUpOejAYQ293si3MvFMREdHdCQQqoN73rKpTxlxMC4BLpBrBg95NxV74QQ1De/LFQVSD89YMQBgBmPUsQuoAjbYi/ovgb80ctN9BO0JbYOo73xAdbuoHJPh854UAAAAASUVORK5CYII=",
13 | "renderParams": {
14 | "width": "450",
15 | "height": "230"
16 | }
17 | }
18 | }],
19 | "services": [
20 | "Verse"
21 | ]
22 | }
23 | ]
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 IBM Corp.
4 | Copyright (c) 2019 HCL Corp.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # HCL Verse Developer Browser Extension
2 |
3 | HCL Verse Developer Browser Extension is a browser add-on which is used in the development of applications for HCL Verse. It allows you to register your application in HCL Verse as you develop it. Applications registered with the extension are only available in the developers' local browser, and cannot be accessed from other devices.
4 |
5 | ## What's Here
6 |
7 | ### 1. Tutorials
8 |
9 | We have a step-by-step tutorial with sample code to help you get started writing your first application for Verse quickly. We recommend following this, if it's your first time here.
10 |
11 | - To follow our tutorials, click [here][2].
12 |
13 | ### 2. Documentation
14 |
15 | Alternatively, we offer reference documentation on Verse extensibility features and how it all works. If you already have some basic idea of how to write an application for Verse, and want to dig into the details or simply looking for reference material, this is the place to go.
16 |
17 | To check out the reference documentation, click [here][1].
18 |
19 | [1]: https://doc.cwpcollaboration.com/verse-developer/docs/introduction
20 | [2]: https://doc.cwpcollaboration.com/verse-developer/docs/getting-started
21 |
--------------------------------------------------------------------------------
/src/contentscript.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright IBM Corp. 2016
3 | * Licensed under the MIT License.
4 | */
5 |
6 | var apps = chrome.extension.getURL('applications.json');
7 | var xhr = new XMLHttpRequest();
8 | xhr.overrideMimeType("application/json");
9 | xhr.onreadystatechange = function () {
10 | if (xhr.readyState === 4 && xhr.status === 200) {
11 | var appsStr = updateExtensionURLs(xhr.responseText);
12 | localStorage.setItem('applications-json', appsStr);
13 | var pageScript = document.createElement('script');
14 | pageScript.src = chrome.extension.getURL('page.js');
15 | pageScript.onload = function() {
16 | this.parentNode.removeChild(this);
17 | };
18 | (document.head||document.documentElement).appendChild(pageScript);
19 | }
20 | };
21 | xhr.open('GET', apps, true);
22 | xhr.send();
23 |
24 | /**
25 | * Updates the relative url of an extension
26 | * @param {String} definedApps - Apps defined in applications.json
27 | * @return {String} - Apps definitions with updated extension URLs
28 | */
29 | function updateExtensionURLs(definedApps) {
30 | var baseURL = chrome.extension.getURL("");
31 | definedApps = definedApps.replace(/\$\{extensionPath\}\//g, baseURL);
32 | return definedApps;
33 | }
34 |
--------------------------------------------------------------------------------
/tutorial_live_text/live-text-multiple-actions/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "The Live Text Widget Sample with Multiple Actions",
4 | "title": "The Live Text Widget Sample with Multiple Actions",
5 | "description": "The sample shows how to create multiple Live Text actions for the same Live Text in Verse",
6 | "extensions": [
7 | {
8 | "name": "Live Text Widget Action Sample One",
9 | "ext_id": "com.ibm.verse.livetext.sample.one",
10 | "type": "com.ibm.verse.ext.liveText",
11 | "payload": {
12 | "text": "Live Text Widget Action One",
13 | "href": "${extensionPath}/${1}/sample1.html?tel=${2}",
14 | "recognizer": "Path:(live-text), Tel:([0-9]{8}).*",
15 | "location": "window",
16 | "renderParams": {
17 | "width": "800",
18 | "height": "400"
19 | }
20 | }
21 | },
22 |
23 | {
24 | "name": "Live Text Widget Action Sample Two",
25 | "ext_id": "com.ibm.verse.livetext.sample.two",
26 | "type": "com.ibm.verse.ext.liveText",
27 | "payload": {
28 | "text": "Live Text Widget Action Two",
29 | "href": "${extensionPath}/live-text/sample2.html?tel=${2}",
30 | "recognizer": "Path:(live-text), Tel:([0-9]{8}).*"
31 | }
32 | }
33 | ],
34 | "payload": {},
35 | "services": [
36 | "Verse"
37 | ]
38 | }
39 | ]
--------------------------------------------------------------------------------
/src/page.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright IBM Corp. 2016
3 | * Copyright HCL Corp. 2019
4 | * Licensed under the MIT License.
5 | */
6 | console.log("Loaded Verse Developer page. Waiting for WidgetRegistryReady...");
7 | document.addEventListener("WidgetRegistryReady", function(event) {
8 | console.log("Received WidgetRegistryReady.");
9 | var widgetRegistry = event.widgetRegistry;
10 | if(!widgetRegistry) {
11 | console.error("Fail to get widgetRegistry!");
12 | return;
13 | }
14 |
15 | var jsonString = localStorage.getItem('applications-json');
16 | if(jsonString) {
17 | console.log("Loaded applications-json: " + jsonString);
18 | var apps = [];
19 | try {
20 | apps = JSON.parse(jsonString);
21 | } catch (error) {
22 | console.error("Fail to parse applications.json: %O", error);
23 | }
24 |
25 | // the applications.json file can define an array of applications or a single application
26 | if(apps instanceof Array) {
27 | apps.forEach(function(appObj) {
28 | try {
29 | console.log("Registering: %O", appObj);
30 | widgetRegistry.addWidgetFromJSON(appObj);
31 | } catch (error) {
32 | console.error("Fail to add an application %O from applications.json file: %O", appObj, error);
33 | }
34 | });
35 | } else {
36 | widgetRegistry.addWidgetFromJSON(apps);
37 | }
38 | } else {
39 | console.error("Fail to read applications.json.");
40 | }
41 | }, false);
42 |
--------------------------------------------------------------------------------
/tutorial_getting_started/step3/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Widget Samples",
4 | "title": "Widget Sampled",
5 | "description": "This samples demonstrates using the widget extension point",
6 | "extensions": [
7 | {
8 | "name": "Person Action Sample",
9 | "type": "com.ibm.verse.ext.widget",
10 | "payload": {
11 | "url": "${extensionPath}/samples/actions.html",
12 | "features": [
13 | "core"
14 | ],
15 | "actions": [
16 | {
17 | "id": "com.ibm.verse.ext.person.action",
18 | "object": "com.ibm.appreg.object.person",
19 | "text": "Person Widget Action",
20 | "title": "Person Widget Action",
21 | "location": "window",
22 | "renderParams": {
23 | "width": "900",
24 | "height": "500"
25 | }
26 | },
27 | {
28 | "id": "com.ibm.verse.ext.mail.compose.action",
29 | "path": "mail.compose",
30 | "text": "Mail Compose Action",
31 | "title": "Mail Compose Action",
32 | "location": "window",
33 | "renderParams": {
34 | "width": "900",
35 | "height": "500"
36 | }
37 | }
38 | ]
39 | }
40 | }
41 | ],
42 | "services": [
43 | "Verse"
44 | ]
45 | }
46 | ]
47 |
--------------------------------------------------------------------------------
/tutorial_navigation_bar_extension/cascading_menu/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "extensions": [
4 | {
5 | "type": "com.ibm.action.menu",
6 | "path": "com.ibm.navbar.order.3500",
7 | "applications": [
8 | "News Menu"
9 | ],
10 | "name": "NewsMenuContainer",
11 | "description": "This sample shows how to contribute a menu container",
12 | "title": "News"
13 | },
14 | {
15 | "type": "com.ibm.action.menu.link",
16 | "path": "NewsMenuContainer.1",
17 | "applications": [
18 | "News Menu"
19 | ],
20 | "name": "News.CNN",
21 | "description": "This sample shows how to contribute a submenu",
22 | "payload": {
23 | "link": "http://cnn.com",
24 | "target":"_blank"
25 | },
26 | "title": "CNN"
27 | },
28 | {
29 | "type": "com.ibm.action.menu.link",
30 | "path": "NewsMenuContainer.2",
31 | "applications": [
32 | "News Menu"
33 | ],
34 | "name": "News.BBC",
35 | "description": "This sample shows how to contribute a submenu",
36 | "payload": {
37 | "link": "http://bbc.com/news",
38 | "target":"_blank"
39 | },
40 | "title": "BBC"
41 | }
42 | ],
43 | "title": "News Menu",
44 | "name": "News Menu",
45 | "description": "This sample shows how to contribute a cascading menu",
46 | "payload": {},
47 | "services": [
48 | "TopNavigationBar"
49 | ]
50 | }
51 | ]
--------------------------------------------------------------------------------
/tutorial_getting_started/step6/action.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Print out Verse API data for all the action samples
3 | */
4 | window.addEventListener("message", function(event) {
5 | if (!isValidOrigin(event.origin)) {
6 | return;
7 | }
8 | var eventData = event.data;
9 |
10 | console.log(event);
11 |
12 | document.getElementById("status").innerHTML = "";
13 |
14 | document.getElementById("messages").innerHTML = "Message received: " + "
";
15 |
16 | document.getElementById("json").innerText = JSON.stringify(eventData, null, 2);
17 |
18 | /**
19 | * Message from Verse to check whether your web application is ready.
20 | */
21 | if (eventData.verseApiType === "com.ibm.verse.ping.application.loaded") {
22 | var loaded_message = {
23 | verseApiType: 'com.ibm.verse.application.loaded'
24 | };
25 | /**
26 | * Your application must send a message back to Verse
27 | * to identify that it's ready to receive data from Verse.
28 | */
29 | event.source.postMessage(loaded_message, event.origin);
30 | }
31 | }, false);
32 |
33 | /** Verify we are listening to the right origin
34 | * @param {String} currentOrigin - The url which we should listen to
35 | * @return {Boolean} true if the origin is valid, false otherwise
36 | */
37 | function isValidOrigin(currentOrigin) {
38 | var originsList = [
39 | "https://mail.notes.na.collabserv.com",
40 | "https://mail.notes.ap.collabserv.com",
41 | "https://mail.notes.ce.collabserv.com"
42 | ];
43 | for (var i = 0; i < originsList.length; i++) {
44 | if (originsList[i].indexOf(currentOrigin) !== -1) {
45 | return true;
46 | }
47 | }
48 | return false;
49 | }
50 |
--------------------------------------------------------------------------------
/src/hook-before-send/script.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | 'use strict';
3 |
4 | window.addEventListener('message', function(event) {
5 | // Add check for the event origin here
6 | if(event.data) {
7 | if (event.data.verseApiType === 'com.ibm.verse.ping.application.loaded') {
8 | var loaded_message = {
9 | verseApiType: 'com.ibm.verse.application.loaded'
10 | };
11 | event.source.postMessage(loaded_message, event.origin);
12 | } else if (event.data.verseApiType === 'com.ibm.verse.action.clicked') {
13 | if(event.data.verseApiData.context) {
14 | checkMailBody(event.data.verseApiData.context.body, event);
15 | } else {
16 | console.warn('No context data retrieved from Verse');
17 | }
18 | }
19 | } else {
20 | console.warn('No data retrieved from Verse');
21 | }
22 | }, false);
23 |
24 | /*
25 | * Checks if the mail body contains a credit card number and if it does displays a warning.
26 | * @param {String} body Body of the mail as HTML
27 | * @param {String} event Before on send action events
28 | */
29 | function checkMailBody(body, event) {
30 | var regex = /\b(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}\b/
31 | var found = regex.test(body);
32 | if (found) {
33 | var errorNode = document.getElementById('error');
34 | errorNode.textContent = 'Are you sure you want to send an email that contains a credit card number?';
35 | } else {
36 | var response_message = {
37 | verseApiType: 'com.ibm.verse.message.continue.send'
38 | };
39 | event.source.postMessage(response_message, event.origin);
40 | }
41 | }
42 |
43 | })();
44 |
--------------------------------------------------------------------------------
/src/hook-before-send-disable/script.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | 'use strict';
3 |
4 | window.addEventListener('message', function(event) {
5 | // Add check for the event origin here
6 | if(event.data) {
7 | if (event.data.verseApiType === 'com.ibm.verse.ping.application.loaded') {
8 | var loaded_message = {
9 | verseApiType: 'com.ibm.verse.application.loaded'
10 | };
11 | event.source.postMessage(loaded_message, event.origin);
12 | } else if (event.data.verseApiType === 'com.ibm.verse.action.clicked') {
13 | if(event.data.verseApiData.context) {
14 | checkMailBody(event.data.verseApiData.context.body, event);
15 | } else {
16 | console.warn('No context data retrieved from Verse');
17 | }
18 | }
19 | } else {
20 | console.warn('No data retrieved from Verse');
21 | }
22 | }, false);
23 |
24 | /*
25 | * Checks if the mail body contains a credit card number and if it does displays a warning.
26 | * @param {String} body Body of the mail as HTML
27 | * @param {String} event Before on send action events
28 | */
29 | function checkMailBody(body, event) {
30 | var regex = /\b(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}\b/
31 | var found = regex.test(body);
32 | if (found) {
33 | var errorNode = document.getElementById('error');
34 | errorNode.textContent = 'You are not permitted to send an email that contains a credit card number.';
35 | } else {
36 | var response_message = {
37 | verseApiType: 'com.ibm.verse.message.continue.send'
38 | };
39 | event.source.postMessage(response_message, event.origin);
40 | }
41 | }
42 |
43 | })();
44 |
--------------------------------------------------------------------------------
/tutorial_getting_started/step4/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Widget Samples",
4 | "title": "Widget Sampled",
5 | "description": "This samples demonstrates using the widget extension point",
6 | "extensions": [
7 | {
8 | "name": "Person Action Sample",
9 | "type": "com.ibm.verse.ext.widget",
10 | "payload": {
11 | "url": "${extensionPath}/samples/actions.html",
12 | "features": [
13 | "core"
14 | ],
15 | "actions": [
16 | {
17 | "id": "com.ibm.verse.ext.person.action",
18 | "object": "com.ibm.appreg.object.person",
19 | "text": "Person Widget Action",
20 | "title": "Person Widget Action",
21 | "location": "window",
22 | "renderParams": {
23 | "width": "900",
24 | "height": "500"
25 | }
26 | },
27 | {
28 | "id": "com.ibm.verse.ext.mail.compose.action",
29 | "path": "mail.compose",
30 | "text": "Mail Compose Action",
31 | "title": "Mail Compose Action",
32 | "location": "window",
33 | "renderParams": {
34 | "width": "900",
35 | "height": "500"
36 | }
37 | },
38 | {
39 | "id": "com.ibm.verse.ext.mail.read.action",
40 | "path": "mail.read",
41 | "text": "Mail Read Action",
42 | "title": "Mail Read Action",
43 | "location": "window",
44 | "renderParams": {
45 | "width": "900",
46 | "height": "500"
47 | }
48 | }
49 | ]
50 | }
51 | }
52 | ],
53 | "services": [
54 | "Verse"
55 | ]
56 | }
57 | ]
58 |
--------------------------------------------------------------------------------
/tutorial_navigation_bar_extension/branding/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "extensions": [
4 | {
5 | "name": "Delete the default Org link",
6 | "type": "com.ibm.action.delete",
7 | "path": ".org",
8 | "title": "Delete the default Org link",
9 | "description": "This sample shows how to delete the default organization link",
10 | "applications": [
11 | "Branding App"
12 | ]
13 | },
14 | {
15 | "name": "New Company Name",
16 | "type": "com.ibm.action.link",
17 | "path": "com.ibm.navbar.order.1500",
18 | "title": "New Company Name",
19 | "description": "This sample shows how to add a new organization link",
20 | "payload": {
21 | "link": "http://www.ibm.com",
22 | "title": "New Company Name",
23 | "window_features": "target=_blank"
24 | }
25 | },
26 | {
27 | "name": "New Company logo",
28 | "type": "com.ibm.action.link",
29 | "title": "New Company Name",
30 | "path": "com.ibm.navbar.order.1000",
31 | "description": "This sample shows how to add a new organization logo",
32 | "payload": {
33 | "link": "http://www.ibm.com",
34 | "title": "New Company Name",
35 | "icon": "data:image/svg+xml;base64,PHN2ZyBjbGFzcz0nY2hhdC1pbWFnZScgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJyBmaWxsPSd3aGl0ZScgdmlld0JveD0nMCAwIDIwIDIwJz48cGF0aCBjbGFzcz0nY2hhdC1pbWFnZS1vdXRsaW5lJyBkPSdNMTAgMEM1LjYgMCAyIDMuNiAyIDhjMCA0LjEgMy4xIDcuNCA3IDcuOVYyMGw2LjgtNi41QzE3LjEgMTIuMSAxOCAxMC4xIDE4IDhjMC00LjQtMy42LTgtOC04em01IDEyLjlsLTUgNC43VjE1Yy0zLjkgMC03LTMuMS03LTdzMy4xLTcgNy03IDcgMy4xIDcgN2MwIDEuOS0uOCAzLjYtMiA0Ljl6Jy8+PC9zdmc+",
36 | "window_features": "target=_blank"
37 | }
38 | }
39 | ],
40 | "title": "Branding App",
41 | "name": "Branding App",
42 | "description": "This sample shows how to brand Verse",
43 | "payload": {},
44 | "services": [
45 | "TopNavigationBar"
46 | ]
47 | }
48 | ]
--------------------------------------------------------------------------------
/tutorial_navigation_bar_extension/add_delete_link/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "extensions": [
4 | {
5 | "type": "com.ibm.action.link",
6 | "path": "com.ibm.navbar.order.10000",
7 | "applications": [
8 | "Narbar App"
9 | ],
10 | "name": "Sample Link 1",
11 | "description": "This sample shows how to add a top-level link",
12 | "payload": {
13 | "link": "http://www.ibm.com",
14 | "title": "Sample Link 1",
15 | "window_features": "target=_blank"
16 | },
17 | "title": "Sample Link 1"
18 | },
19 | {
20 | "type": "com.ibm.action.link",
21 | "path": "com.ibm.navbar.order.390000",
22 | "applications": [
23 | "Narbar App"
24 | ],
25 | "name": "Sample Link 2",
26 | "description": "This sample shows how to add a top-level link",
27 | "payload": {
28 | "link": "http://www.ibm.com",
29 | "title": "Sample Link 2",
30 | "window_features": "target=_blank"
31 | },
32 | "title": "Sample Link 2"
33 | },
34 | {
35 | "type": "com.ibm.action.link",
36 | "path": "com.ibm.navbar.order.96001",
37 | "applications": [
38 | "Narbar App"
39 | ],
40 | "name": "Sample Link 3",
41 | "title": "Sample Link 3",
42 | "description": "This sample shows how to add a new link to More menu",
43 | "payload": {
44 | "link": "http://www.ibm.com",
45 | "title": "Sample Link 3",
46 | "window_features": "target=_blank"
47 | }
48 | },
49 | {
50 | "type": "com.ibm.action.delete",
51 | "path": ".mailnotebook",
52 | "applications": [
53 | "Navbar App"
54 | ],
55 | "name": "Delete Notebook link",
56 | "description": "This sample shows how to delete the Notebook link from the More menu",
57 | "title": "Delete Notebook Link"
58 | }
59 | ],
60 | "title": "Navbar App",
61 | "name": "Navbar App",
62 | "description": "Navbar App",
63 | "payload": {},
64 | "services": [
65 | "TopNavigationBar"
66 | ]
67 | }
68 | ]
--------------------------------------------------------------------------------
/src/custom-directory-search/script.js:
--------------------------------------------------------------------------------
1 | window.onload = function () {
2 | var verseWindow;
3 | var verseOrigin;
4 | var samples =
5 | [
6 | {
7 | "emailAddress": "userSample1@test.com",
8 | "notesAddress": "CN=User Sample 1/OU=China/O=HCL",
9 | "displayName": "User Sample 1"
10 | },
11 | {
12 | "emailAddress": "userSample2@test.com",
13 | "displayName": "User Sample 2"
14 | },
15 | {
16 | "notesAddress": "CN=User Sample 3/OU=China/O=HCL",
17 | "displayName": "User Sample 3"
18 | },
19 | {
20 | "emailAddress": "userSample4@test.com",
21 | },
22 | {
23 | "notesAddress": "CN=User Sample 5/OU=China/O=HCL",
24 | },
25 | {
26 | "emailAddress": "userSample6@test.com",
27 | "displayName": "User Sample 6",
28 | "forwardMailAddress": "userForward@test.com"
29 | }
30 | ];
31 |
32 | window.addEventListener('message', function(event) {
33 | var verseApiType = event && event.data && event.data.verseApiType;
34 | verseWindow = event.source;
35 | verseOrigin = event.origin;
36 | // 1. The extension must reply 'com.ibm.verse.ping.application.loaded' message sent from Verse as below, to tell Verse the extension is loaded
37 | if (verseApiType === 'com.ibm.verse.ping.application.loaded') {
38 | var loaded_message = {
39 | verseApiType: 'com.ibm.verse.application.loaded'
40 | };
41 | verseWindow.postMessage(loaded_message,verseOrigin);
42 | } else if (verseApiType === 'com.ibm.verse.action.clicked') {
43 | // 2. The extension checks Verse message and gets the search string.
44 | var actionId = event.data.verseApiData && event.data.verseApiData.actionId;
45 | if ( actionId === "com.ibm.verse.ext.action.directorySearch") {
46 | var searchString = event.data.verseApiData && event.data.verseApiData.context
47 | && event.data.verseApiData.context.searchString;
48 |
49 | // 3. The extension executes search and returns the search results to Verse.
50 | // You can replace below Search Logic block with your own one
51 | // === Search Logic Start ==
52 | var searchResult = '';
53 | // Use a sample data as returned result
54 | if (searchString == 'sample hcl') {
55 | searchResult = samples;
56 | }
57 | // === Search Logic End ===
58 |
59 | var searched_message = {
60 | verseApiType: 'com.ibm.verse.ext.directorySearch.searchResults',
61 | returnCode: 0,
62 | result: searchResult,
63 | };
64 | verseWindow.postMessage(searched_message, verseOrigin);
65 | }
66 | }
67 | }, false);
68 | };
69 |
--------------------------------------------------------------------------------
/src/custom-name-picker/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
110 |
111 |
112 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/tutorial_chat_service/applications.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "Chat Service Integration Sample",
4 | "title": "Chat Service Integration Sample",
5 | "description": "This is a sample to integrate third-party chat service in Verse",
6 | "extensions": [
7 | {"type": "com.ibm.appreg.ext.disableSametime"},
8 | {"type": "com.ibm.appreg.ext.disableSTMeetings"},
9 | {
10 | "type": "com.ibm.appreg.ext.templatedLink",
11 | "object": "com.ibm.appreg.object.person",
12 | "payload": {
13 | "text": "Jabber Chat",
14 | "icon": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAeAB4AAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAbABsDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9+z0rwD40f8FLfhZ8DtV1C11C+1zVl0WXyNVudF0mfULbSnBAKyyxjbuUkBlUsynggEV7T4/1a/0HwNrF7pVoL/U7SymmtLZs7Z5VQlFOOcFgM45x05r47+BPie5+EniTQNdj+OL+OPC8saWut6Hrd5FaGzLgRpcWqmONQqZOYAArADyxuUB/fybLYV6dSvVg5qNklFtNt+fLJLyva/Ru1j4viniCrgq9HCUJKDnducoqUYpW6c8G9/s8zXVJan1b8Ffjv4R/aI8D2/iPwXr1j4g0e5A23Fs+dpxnaynDK2CDhgDyK66vk/8AZ4j8PWf7dHiK9+G9pAnhfxHo7y+Ihbo0cY1COfckxVsFd3nOAoGCWcjo2PrAVzZ1l8MJiFCndJpStL4o36S818rqzsrnpcM5vUzHCOpWtzRk4txvySt9qN9eV3++4jdK+DviR/wTUv8A4yfHNms9P1z4e+CNOvnuIorXU4roahMAwSdYxIv2eMZJVBuOSTx2+8qKMqzvG5bOVTBT5XJWf/Dbel1p0sy8+4Yy7OYwhmEOZQbt033V1aSWz91q9le60PL/ANmD9k7wz+yt4au7PQftdxd6myPfXtzIXluim7bn6F3Pc5Y5J4x6gOKKK4cViq2Jqyr4iTlOW7e7PSy7LsNgMNHCYOHJTjsl9731bb1bererP//Z",
15 | "href": "xmpp://${emails}",
16 | "locator": "chat"
17 | }
18 | },
19 | {
20 | "type": "com.ibm.appreg.ext.templatedLink",
21 | "object": "com.ibm.appreg.object.person",
22 | "payload": {
23 | "text": "WebEx meeting",
24 | "icon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAARbSURBVEhL7ZZ7TJVlHMdfmsFqXRaLOYJic7OsQOBc4NxvhIhoDmfkFunQ8IgHsYwpSGCwnEoZt5kKyYhkGkoRIKFcLPvTP1picFx0mWlbzSFnh8vBc/n2ex9eqMN7jrxtzf7xuz3nOed5f8/7eX6X53kOh/9J98H3TJLAPmpueKGo6wR3yA7unQsIyW/HImsruKwTWJ9/DB7BTqoWBLvdboRXDoCrGwRXOYSoonO4QeN/UrtJ7bG1NYhKq0a05QjiMnbyUyQpCPgOLd+LP+jbQycmwB3/DROTLsDjBn36y0vN58J3P9HL1r6AsI2JmKL5Hv6Bzz1jE0CBwXcm8SN1YZ/8gqrvnUIIvawXhVMY4Lu+65fx6KZ4RG6XYZSW6GKrCqzAYI8XoV0OaE5eZtOliAd7fNMIz01ETIESy0vkfGEElQg8TS201QHuNJ9J6fIxihdP2eRY+nYylGVqpL9nodHA9AAee8G13sSY8EuqeI9dlN2YAgVii1RQV6iRWqWZS8V8icAxLbRdTlGl/Gu5qRidWFaogKxUBeMBLdLrdGj8tlp47i8RmGsbg6l5EP0/O4QRafJRpEwFq5DAe1uuQsoHWqw5psem5lTBwl8i8AMtv6NtxIXuq6NCdoJXpp/oBJEXa1lu9Qc0SKvRIbPRhM1tKwUDf4nAIfW/omd4HOeHHei2j2PKKw08TctMKFWy3Jrf12H1R0ZkNZvwRucKwcJfYo8bhgnsZODzw7dx8doYq/S77g0qIMPuNKjLtCy3adUGrGswIvszM7b1SAw1Vz2EMyOeOY9nFuDApPBcJDrh4JuCslQB7X4Ny23GEQOymozI+cKCnf1SwVVXsKToDHrst+egs+3SDzdm/P7nFqEB3R7y9l0NzJVarKwxIvNjM7JPmWDtsqBowCIY+ksEjjj4Fd0+vegfuiUCd9ud6LOPYkKw5eWkw1FdooB+vw6pH+pZbl9pMiPnbAryL5jw+ZVawdJfIjB/vXElF3GSrp754NnG10DfiAPXx31QlKihKVfCfEjP9u26BgteP21EXqcFbw5QYQWpTRGYP5kfLOhAWF5XQCjf+Gh8MziFRVnL8MTWeDxti2dF9fJxHTZ8asCGZjNs3UYU96VTJuimCyARmImuPy63HaGra9F9TRzyXqr2J7coEL7tRURtl2PJDgWe261E/N5kJJUZkHcuHYWXVP61ME8Bwfwqx6mPXlOPxWl16Bi5xWBfX51C8dkWPLIxDhFb5Ii0yvHMjiQ8+1YSEvZqkbwvCZu/NGBXn5ldiXfhBvGYXeR0KNDMiNR6RK46ipDM5Qh9NRYPZ8ciPCcRi60yRNtkzNu4QhWSKxKwtd0IW28SLdxJufWydwRTEPDf8ng8eDw1jv5ZPE9expOHFNY9KsgopLqDBmQc1eO1Rj2s7S+hoj1XmLWwFgTPappCp8pdgaW7NFCUq5FSa4TpsBbrm3Q43LGP2XhmdrkkSQb/17oPvkcC/gLPZ5Rn6HFpXQAAAABJRU5ErkJggg==",
25 | "href": "https://ibm.webex.com/join/${emails}",
26 | "locator": "meeting"
27 | }
28 | }
29 | ],
30 | "services": [
31 | "Verse"
32 | ]
33 | }
34 | ]
35 |
--------------------------------------------------------------------------------
/src/custom-name-picker/ui.js:
--------------------------------------------------------------------------------
1 | // Add event handlers for select boxes and call the API to load new people
2 | function addEventHandler(elem, eventType, handler) {
3 | if (elem.addEventListener) {
4 | elem.addEventListener (eventType, handler, false);
5 | } else if (elem.attachEvent) {
6 | elem.attachEvent ('on' + eventType, handler);
7 | }
8 | }
9 |
10 | var SamplePeople = [
11 | {
12 | "email" : "fadams@mailinator.com",
13 | "name" : "Frank Adams",
14 | "image" : "https://raw.githubusercontent.com/IBM-Design/icons/master/dist/png/object-based/person_128.png"
15 | },
16 | {
17 | "email" : "sdaryn@mailinator.com",
18 | "name" : "Samantha Daryn",
19 | "image" : "https://raw.githubusercontent.com/IBM-Design/icons/master/dist/png/object-based/person_128.png"
20 | },
21 | {
22 | "email" : "respinosa@mailinator.com",
23 | "name" : "Ron Espinosa",
24 | "image" : "https://raw.githubusercontent.com/IBM-Design/icons/master/dist/png/object-based/person_128.png"
25 | }
26 | ];
27 |
28 |
29 | var evt = undefined;
30 |
31 | (function() {
32 | window.addEventListener('message', function(event) {
33 | // Add check for the event origin here
34 | var eventData = event.data;
35 | console.log('Received event: %O', eventData);
36 | /**
37 | * Message from Verse to check whether your web application is ready.
38 | */
39 | if (eventData.verseApiType === 'com.ibm.verse.ping.application.loaded') {
40 | var loaded_message = {
41 | verseApiType: 'com.ibm.verse.application.loaded'
42 | };
43 | /**
44 | * Your application must send a message back to Verse
45 | * to identify that it's ready to receive data from Verse.
46 | */
47 | event.source.postMessage(loaded_message, event.origin);
48 | evt = event;
49 | }
50 | else if (eventData.verseApiType === 'com.ibm.verse.action.clicked') {
51 | for(var i = 0; i < SamplePeople.length; i++){
52 | setContact(SamplePeople[i]["email"], SamplePeople[i]["name"], SamplePeople[i]["image"]);
53 | }
54 | }
55 | }, false);
56 | })();
57 |
58 | /**
59 | * Build a contact list item and append it to the list
60 | * @param email {String} - person's email address
61 | * @param name {String} - person's name
62 | * @param image {String} - profile picture url
63 | */
64 | function setContact(email, name, image) {
65 | var resultsList = document.getElementById("results-list");
66 |
67 | var liNode = document.createElement("li");
68 |
69 | var emailNode = document.createElement("div");
70 | emailNode.className = "user-email";
71 |
72 | var nameNode = document.createElement("div");
73 | nameNode.className = "user-name";
74 |
75 | var imgNode = document.createElement("img");
76 | imgNode.className = "user-avatar";
77 |
78 | var addBtnNode = document.createElement("div");
79 | addBtnNode.className = "add-contact";
80 |
81 | var textEmailNode = document.createTextNode(email);
82 | var textNameNode = document.createTextNode(name);
83 | var imgSrcNode = image;
84 |
85 | emailNode.appendChild(textEmailNode);
86 | nameNode.appendChild(textNameNode);
87 | imgNode.src = imgSrcNode;
88 |
89 | liNode.appendChild(imgNode);
90 | liNode.appendChild(nameNode);
91 | liNode.appendChild(emailNode);
92 | addBtnNode.innerHTML = 'Add';
93 | liNode.appendChild(addBtnNode);
94 | liNode.setAttribute("tabindex", "1");
95 |
96 | resultsList.appendChild(liNode);
97 |
98 | addEventHandler(addBtnNode, "click", function() {
99 | this.parentNode.classList.add("added-contact");
100 | var addBtn = this.querySelector("span");
101 | setTimeout(function() {
102 | addBtn.innerText = "Added";
103 | }, 300);
104 |
105 | var userEmail = this.parentNode.querySelector(".user-email").innerText;
106 | var userName = this.parentNode.querySelector(".user-name").innerText;
107 | var emails_message = {
108 | verseApiType: "com.ibm.verse.add.contact",
109 | userEmail: userEmail,
110 | userName: userName
111 | };
112 | evt.source.postMessage(emails_message, evt.origin);
113 | });
114 | }
115 |
--------------------------------------------------------------------------------