search is almost finished
diff --git a/dtps.css b/dtps.css
index 33ffc62..9190b96 100644
--- a/dtps.css
+++ b/dtps.css
@@ -1625,6 +1625,10 @@
padding: 15px 18px;
position: relative;
border-radius: var(--cardRadius);
+ border: 2px solid transparent;
+ cursor: pointer;
+ transition: border 0.2s, background-color 0.2s;
+ user-select: none;
}
.card.searchResult h4 {
@@ -1674,4 +1678,9 @@
.searchResult.mixedClasses {
padding-left: 34px;
+}
+
+.searchResult:hover {
+ background-color: var(--elements);
+ border-color: var(--highlight);
}
\ No newline at end of file
diff --git a/scripts/assignments.js b/scripts/assignments.js
index 5d97f3c..d5461bd 100644
--- a/scripts/assignments.js
+++ b/scripts/assignments.js
@@ -1197,6 +1197,7 @@
* @property {string} title Title of the announcement
* @property {Date} postedAt Date when the announcement was posted
* @property {string} body Announcement content
+* @property {string} url Announcement URL
*/
/**
diff --git a/scripts/lms/canvas.js b/scripts/lms/canvas.js
index 538c0b4..1771b88 100644
--- a/scripts/lms/canvas.js
+++ b/scripts/lms/canvas.js
@@ -280,6 +280,7 @@
title: item.title,
id: item.content_id,
indent: item.indent,
+ url: item.html_url,
completed: item.completion_requirement && item.completion_requirement.completed
})
} else if (item.type.toUpperCase() == "PAGE") {
@@ -361,7 +362,8 @@
return {
title: announcement.title,
postedAt: announcement.created_at,
- body: announcement.message
+ body: announcement.message,
+ url: announcement.html_url
}
});
diff --git a/scripts/pages-discussions.js b/scripts/pages-discussions.js
index b31a405..3a72571 100644
--- a/scripts/pages-discussions.js
+++ b/scripts/pages-discussions.js
@@ -12,9 +12,10 @@
*
* @param {string} courseID The course ID to render discussion threads for
* @param {string} [defaultThread] The thread to load by default
- * @param {boolean} fromModules True if this page is being loaded from the moduleStream
+ * @param {boolean} [fromModules] True if this page is being loaded from the moduleStream
+ * @param {string} [defaultPost] The post to load by default
*/
-dtps.loadThreadsList = function (courseID, defaultThread, fromModules) {
+dtps.loadThreadsList = function (courseID, defaultThread, fromModules, defaultPost) {
//Get class index and set as selected class
var classNum = dtps.classes.map(course => course.id).indexOf(courseID);
dtps.selectedClass = classNum;
@@ -37,7 +38,7 @@
//Load module thread
if (fromModules) {
- dtps.loadThreadPosts(classNum, defaultThread, fromModules);
+ dtps.loadThreadPosts(classNum, defaultThread, fromModules, defaultPost);
return;
}
@@ -124,7 +125,7 @@
//Load default thread if provided
if (defaultThread) {
- dtps.loadThreadPosts(classNum, defaultThread);
+ dtps.loadThreadPosts(classNum, defaultThread, fromModules, defaultPost);
}
//Add click event listeners for discussion threads
@@ -152,9 +153,10 @@
*
* @param {number} classNum The class number to render
* @param {string} threadID The discussion thread to render
- * @param {boolean} fromModules True if this page is being loaded from the moduleStream
+ * @param {boolean} [fromModules] True if this page is being loaded from the moduleStream
+ * @param {string} [defaultPost] The post ID to jump to
*/
-dtps.loadThreadPosts = function (classNum, threadID, fromModules) {
+dtps.loadThreadPosts = function (classNum, threadID, fromModules, defaultPost) {
//Show loading indicator
if ((dtps.selectedClass == classNum) && ((dtps.selectedContent == "discuss") || fromModules)) {
jQuery(".classContent").html(/*html*/`
@@ -205,7 +207,7 @@
//Get HTML for each reply and add to array
post.replies.forEach(reply => {
replyHTML.push(/*html*/`
- <div style="margin-left: ${(reply.depth || 0) * 50}px;" class="discussionReply">
+ <div data-post-id="${reply.id}" style="margin-left: ${(reply.depth || 0) * 50}px;" class="discussionReply">
<div class="discussionHeader">
${post.author ? /*html*/`
<img src="${reply.author.photoURL}" />
@@ -230,7 +232,7 @@
//Create HTML for this post
//Note that index == 0 is the initial post
postHTML.push(/*html*/`
- <div class="card" style="margin-top: 20px;${index == 0 ? "margin-bottom: 75px;" : "padding: 20px 30px;"}">
+ <div class="card" data-post-id="${post.id}" style="margin-top: 20px;${index == 0 ? "margin-bottom: 75px;" : "padding: 20px 30px;"}">
<!-- Thread title (Initial post) -->
${index == 0 ? /*html*/`
<h4 style="font-weight: bold">${thread.title}</h4>
@@ -283,6 +285,11 @@
<i class="material-icons">keyboard_arrow_left</i> Back
</button>
` : "") + postHTML.join(""));
+
+ //Jump to post if specified
+ if (defaultPost) {
+ $("[data-post-id=" + defaultPost + "]").get(0).scrollIntoView();
+ }
}
}).catch(function (err) {
dtps.error("Could not fetch discussion posts", "Caught promise rejection @ dtps.loadThreadPosts", err);
@@ -505,8 +512,9 @@
var courseID = param.split("|")[0];
var threadID = param.split("|")[1];
var fromModules = param.split("|")[2] == "true";
+ var postID = param.split("|")[3];
- dtps.loadThreadsList(courseID, threadID, fromModules);
+ dtps.loadThreadsList(courseID, threadID, fromModules, postID);
}
fluid.externalScreens.pages = (param) => {
diff --git a/scripts/search.js b/scripts/search.js
index 15fc871..5e871ed 100644
--- a/scripts/search.js
+++ b/scripts/search.js
@@ -57,7 +57,7 @@
title: assignment.title,
class: course.num,
body: $('<div>' + assignment.body + '</div>').text(),
- url: assignment.url,
+ onclick: "dtps.assignment('" + assignment.id + "', " + assignment.class + ")",
locatedIn: assignment.category ? assignment.category : "Assignment",
icon: "assignment",
infoIcons: [
@@ -140,6 +140,7 @@
resolve([{
title: course.subject + " Homepage",
class: course.num,
+ onclick: "dtps.classHome(" + course.num + ");",
locatedIn: course.subject,
icon: "home",
body: $('<div>' + data + '</div>').text(),
@@ -159,6 +160,7 @@
resolve(pages.map(page => ({
title: page.title,
class: course.num,
+ onclick: "fluid.screen('pages', '" + course.id + "|" + page.id + "');",
body: $('<div>' + page.content + '</div>').text(),
locatedIn: "Page",
icon: "insert_drive_file",
@@ -186,11 +188,13 @@
discussions.forEach(discussion => {
discussion.posts.forEach(post => {
post.locatedIn = discussion.title;
+ post.threadID = discussion.id;
res.push(post);
if (post.replies) {
post.replies.forEach(reply => {
reply.locatedIn = discussion.title;
+ reply.threadID = discussion.id;
res.push(reply);
});
}
@@ -199,7 +203,7 @@
resolve(res.map(post => ({
body: $('<div>' + post.body + '</div>').text(),
class: course.num,
- url: post.replyURL,
+ onclick: "fluid.screen('discussions', '" + course.id + "|" + post.threadID + "|false|" + post.id + "');",
locatedIn: post.locatedIn,
icon: "forum",
infoIcons: [
@@ -258,7 +262,7 @@
res.push({
title: assignment.title,
class: course.num,
- url: assignment.url,
+ onclick: "dtps.assignment('" + assignment.id + "', " + assignment.class + ")",
locatedIn: rubric.title,
icon: "assessment",
infoIcons: [
@@ -275,7 +279,7 @@
res.push({
title: assignment.title,
class: course.num,
- url: assignment.url,
+ onclick: "dtps.assignment('" + assignment.id + "', " + assignment.class + ")",
locatedIn: "Grade",
icon: "assessment",
infoIcons: [
@@ -298,6 +302,7 @@
dtpsLMS.fetchAnnouncements(course.lmsID).then(announcements => {
resolve(announcements.map((announcement) => ({
title: announcement.title,
+ url: announcement.url,
class: course.num,
locatedIn: course.subject,
icon: "announcement",
@@ -432,6 +437,7 @@
<div
class="card searchResult ${mixedClasses ? "mixedClasses" : ""}"
style="${'--classColor: ' + dtps.classes[result.class].color}"
+ onclick="${result.onclick || (result.url && "window.open('" + result.url + "')")}"
>
<!-- Color bar for the dashboard -->