Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ function renderMatches(matches) {
list.innerHTML = '';

// For every match found, render the objects to the DOM in JSON format
matches.forEach(match => {
const li = document.createElement('li');
if(matches.length > 0) {
matches.forEach(match => {
const li = document.createElement('li');

// Create an element that looks like a JSON object for every match
li.innerHTML = `
<pre class="json"><code>{<div class="indent"><br>name: '${match.name}',<br>url: <a href="${match.url}" target="_blank">'${match.url}',</a><br class="middle-br">keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]<br></div>},</code></pre>
`;
// Create an element that looks like a JSON object for every match
li.innerHTML = `
<pre class="json"><code>{<div class="indent"><br>name: '${match.name}',<br>url: <a href="${match.url}" target="_blank">'${match.url}',</a><br class="middle-br">keywords: [${match.keywords.map(keyword => `'${keyword}'`).join(", ")}]<br></div>},</code></pre>
`;

list.appendChild(li);
});
} else {
const li = document.createElement('li');
li.innerText = 'No matches were found.';
list.appendChild(li);
});
}
}
2 changes: 0 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ const express = require('express');
const app = express();
const cors = require('cors');
const { resources } = require("./resources");
const { response } = require('express');
const e = require('express');
const PORT = process.env.PORT || 8000;

app.set('view engine', 'ejs')
Expand Down