diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4579b6 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# Introduction +TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. + +# Getting Started +TODO: Guide users through getting your code up and running on their own system. In this section you can talk about: +1. Installation process +2. Software dependencies +3. Latest releases +4. API references + +# Build and Test +TODO: Describe and show how to build your code and run the tests. + +# Contribute +TODO: Explain how other users and developers can contribute to make your code better. + +If you want to learn more about creating good readme files then refer the following [guidelines](https://www.visualstudio.com/en-us/docs/git/create-a-readme). You can also seek inspiration from the below readme files: +- [ASP.NET Core](https://github.com/aspnet/Home) +- [Visual Studio Code](https://github.com/Microsoft/vscode) +- [Chakra Core](https://github.com/Microsoft/ChakraCore) \ No newline at end of file diff --git a/abnamrotrial.html b/abnamrotrial.html index d097db5..65fa842 100644 --- a/abnamrotrial.html +++ b/abnamrotrial.html @@ -4,31 +4,44 @@ - + Nederlandstalige Chat -
- - Baas's avatar -
-

Baas

- Smalltalk -
-
-
-
-
-
- + OVER BAAS +

+ Logo +

+ diff --git a/chatbot.html b/chatbot.html index 554fb53..9a96458 100644 --- a/chatbot.html +++ b/chatbot.html @@ -11,24 +11,37 @@ -
- - Baas's avatar -
-

Baas

- Smalltalk -
-
-
-
-
-
- + OVER BAAS +

+ Logo +

+ diff --git a/chatbotcors.html b/chatbotcors.html index 213ec09..cfc3345 100644 --- a/chatbotcors.html +++ b/chatbotcors.html @@ -11,24 +11,37 @@ -
- - Baas's avatar -
-

Baas

- Smalltalk CORS -
-
-
-
-
-
- + OVER BAAS +

+ Logo +

+ diff --git a/css/style.css b/css/style.css index 66933ea..6b36e11 100644 --- a/css/style.css +++ b/css/style.css @@ -12,7 +12,26 @@ html { body { font-family: Roboto; height: 100%; - padding-bottom: calc(67px + .2em); + /* padding-bottom: calc(67px + .2em); */ + background:#fff url(../img/background.jpg); + background-size:cover; + overflow:hidden; +} +.whitelayer { + background:rgba(255,255,255, .6); + width:100%; + height:100%; + overflow:hidden; +} +.wrap { + display:block; + width:100%; + height:100%; + border-radius:5px; + overflow:hidden; + margin:10% auto; + margin-top:0; + position:relative; } header { display:block; @@ -21,18 +40,57 @@ header { background:#15822F; background:#2B9A44; padding:.5em; + text-align:center; } main { - padding-bottom: 41px; + /* padding-bottom: 41px; */ overflow-y: scroll; height: 100%; + background:#fff; + height: calc(100% - 108px); +} +#backButton { + position:relative; + background:#F29108; + display:block; + color:#fff; + padding: .6em 1.2em; + z-index:999; + border-radius: 0 0 5px 5px; + margin: -10% auto 0; + width:140px; + text-decoration: none; + text-align:center; } +#backButton span { + font-weight:bold; +} +#logoOrange a { + display:block; + width:100%; + height:100%; +} +#logoOrange { + bottom:0; + top:10%; + right:auto; + margin:auto; + position:relative; + background:url(../img/logo.png)no-repeat center; + background-size:contain; + text-indent:-9999em; + width:200px; + height:100px; +} + .botname { color:#fff; height:51px; display:inline-block; + vertical-align: middle; padding: 0.5em; line-height: 1em; + text-align:left; } .botname h2{ font-size:1em; @@ -40,10 +98,11 @@ main { .botname span{ font-size:.666em; } - .wavy { - float:left; height:51px; + display:inline-block; + vertical-align: middle; + filter: drop-shadow(0px 0px 4px #0a3e17); } .conversationQuestion { color: #F00; @@ -87,6 +146,7 @@ div[id^="r"] { display:inline-block; vertical-align:middle; padding:.2em .5em; + border:0; } button { @@ -109,9 +169,11 @@ button { margin:0; margin-left:-4px; width:64px; - height:40px; + height:41px; display:inline-block; vertical-align:middle; + background-color: #fff; + color: #999; } #button-yes { @@ -135,12 +197,13 @@ button { } footer { -} -.bottom { width:100%; position: absolute; bottom:0; } +.bottom { + height:40px; +} /*========== Mobile First Method ==========*/ @@ -151,17 +214,50 @@ footer { /* Extra Small Devices, Phones */ @media only screen and (min-width : 480px) { - + .wrap { + display: block; + width: 480px; + height: 480px; + border-radius: 5px; + overflow: hidden; + margin: 10% auto; + position: relative; + } } /* Small Devices, Tablets */ @media only screen and (min-width : 768px) { - + .wrap { + left:-5%; + } + #backButton { + position: absolute; + left: 0; + top: 32%; + background: #F29108; + color: #fff; + padding: .5em 1em; + transform: rotate(90deg); + transform-origin: left bottom; + margin-top: -37px; + z-index: 999; + border-radius: 5px 5px 0 0; + } + #logoOrange { + left:-5%; + } } /* Medium Devices, Desktops */ @media only screen and (min-width : 992px) { - + #logoOrange { + position:absolute; + right:10%; + left:auto; + top:35%; + bottom:auto; + /* background:#F29108; */ + } } /* Large Devices, Wide Screens */ diff --git a/feedbackbot.html b/feedbackbot.html index 8c63504..545fa4f 100644 --- a/feedbackbot.html +++ b/feedbackbot.html @@ -1,20 +1,46 @@ - - - - + - Nederlandstalige Feedback Bot + + + + + + Nederlandstalige Chat + -

Feedbackbot minimalistisch

-
-
-
- - +
+
+ +
+ + Baas's avatar +
+

BaaS

+ Beschikbaar +
+
+
+
+
+ +
+
+
+
+ + +
+
+ +
+ OVER BAAS +

+ Logo +

diff --git a/img/background.jpg b/img/background.jpg new file mode 100644 index 0000000..b6da591 Binary files /dev/null and b/img/background.jpg differ diff --git a/img/logo.png b/img/logo.png new file mode 100644 index 0000000..2704688 Binary files /dev/null and b/img/logo.png differ diff --git a/krampgroeptrial.html b/krampgroeptrial.html index d9117f9..e62c1ab 100644 --- a/krampgroeptrial.html +++ b/krampgroeptrial.html @@ -4,31 +4,44 @@ - + Nederlandstalige Chat -
- - Baas's avatar -
-

Baas

- Smalltalk -
-
-
-
-
-
- + OVER BAAS +

+ Logo +

+
diff --git a/scripts/feedback.js b/scripts/feedback.js deleted file mode 100644 index 7c16b3c..0000000 --- a/scripts/feedback.js +++ /dev/null @@ -1,315 +0,0 @@ -var conversationIndex = 1; -var watsonContext = ""; - -function loadJSON() { - //Question - var questionText = document.getElementById('input').value; - questionText.style = 'float: left; width:80%;'; - - var dialog = new Object(); - dialog.newQuestion = questionText; - - if (questionText != "") { - var qTOAdd = document.createDocumentFragment(); - var qNnewDiv = document.createElement('div'); - qNnewDiv.id = 'q'+conversationIndex; - qNnewDiv.className = 'direct-chat-msg right'; - qNnewDiv.style = 'font-family: sans-serif; font-weight:bold; font-size:11px; margin-right:0px; text-align: justify; margin-right: 0px; float:right; overflow: auto; background-color: #ed8c00; border-radius: 3px; margin: 10px; padding: 5px; text-align: left; color: #fff; margin-right:0px;'; - - var clearfixDiv = document.createElement('div') - clearfixDiv.className = 'direct-chat-info clearfix'; - - var chatnameleft = document.createElement('span') - chatnameleft.className = 'direct-chat-name pull-left'; - chatnameleft.innerHTML= ""; - chatnameleft.style = 'display: none;'; - - var qtext = document.createElement('span'); - qtext.className = 'direct-chat-text'; - qtext.innerHTML=questionText; - qTOAdd.appendChild(qNnewDiv); - qNnewDiv.appendChild(clearfixDiv); - clearfixDiv.appendChild(chatnameleft); - qNnewDiv.appendChild(qtext); - document.getElementById("conversation").appendChild(qTOAdd); - scrolldown(); - } - - console.log(watsonContext) - if (watsonContext != "") { - updateWatsonContext(watsonContext); //Retrieve timestamps and returns them to Conversation Service within context variable - dialog.context=watsonContext; - } - - var url = "https://openwhisk.ng.bluemix.net/api/v1/web/e-office_development/default/eogfeedback.json"; //BELANGRIJK - //var url = "http://localhost:9080/api/chatbotpostnl"; //local - - $.ajax({ - url: url, - type: 'post', - dataType: 'json', - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(dialog), - success: function (data) { - console.log(data); - var jsonBodyObj = data; - var jsonObj=jsonBodyObj.body; - console.log(jsonObj); - var responseMessages = jsonObj.text; - console.log("Responsemessage =" + responseMessages); - - //loop through array with outputs - for(var i = 0; i < responseMessages.length; i++) { - var toAdd = document.createDocumentFragment(); - var responseMessage = responseMessages[i]; - var newDiv = document.createElement('div'); - newDiv.id = 'r'+conversationIndex; - - conversationIndex++; - newDiv.className = 'direct-chat-msg'; - - var clearfixright = document.createElement('div'); - clearfixright.className = 'direct-chat-info clearfix'; - - var YourChatname = document.createElement('span'); - YourChatname.className = 'direct-chat-name pull-left'; - YourChatname.innerHTML= ""; - - var spanImgleft = document.createElement('span'); - spanImgleft.ClassName = 'spanImgleft'; - - var spanImgright = document.createElement('span'); - spanImgleft.ClassName = 'spanImgright'; - var Image = document.createElement('img'); - Image.ClassName = 'direct-chat-img'; - Image.style = 'float: left; height:40px;'; - var imgsrc = "img/w21-avatar.jpeg"; - Image.src = (imgsrc); - - var yourtext = document.createElement('div'); - yourtext.className='direct-chat-text'; - yourtext.innerHTML=responseMessage; - yourtext.style = 'font-size: 11px; font-family: sans-serif; color: #001a73; font-weight: bold; margin-left: 50px; text-align:left; min-height: 40px; border: 1px solid; border-color: #dadada; box-sizing: border-box; border-radius: 5px; box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,.1); padding:10px;'; - - toAdd.appendChild(newDiv); - newDiv.appendChild(clearfixright); - clearfixright.appendChild(YourChatname); - newDiv.appendChild(spanImgleft); - newDiv.appendChild(spanImgright); - spanImgleft.appendChild(Image); - spanImgright.appendChild(yourtext); - document.getElementById('input').value=""; - - watsonContext = jsonObj.context; - //console.log(watsonContext); - //updateWatsonContext(watsonContext); - - scrolldown(); - document.getElementById("conversation").appendChild(toAdd); - scrolldown(); - } - }, - fail: function (data) { - console.log(data) - //console.log("error, gefaald"); - } - }); -} - -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} - -function yesbye() { - document.getElementById('input').value="yes"; - loadJSON(); - scrolldown(); -} - -function nobye(){ - document.getElementById('input').value="no"; - loadJSON(); - scrolldown(); -} - -function scrolldown() { - var objDiv = document.getElementById("conversation"); - objDiv.scrollTop = objDiv.scrollHeight; -} - -function ask() { - if(event.keyCode == 13) { - loadJSON() - } -} - -function button(userinput, buttonContext) { - document.getElementById('input').value=userinput; - watsonContext.product=buttonContext; - loadJSON(); -} - -function openlink(url) { - var win = window.open(url,'_blank'); - win.focus(); -} - -function process(e) { - var code = (e.keyCode ? e.keyCode : e.which); - if (code == 13) { //Enter keycode - loadJSON(); - } -} \ No newline at end of file diff --git a/scripts/smalltalk.js b/scripts/smalltalk.js index 13bf128..abca4eb 100644 --- a/scripts/smalltalk.js +++ b/scripts/smalltalk.js @@ -42,12 +42,11 @@ function loadJSON() { console.log(watsonContext) if (watsonContext != "") { - updateWatsonContext(watsonContext); //Retrieve timestamps and returns them to Conversation Service within context variable + dialog.context=watsonContext; } - var url = "https://openwhisk.ng.bluemix.net/api/v1/web/e-office_development/default/talksmall.json"; //BELANGRIJK - //var url = "http://localhost:9080/api/chatbotpostnl"; //local + var url = document.getElementById("endpoint").value; $.ajax({ url: url, @@ -60,8 +59,13 @@ function loadJSON() { var jsonBodyObj = data; var jsonObj=jsonBodyObj.body; console.log(jsonObj); - var responseMessages = jsonObj.text; - console.log("Responsemessage =" + responseMessages); + var responseMessages + if (jsonObj==null) { + responseMessages = jsonBodyObj.text; + } else { + responseMessages = jsonObj.text; + } + console.log("Responsemessages =" + responseMessages); //loop through array with outputs for(var i = 0; i < responseMessages.length; i++) { @@ -88,7 +92,7 @@ function loadJSON() { var Image = document.createElement('img'); Image.ClassName = 'direct-chat-img'; Image.style = 'visible: hidden; display:none;'; - var imgsrc = 'img/wavy.png'; + var imgsrc = 'img/avatar1.png'; Image.src = (imgsrc); var yourtext = document.createElement('div'); @@ -121,162 +125,6 @@ function loadJSON() { }); } -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} function yesbye() { document.getElementById('input').value="yes"; diff --git a/scripts/smalltalkabnamro.js b/scripts/smalltalkabnamro.js deleted file mode 100644 index a840a1f..0000000 --- a/scripts/smalltalkabnamro.js +++ /dev/null @@ -1,324 +0,0 @@ -// Fill $chatbotName with CLients chatbot-name -var chatbotName = "jochem"; -// Fill $userName with 'active' user-name -var userName = "jij"; - -var conversationIndex = 1; -var watsonContext = ""; - -function loadJSON() { - //Question - var questionText = document.getElementById('input').value; - questionText.style = 'float: left; width:80%;'; - - var dialog = new Object(); - dialog.newQuestion = questionText; - - if (questionText != "") { - var qTOAdd = document.createDocumentFragment(); - var qNnewDiv = document.createElement('div'); - qNnewDiv.id = 'q'+conversationIndex; - qNnewDiv.className = 'direct-chat-msg right'; - // qNnewDiv.style = 'font-family: sans-serif; font-weight:bold; font-size:11px; margin-right:0px; text-align: justify; margin-right: 0px; float:right; overflow: auto; background-color: #ed8c00; border-radius: 3px; margin: 10px; padding: 5px; text-align: left; color: #fff; margin-right:0px;'; - - var clearfixDiv = document.createElement('div') - clearfixDiv.className = 'direct-chat-info clearfix'; - - var chatnameleft = document.createElement('h3') - chatnameleft.className = 'direct-chat-name pull-left'; - chatnameleft.innerHTML= userName; //$Username - chatnameleft.style = ""; - - var qtext = document.createElement('span'); - qtext.className = 'direct-chat-text'; - qtext.innerHTML=questionText; - qTOAdd.appendChild(qNnewDiv); - qNnewDiv.appendChild(clearfixDiv); - clearfixDiv.appendChild(chatnameleft); - qNnewDiv.appendChild(qtext); - document.getElementById("conversation").appendChild(qTOAdd); - scrolldown(); - } - - console.log(watsonContext) - if (watsonContext != "") { - updateWatsonContext(watsonContext); //Retrieve timestamps and returns them to Conversation Service within context variable - dialog.context=watsonContext; - } - - var url = "https://openwhisk.eu-gb.bluemix.net/api/v1/web/e-office_Baas%20Production/baas/abnamrotrial.json"; //BELANGRIJK - - $.ajax({ - url: url, - type: 'post', - dataType: 'json', - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(dialog), - success: function (data) { - console.log(data); - var jsonBodyObj = data; - var jsonObj=jsonBodyObj.body; - console.log(jsonObj); - var responseMessages = jsonObj.text; - console.log("Responsemessage =" + responseMessages); - - //loop through array with outputs - for(var i = 0; i < responseMessages.length; i++) { - var toAdd = document.createDocumentFragment(); - var responseMessage = responseMessages[i]; - var newDiv = document.createElement('div'); - newDiv.id = 'r'+conversationIndex; - - conversationIndex++; - newDiv.className = 'direct-chat-msg'; - - var clearfixright = document.createElement('div'); - clearfixright.className = 'direct-chat-info clearfix'; - - var YourChatname = document.createElement('h3'); - YourChatname.className = 'direct-chat-name pull-left'; - YourChatname.innerHTML= chatbotName; //$Botname - - var spanImgleft = document.createElement('span'); - spanImgleft.ClassName = 'spanImgleft'; - - var spanImgright = document.createElement('span'); - spanImgleft.ClassName = 'spanImgright'; - var Image = document.createElement('img'); - Image.ClassName = 'direct-chat-img'; - Image.style = 'visible: hidden; display:none;'; - var imgsrc = 'img/avatar1.png'; - Image.src = (imgsrc); - - var yourtext = document.createElement('div'); - yourtext.className='direct-chat-text'; - yourtext.innerHTML=responseMessage; - // yourtext.style = 'font-size: 11px; font-family: sans-serif; color: #001a73; font-weight: bold; margin-left: 50px; text-align:left; min-height: 40px; border: 1px solid; border-color: #dadada; box-sizing: border-box; border-radius: 5px; box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,.1); padding:10px;'; - - toAdd.appendChild(newDiv); - newDiv.appendChild(clearfixright); - clearfixright.appendChild(YourChatname); - newDiv.appendChild(spanImgleft); - newDiv.appendChild(spanImgright); - spanImgleft.appendChild(Image); - spanImgright.appendChild(yourtext); - document.getElementById('input').value=""; - - watsonContext = jsonObj.context; - //console.log(watsonContext); - //updateWatsonContext(watsonContext); - - // scrolldown(); - document.getElementById("conversation").appendChild(toAdd); - } - scrolldown(); - }, - fail: function (data) { - console.log(data) - //console.log("error, gefaald"); - } - }); -} - -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} - -function yesbye() { - document.getElementById('input').value="yes"; - loadJSON(); - scrolldown(); -} - -function nobye(){ - document.getElementById('input').value="no"; - loadJSON(); - scrolldown(); -} - -function scrolldown() { - // setTimeout(function() { - var conversation = $("#conversation"); - var conversationHeight = $(conversation).height(); - $("main").animate({ scrollTop: $(conversation).height() }, 300); //adjust animation time here '300ms' - console.log("Scrolled down") - // }, 300); - // set delay here '300ms' -} - -function ask() { - if(event.keyCode == 13) { - loadJSON() - } -} - -function button(userinput, buttonContext) { - document.getElementById('input').value=userinput; - watsonContext.product=buttonContext; - loadJSON(); -} - -function openlink(url) { - var win = window.open(url,'_blank'); - win.focus(); -} - -function process(e) { - var code = (e.keyCode ? e.keyCode : e.which); - if (code == 13) { //Enter keycode - loadJSON(); - } -} diff --git a/scripts/smalltalkcors.js b/scripts/smalltalkcors.js index 62cf4ff..1026e6c 100644 --- a/scripts/smalltalkcors.js +++ b/scripts/smalltalkcors.js @@ -46,8 +46,7 @@ function loadJSON() { dialog.context=watsonContext; } - //var url = "https://openwhisk.ng.bluemix.net/api/v1/web/e-office_development/baasgenerator/corsmiddleman.json"; - var url = "https://openwhisk.eu-gb.bluemix.net/api/v1/web/MJonker_uk-dev/baas/corsmiddleman.http"; + var url = document.getElementById("endpoint").value; $.ajax({ url: url, @@ -110,9 +109,13 @@ function loadJSON() { spanImgright.appendChild(yourtext); document.getElementById('input').value=""; - //watsonContext = jsonObj.context; - //console.log(watsonContext); - //updateWatsonContext(watsonContext); + if (jsonObj==null) { + watsonContext = jsonBodyObj.context; + } else { + watsonContext = jsonObj.context; + } + + // scrolldown(); document.getElementById("conversation").appendChild(toAdd); @@ -126,162 +129,6 @@ function loadJSON() { }); } -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} function yesbye() { document.getElementById('input').value="yes"; diff --git a/scripts/smalltalkkrampgroep.js b/scripts/smalltalkkrampgroep.js deleted file mode 100644 index ebd7a68..0000000 --- a/scripts/smalltalkkrampgroep.js +++ /dev/null @@ -1,325 +0,0 @@ -// Fill $chatbotName with CLients chatbot-name -var chatbotName = "jochem"; -// Fill $userName with 'active' user-name -var userName = "jij"; - -var conversationIndex = 1; -var watsonContext = ""; - -function loadJSON() { - //Question - var questionText = document.getElementById('input').value; - questionText.style = 'float: left; width:80%;'; - - var dialog = new Object(); - dialog.newQuestion = questionText; - - if (questionText != "") { - var qTOAdd = document.createDocumentFragment(); - var qNnewDiv = document.createElement('div'); - qNnewDiv.id = 'q'+conversationIndex; - qNnewDiv.className = 'direct-chat-msg right'; - // qNnewDiv.style = 'font-family: sans-serif; font-weight:bold; font-size:11px; margin-right:0px; text-align: justify; margin-right: 0px; float:right; overflow: auto; background-color: #ed8c00; border-radius: 3px; margin: 10px; padding: 5px; text-align: left; color: #fff; margin-right:0px;'; - - var clearfixDiv = document.createElement('div') - clearfixDiv.className = 'direct-chat-info clearfix'; - - var chatnameleft = document.createElement('h3') - chatnameleft.className = 'direct-chat-name pull-left'; - chatnameleft.innerHTML= userName; //$Username - chatnameleft.style = ""; - - var qtext = document.createElement('span'); - qtext.className = 'direct-chat-text'; - qtext.innerHTML=questionText; - qTOAdd.appendChild(qNnewDiv); - qNnewDiv.appendChild(clearfixDiv); - clearfixDiv.appendChild(chatnameleft); - qNnewDiv.appendChild(qtext); - document.getElementById("conversation").appendChild(qTOAdd); - scrolldown(); - } - - console.log(watsonContext) - if (watsonContext != "") { - updateWatsonContext(watsonContext); //Retrieve timestamps and returns them to Conversation Service within context variable - dialog.context=watsonContext; - } - - var url = "https://openwhisk.eu-gb.bluemix.net/api/v1/web/e-office_Baas%20Production/baas/krampgroeptrial.json"; //BELANGRIJK - - - $.ajax({ - url: url, - type: 'post', - dataType: 'json', - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(dialog), - success: function (data) { - console.log(data); - var jsonBodyObj = data; - var jsonObj=jsonBodyObj.body; - console.log(jsonObj); - var responseMessages = jsonObj.text; - console.log("Responsemessage =" + responseMessages); - - //loop through array with outputs - for(var i = 0; i < responseMessages.length; i++) { - var toAdd = document.createDocumentFragment(); - var responseMessage = responseMessages[i]; - var newDiv = document.createElement('div'); - newDiv.id = 'r'+conversationIndex; - - conversationIndex++; - newDiv.className = 'direct-chat-msg'; - - var clearfixright = document.createElement('div'); - clearfixright.className = 'direct-chat-info clearfix'; - - var YourChatname = document.createElement('h3'); - YourChatname.className = 'direct-chat-name pull-left'; - YourChatname.innerHTML= chatbotName; //$Botname - - var spanImgleft = document.createElement('span'); - spanImgleft.ClassName = 'spanImgleft'; - - var spanImgright = document.createElement('span'); - spanImgleft.ClassName = 'spanImgright'; - var Image = document.createElement('img'); - Image.ClassName = 'direct-chat-img'; - Image.style = 'visible: hidden; display:none;'; - var imgsrc = 'img/avatar1.png'; - Image.src = (imgsrc); - - var yourtext = document.createElement('div'); - yourtext.className='direct-chat-text'; - yourtext.innerHTML=responseMessage; - // yourtext.style = 'font-size: 11px; font-family: sans-serif; color: #001a73; font-weight: bold; margin-left: 50px; text-align:left; min-height: 40px; border: 1px solid; border-color: #dadada; box-sizing: border-box; border-radius: 5px; box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,.1); padding:10px;'; - - toAdd.appendChild(newDiv); - newDiv.appendChild(clearfixright); - clearfixright.appendChild(YourChatname); - newDiv.appendChild(spanImgleft); - newDiv.appendChild(spanImgright); - spanImgleft.appendChild(Image); - spanImgright.appendChild(yourtext); - document.getElementById('input').value=""; - - watsonContext = jsonObj.context; - //console.log(watsonContext); - //updateWatsonContext(watsonContext); - - // scrolldown(); - document.getElementById("conversation").appendChild(toAdd); - } - scrolldown(); - }, - fail: function (data) { - console.log(data) - //console.log("error, gefaald"); - } - }); -} - -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} - -function yesbye() { - document.getElementById('input').value="yes"; - loadJSON(); - scrolldown(); -} - -function nobye(){ - document.getElementById('input').value="no"; - loadJSON(); - scrolldown(); -} - -function scrolldown() { - // setTimeout(function() { - var conversation = $("#conversation"); - var conversationHeight = $(conversation).height(); - $("main").animate({ scrollTop: $(conversation).height() }, 300); //adjust animation time here '300ms' - console.log("Scrolled down") - // }, 300); - // set delay here '300ms' -} - -function ask() { - if(event.keyCode == 13) { - loadJSON() - } -} - -function button(userinput, buttonContext) { - document.getElementById('input').value=userinput; - watsonContext.product=buttonContext; - loadJSON(); -} - -function openlink(url) { - var win = window.open(url,'_blank'); - win.focus(); -} - -function process(e) { - var code = (e.keyCode ? e.keyCode : e.which); - if (code == 13) { //Enter keycode - loadJSON(); - } -} diff --git a/scripts/truqu.js b/scripts/truqu.js deleted file mode 100644 index 57784a7..0000000 --- a/scripts/truqu.js +++ /dev/null @@ -1,314 +0,0 @@ -var conversationIndex = 1; -var watsonContext = ""; - -function loadJSON() { - //Question - var questionText = document.getElementById('input').value; - questionText.style = 'float: left; width:80%;'; - - var dialog = new Object(); - dialog.newQuestion = questionText; - - if (questionText != "") { - var qTOAdd = document.createDocumentFragment(); - var qNnewDiv = document.createElement('div'); - qNnewDiv.id = 'q'+conversationIndex; - qNnewDiv.className = 'direct-chat-msg right'; - qNnewDiv.style = 'font-family: sans-serif; font-weight:bold; font-size:11px; margin-right:0px; text-align: justify; margin-right: 0px; float:right; overflow: auto; background-color: #ed8c00; border-radius: 3px; margin: 10px; padding: 5px; text-align: left; color: #fff; margin-right:0px;'; - - var clearfixDiv = document.createElement('div') - clearfixDiv.className = 'direct-chat-info clearfix'; - - var chatnameleft = document.createElement('span') - chatnameleft.className = 'direct-chat-name pull-left'; - chatnameleft.innerHTML= ""; - chatnameleft.style = 'display: none;'; - - var qtext = document.createElement('span'); - qtext.className = 'direct-chat-text'; - qtext.innerHTML=questionText; - qTOAdd.appendChild(qNnewDiv); - qNnewDiv.appendChild(clearfixDiv); - clearfixDiv.appendChild(chatnameleft); - qNnewDiv.appendChild(qtext); - document.getElementById("conversation").appendChild(qTOAdd); - scrolldown(); - } - - console.log(watsonContext) - if (watsonContext != "") { - updateWatsonContext(watsonContext); //Retrieve timestamps and returns them to Conversation Service within context variable - dialog.context=watsonContext; - } - - var url = "https://openwhisk.eu-gb.bluemix.net/api/v1/web/e-office_Baas%20Production/baas/trialtruqu.json"; - - $.ajax({ - url: url, - type: 'post', - dataType: 'json', - contentType: 'application/json; charset=utf-8', - data: JSON.stringify(dialog), - success: function (data) { - console.log(data); - var jsonBodyObj = data; - var jsonObj=jsonBodyObj.body; - console.log(jsonObj); - var responseMessages = jsonObj.text; - console.log("Responsemessage =" + responseMessages); - - //loop through array with outputs - for(var i = 0; i < responseMessages.length; i++) { - var toAdd = document.createDocumentFragment(); - var responseMessage = responseMessages[i]; - var newDiv = document.createElement('div'); - newDiv.id = 'r'+conversationIndex; - - conversationIndex++; - newDiv.className = 'direct-chat-msg'; - - var clearfixright = document.createElement('div'); - clearfixright.className = 'direct-chat-info clearfix'; - - var YourChatname = document.createElement('span'); - YourChatname.className = 'direct-chat-name pull-left'; - YourChatname.innerHTML= ""; - - var spanImgleft = document.createElement('span'); - spanImgleft.ClassName = 'spanImgleft'; - - var spanImgright = document.createElement('span'); - spanImgleft.ClassName = 'spanImgright'; - var Image = document.createElement('img'); - Image.ClassName = 'direct-chat-img'; - Image.style = 'float: left; height:40px;'; - var imgsrc = "img/avatar.png"; - Image.src = (imgsrc); - - var yourtext = document.createElement('div'); - yourtext.className='direct-chat-text'; - yourtext.innerHTML=responseMessage; - yourtext.style = 'font-size: 11px; font-family: sans-serif; color: #001a73; font-weight: bold; margin-left: 50px; text-align:left; min-height: 40px; border: 1px solid; border-color: #dadada; box-sizing: border-box; border-radius: 5px; box-shadow: inset 1px 1px 2px 0 rgba(0,0,0,.1); padding:10px;'; - - toAdd.appendChild(newDiv); - newDiv.appendChild(clearfixright); - clearfixright.appendChild(YourChatname); - newDiv.appendChild(spanImgleft); - newDiv.appendChild(spanImgright); - spanImgleft.appendChild(Image); - spanImgright.appendChild(yourtext); - document.getElementById('input').value=""; - - watsonContext = jsonObj.context; - //console.log(watsonContext); - //updateWatsonContext(watsonContext); - - scrolldown(); - document.getElementById("conversation").appendChild(toAdd); - scrolldown(); - } - }, - fail: function (data) { - console.log(data) - //console.log("error, gefaald"); - } - }); -} - -function updateWatsonContext(watsonContext) { - console.log(watsonContext) - var username = retrieveUsername(watsonContext); - watsonContext['username'] = username; - - //if(watsonContext.hasOwnProperty('time') && watsonContext.hasOwnProperty('officialtime') && watsonContext.hasOwnProperty('date')) { - var timestamps = retrieveTimeStamp(); - //[time, officialtime, date, timeindication] = retrieveTimeStamp(); - watsonContext['time'] = timestamps[0]; - watsonContext['officialtime'] = timestamps[1]; - watsonContext['date'] = timestamps[2]; - watsonContext['timeindication'] = timestamps[3]; - //} - return watsonContext; -} - -function retrieveUsername(watsonContext) { - var username = ''; - return username; -} - -function retrieveTimeStamp() { - //Day - var day = new Date().getDay(); - switch (day) { - case 0: - day = "zondag"; - break; - case 1: - day = "maandag"; - break; - case 2: - day = "dinsdag"; - break; - case 3: - day = "woensdag"; - break; - case 4: - day = "donderdag"; - break; - case 5: - day = "vrijdag"; - break; - case 6: - day = "zaterdag"; - break; - } - - //Date - var date = day + " " + new Date().getDate() + "-" + (new Date().getMonth() + 1) + "-" + new Date().getFullYear(); - - //Official time - var hours = new Date().getHours(); - var minutes = new Date().getMinutes(); - var officialtime = ""; - - if (hours < 10 && minutes < 10) { - officialtime = "0" + hours + ":0" + minutes; - } - else if (hours < 10 && minutes >= 10) { - officialtime = "0" + hours + ":" + minutes; - } - else if (minutes < 10) { - officialtime = hours + ":" + "0" + minutes; - } - else { - officialtime = hours + ":" + minutes; - } - - //Time indication - var timeindication; - - if (hours >= 0 && hours < 6) { - timeindication = "goede nacht"; - } - else if (hours >= 6 && hours < 12) { - timeindication = "goede morgen"; - } - else if (hours >= 12 && hours < 18) { - timeindication = "goede middag"; - } - else { - timeindication = "goede avond"; - } - - //Spoken numbers - if (hours > 12) { - hours = hours - 12; - } - var currenttime = ""; - while (currenttime == "") { - if (minutes == 0) { - currenttime += (toSpeech(hours)); - currenttime += (" uur"); - } - else if (minutes < 15) { - currenttime += (toSpeech(minutes)); - currenttime += (" over "); - currenttime += (toSpeech(hours)); - } - else if (minutes == 15) { - minutes = "kwart over "; - currenttime += toSpeech(hours); - } - else if (minutes < 30) { - currenttime += (toSpeech(30 - minutes)); - currenttime += (" voor half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 30) { - currenttime += ("half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes < 45) { - currenttime += (toSpeech(minutes - 30)); - currenttime += (" over half "); - currenttime = updateCurrentTime(hours, currenttime); - } - else if (minutes == 45) { - currenttime += ("kwart voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - else { - currenttime += (toSpeech(60 - minutes)); - currenttime += (" voor "); - currenttime = updateCurrentTime(hours, currenttime); - } - } - var timearray = [currenttime, officialtime, date, timeindication]; - return timearray; -} - -//Reoccuring pattern functionalized -function updateCurrentTime(hours, currenttime) { - if (hours != 12) { - currenttime += (toSpeech(hours + 1)); - } - else { - currenttime += (toSpeech(1)); - } - return currenttime; -} - -//Spoken time -function toSpeech(number) { - var toSpeech = {1: "één", 2: "twee", 3: "drie", 4: "vier", 5: "vijf", 6: "zes", 7: "zeven", 8: "acht", 9: "negen", 10: "tien", - 11: "elf", 12: "twaalf", 13: "dertien", 14: "veertien"}; - /* - 15: "vijftien", 16: "zestien", 17: "zeventien", 18: "achttien", 19: "negetien", 20: "twintig", - 21: "éénentwintig", 22: "tweeëntwintig", 23: "drieëntwintig", 24: "vierentwintig", 25: "vijfentwintig", 26: "zesentwintig", 27: "zevenentwintig", 28: "achtentwintig", 29: "negenentwintig", 30: "dertig", - 31: "éénendertig", 32: "tweeënertig", 33: "drieëndertig", 34: "vierendertig", 35: "vijfendertig", 36: "zesendertig", 37: "zevenendertig", 38: "achtendertig", 39: "negenendertig", 40: "veertig", - 41: "éénenveertig", 42: "tweeënveertig", 43: "drieënveertig", 44: "vierenveertig", 45: "vijfenveertig", 46: "zesenveertig", 47: "zevenenveertig", 48: "achtenveertig", 49: "negenenveertig", 50: "vijftig", - 51: "éénenvijftig", 52: "tweeënvijftig", 53: "drieënvijftig", 54: "vierenvijftig", 55: "vijfenvijftig", 56: "zesenvijftig", 57: "zevenenvijftig", 58: "achtenvijftig", 59: "negenenvijftig", 60: "zestig", - */ - return toSpeech[number]; -} - -function yesbye() { - document.getElementById('input').value="yes"; - loadJSON(); - scrolldown(); -} - -function nobye(){ - document.getElementById('input').value="no"; - loadJSON(); - scrolldown(); -} - -function scrolldown() { - var objDiv = document.getElementById("conversation"); - objDiv.scrollTop = objDiv.scrollHeight; -} - -function ask() { - if(event.keyCode == 13) { - loadJSON() - } -} - -function button(userinput, buttonContext) { - document.getElementById('input').value=userinput; - watsonContext.product=buttonContext; - loadJSON(); -} - -function openlink(url) { - var win = window.open(url,'_blank'); - win.focus(); -} - -function process(e) { - var code = (e.keyCode ? e.keyCode : e.which); - if (code == 13) { //Enter keycode - loadJSON(); - } -} \ No newline at end of file diff --git a/truqu.html b/truqu.html index 79e722b..7864df6 100644 --- a/truqu.html +++ b/truqu.html @@ -1,20 +1,46 @@ - - - - + - Nederlandstalige Feedback Bot + + + + + + Nederlandstalige Chat + -

Feedbackbot minimalistisch

-
-
-
- - +
+
+ +
+ + Baas's avatar +
+

BaaS

+ Beschikbaar +
+
+
+
+
+ +
+
+
+
+ + +
+
+ +
+ OVER BAAS +

+ Logo +