29 |
30 |
31 |
32 | Red link represents bus travel time :
33 | Green link represents flight travel time :
34 | Click on solve to get Solution !!
35 |
36 |
37 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/ChatList-master/ChatHandler.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by aarnavjindal on 07/04/20.
3 | */
4 |
5 | export { ChatHandler, chat_names}
6 |
7 | const chat_names = ["Prateek Bhaiya", "Arnav Bhaiya", "Munna Bhaiya", "Aarnav Jindal", "Shriya Chhabra", "Akul Jindal", "Abhinav Duggal"];
8 | const chat_names_length = chat_names.length;
9 | const chat_msg = ["Why didn't he come and talk to me himse...",
10 | "Perfect, I am really glad to hear that!...",
11 | "This is what I understand you're telling me..",
12 | "I’m sorry, I don’t have the info on that.."];
13 | const chat_msg_length = chat_msg.length;
14 | const chat_img_length = 7;
15 |
16 | class ChatHandler{
17 |
18 | constructor(chat_template, chat_list){
19 | this.hashmap = new Map();
20 | this.linked_list = null;
21 | this.chat_template = chat_template;
22 | this.chat_list = chat_list;
23 | let clock = new Date();
24 | this.hours = clock.getHours();
25 | this.mins = clock.getMinutes();
26 | }
27 |
28 | getTime(){
29 | // Time Stamp creation for messages
30 | this.mins += 1;
31 | if(this.mins === 60){
32 | this.hours += 1;
33 | this.mins = 0;
34 | }
35 |
36 | if(this.hours === 24){
37 | this.hours = 0;
38 | }
39 |
40 | return ("0" + this.hours).slice(-2)+":"+("0" + this.mins).slice(-2);
41 | }
42 |
43 | createNode(id){
44 | // Creating node element
45 | let node = {};
46 | // Pointers to prev and next
47 | node['next'] = null;
48 | node['prev'] = null;
49 | // Create a copy of chat template
50 | let chat_item = this.chat_template.cloneNode(true);
51 | // Setting name, message, image to template item
52 | chat_item.querySelector('#Name').innerText = chat_names[id%chat_names_length];
53 | chat_item.querySelector('#Message').innerText = chat_msg[id%chat_msg_length];
54 | console.log("./images/avatar" + eval(1+(id%chat_img_length)) + ".png");
55 | chat_item.querySelector('#Image').src = "./images/avatar" + eval(1+(id%chat_img_length)) + ".png";
56 | node['chat_item'] = chat_item;
57 | return node;
58 | }
59 |
60 | newMsg(id){
61 | let node = null;
62 | if((id in this.hashmap ) === false){
63 | // If node not in linked list
64 | node = this.createNode(id);
65 | this.hashmap[id] = node;
66 | } else{
67 | // If node in linked list
68 | node = this.getNodeFromList(id);
69 | }
70 |
71 | if(this.linked_list === null){
72 | // Setting head of empty list
73 | this.linked_list = node;
74 | } else{
75 | // Adding node to head of linked list
76 | node['next'] = this.linked_list;
77 | if(this.linked_list!==null)
78 | this.linked_list['prev'] = node;
79 | this.linked_list = node;
80 | }
81 | this.updateList();
82 | }
83 |
84 | deleteMsg(id){
85 | let node = this.getNodeFromList(id);
86 | // No use of node since it has been deleted
87 | delete this.hashmap[id];
88 | // Clear entry from hashmap
89 | this.updateList();
90 | }
91 |
92 | getNodeFromList(id){
93 | let node = this.hashmap[id];
94 | let prevNode = node['prev'];
95 | let nextNode = node['next'];
96 |
97 | // Update prev and next node pointers
98 | if(prevNode!==null)
99 | prevNode['next'] = nextNode;
100 | if(nextNode!==null)
101 | nextNode['prev'] = prevNode;
102 |
103 | // Update head of the linked list
104 | if(node===this.linked_list){
105 | this.linked_list = nextNode;
106 | }
107 | node['next'] = null;
108 | node['prev'] = null;
109 | return node;
110 | }
111 |
112 | updateList(){
113 | // Update the contents of the chat list
114 | let innerHTML = '';
115 | let head = this.linked_list;
116 | while(head!==null){
117 | let element = head['chat_item'];
118 | if(head===this.linked_list){
119 | element.className = "ks-item ks-active";
120 | element.querySelector('#Time').innerText = this.getTime();
121 | } else{
122 | element.className = "ks-item";
123 | }
124 | innerHTML += element.outerHTML;
125 | head = head['next'];
126 | }
127 | this.chat_list.innerHTML = innerHTML;
128 | }
129 |
130 | }
--------------------------------------------------------------------------------
/chatbot-api/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
10 |
11 |
12 |
13 |
14 |
18 |
19 |
20 |
21 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
Chat with CB Bot
38 |
Code your way to Success
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
73 |
74 |
85 |
86 |
87 |
88 |
89 | Hey there friends !
90 | This is a simple yet amazing chatbot tutorial
91 | You'll learn about JSON, Javascript promises and APIs
92 | After this tutorial you can even feed your own data to the bot and have fun with it !
93 | So let's begin interacting with the CB Bot.
94 | Send a simple hello message to begin
95 |
96 |