| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <title>JSDoc: Source: pages-discussions.js</title> |
| 6 | |
| 7 | <script src="scripts/prettify/prettify.js"> </script> |
| 8 | <script src="scripts/prettify/lang-css.js"> </script> |
| 9 | <!--[if lt IE 9]> |
| 10 | <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> |
| 11 | <![endif]--> |
| 12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> |
| 13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> |
| 14 | </head> |
| 15 | |
| 16 | <body> |
| 17 | |
| 18 | <div id="main"> |
| 19 | |
| 20 | <h1 class="page-title">Source: pages-discussions.js</h1> |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | <section> |
| 28 | <article> |
| 29 | <pre class="prettyprint source linenums"><code>/** |
| 30 | * @file DTPS pages & discussion functions |
| 31 | * @author jottocraft |
| 32 | * |
| 33 | * @copyright Copyright (c) 2018-2020 jottocraft. All rights reserved. |
| 34 | * @license GPL-2.0-only |
| 35 | */ |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * Renders the discussions list for a class |
| 40 | * |
| 41 | * @param {string} courseID The course ID to render discussion threads for |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 42 | * @param {string} [defaultThread] The thread to load by default |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 43 | */ |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 44 | dtps.loadThreadsList = function (courseID, defaultThread) { |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 45 | //Get class index and set as selected class |
| 46 | var classNum = dtps.classes.map(course => course.id).indexOf(courseID); |
| 47 | dtps.selectedClass = classNum; |
| 48 | |
| 49 | //Set discussions as the selected content |
| 50 | dtps.selectedContent = "discuss"; |
| 51 | $("#dtpsTabBar .btn").removeClass("active"); |
| 52 | $("#dtpsTabBar .btn.discuss").addClass("active"); |
| 53 | |
| 54 | if (classNum == -1) { |
| 55 | //Class does not exist |
| 56 | dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.loadThreadsList"); |
| 57 | } |
| 58 | |
| 59 | //Load class color and things |
| 60 | dtps.presentClass(classNum); |
| 61 | jQuery("body").removeClass("collapsedSidebar"); |
| 62 | |
| 63 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "discuss")) { |
| 64 | //Render sidebar |
| 65 | jQuery(".sidebar").html(/*html*/` |
| 66 | <div class="bigLogo" style="text-align: center; margin: 10px 0 20px; height: 38px;"> |
| 67 | <i style="font-size: 28px; margin-right: 7px; vertical-align: middle;" class="material-icons">forum</i> |
| 68 | <h4 style="color: var(--text); display: inline-block; font-size: 28px; vertical-align: middle; margin: 0px;">Discussions</h4> |
| 69 | </div> |
| 70 | |
| 71 | <div class="items"> |
| 72 | <div class="spinner"></div> |
| 73 | </div> |
| 74 | `); |
| 75 | |
| 76 | //Delete existing class content HTML |
| 77 | jQuery(".classContent").html(""); |
| 78 | } |
| 79 | |
| 80 | //Fetch discussion thread data |
| 81 | dtpsLMS.fetchDiscussionThreads(dtps.classes[classNum].id).then(function (threadData) { |
| 82 | //Store fetched data to the selected class |
| 83 | dtps.classes[classNum].discussions = threadData; |
| 84 | |
| 85 | if (dtps.classes[classNum].discussions.length == 0) { |
| 86 | //No discussion topics in this class |
| 87 | jQuery(".sidebar .items").html(/*html*/` |
| 88 | <div onclick="fluid.screen('stream', '${dtps.classes[classNum].id}');" class="class item main back"> |
| 89 | <span class="label">Classes</span> |
| 90 | <div class="icon"> |
| 91 | <i class="material-icons">keyboard_arrow_left</i> |
| 92 | </div> |
| 93 | </div> |
| 94 | |
| 95 | <p style="text-align: center; font-weight: bold; margin-top: 60px;">No discussions found</p> |
| 96 | <p style="text-align: center; font-size: 14px;">This class doesn't have any discussions</p> |
| 97 | `); |
| 98 | } else { |
| 99 | //Loop over discusson threads array to create discussion thread HTML for the sidebar |
| 100 | var discussionHTML = dtps.classes[classNum].discussions.map(discussionThread => { |
| 101 | return /*html*/` |
| 102 | <div data-threadID="${discussionThread.id}" class="item"> |
| 103 | <span class="label">${discussionThread.title}</span> |
| 104 | <div class="icon"> |
| 105 | <i style="font-family: 'Material Icons Extended';" class="material-icons">${discussionThread.locked ? "lock_outline" : "chat_bubble_outline"}</i> |
| 106 | </div> |
| 107 | </div> |
| 108 | `; |
| 109 | }).join(""); |
| 110 | |
| 111 | //Render discussion threads in the sidebar |
| 112 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "discuss")) { |
| 113 | jQuery(".sidebar .items").html(/*html*/` |
| 114 | <div onclick="fluid.screen('stream', '${dtps.classes[classNum].id}');" class="class item main back"> |
| 115 | <span class="label">Classes</span> |
| 116 | <div class="icon"> |
| 117 | <i class="material-icons">keyboard_arrow_left</i> |
| 118 | </div> |
| 119 | </div> |
| 120 | |
| 121 | ${ |
| 122 | dtps.classes[classNum].newDiscussionThreadURL ? (/*html*/` |
| 123 | <div onclick="window.open('${dtps.classes[classNum].newDiscussionThreadURL}')" class="class item back"> |
| 124 | <span class="label">New discussion</span> |
| 125 | <div class="icon"> |
| 126 | <i class="material-icons">add</i> |
| 127 | </div> |
| 128 | </div> |
| 129 | `) : "" |
| 130 | } |
| 131 | |
| 132 | <div class="divider"></div> |
| 133 | |
| 134 | ${discussionHTML} |
| 135 | `); |
| 136 | } |
| 137 | |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 138 | //Load default thread if provided |
| 139 | if (defaultThread) { |
| 140 | dtps.loadThreadPosts(classNum, defaultThread); |
| 141 | } |
| 142 | |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 143 | //Add click event listeners for discussion threads |
| 144 | $(".sidebar .item:not(.back)").click(function (event) { |
| 145 | //Show the selected thread as active |
| 146 | $(this).siblings().removeClass("active"); |
| 147 | $(this).addClass("active"); |
| 148 | |
| 149 | //Get thread ID from HTML attribute |
| 150 | var postID = $(this).attr("data-threadID"); |
| 151 | |
| 152 | //Load the thread |
| 153 | dtps.loadThreadPosts(classNum, postID); |
| 154 | }); |
| 155 | } |
| 156 | |
| 157 | }).catch(function (err) { |
| 158 | dtps.error("Couldn't fetch discussion threads", "Caught promise rejection @ dtps.loadThreadsList", err); |
| 159 | }); |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * Fetches and displays posts in a discussion |
| 164 | * |
| 165 | * @param {number} classNum The class number to render |
| 166 | * @param {string} threadID The discussion thread to render |
| 167 | */ |
| 168 | dtps.loadThreadPosts = function (classNum, threadID) { |
| 169 | //Show loading indicator |
| 170 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "discuss")) { |
| 171 | jQuery(".classContent").html(`<div class="spinner"></div>`); |
| 172 | } |
| 173 | |
| 174 | //Get discussion data |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 175 | var thread = null; |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 176 | dtps.classes[classNum].discussions.forEach(discussionThread => { |
| 177 | if (discussionThread.id == threadID) { |
| 178 | thread = discussionThread; |
| 179 | } |
| 180 | }); |
| 181 | |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 182 | if (!thread) { |
| 183 | dtps.error("Thread does not exist", "thread is null @ dtps.loadThreadPosts"); |
| 184 | throw null; |
| 185 | } |
| 186 | |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 187 | //Fetch discussion posts from the LMS |
| 188 | dtpsLMS.fetchDiscussionPosts(dtps.classes[classNum].id, threadID).then(function (postData) { |
| 189 | //Store posts in the discussion thread |
| 190 | thread.posts = postData; |
| 191 | |
| 192 | //Post HTML array |
| 193 | var postHTML = []; |
| 194 | |
| 195 | thread.posts.forEach((post, index) => { |
| 196 | //Get background and text color for iFrame content |
| 197 | var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards"); |
| 198 | var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text"); |
| 199 | |
| 200 | //Create a new blob data URL with the post's content |
| 201 | var blob = new Blob([` |
| 202 | <base target="_blank" /> |
| 203 | <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/> |
| 204 | <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};</style> |
| 205 | ${post.body} |
| 206 | `], { type: 'text/html' }); |
| 207 | var discussionPostContentURL = window.URL.createObjectURL(blob); |
| 208 | |
| 209 | //Create HTML for replies |
| 210 | var replyHTML = []; |
| 211 | if (post.replies) { |
| 212 | //Add space above replies |
| 213 | replyHTML.push(`<br />`); |
| 214 | |
| 215 | //Get HTML for each reply and add to array |
| 216 | post.replies.forEach(reply => { |
| 217 | replyHTML.push(/*html*/` |
| 218 | <div style="margin-left: ${(reply.depth || 0) * 50}px;" class="discussionReply"> |
| 219 | <div class="discussionHeader"> |
| 220 | ${post.author ? /*html*/` |
| 221 | <img src="${reply.author.photoURL}" /> |
| 222 | <h5>${reply.author.name}</h5> |
| 223 | ` : ``} |
| 224 | |
| 225 | <span style="cursor: pointer;" onclick="window.open('${reply.replyURL}')"> |
| 226 | <i class="material-icons">reply</i> |
| 227 | <span>Reply</span> |
| 228 | </span> |
| 229 | </div> |
| 230 | |
| 231 | ${reply.body} |
| 232 | </div> |
| 233 | `) |
| 234 | }); |
| 235 | |
| 236 | //Add space below replies |
| 237 | replyHTML.push(`<br />`); |
| 238 | } |
| 239 | |
| 240 | //Create HTML for this post |
| 241 | //Note that index == 0 is the initial post |
| 242 | postHTML.push(/*html*/` |
| 243 | <div class="card" style="margin-top: 20px;${index == 0 ? "margin-bottom: 75px;" : "padding: 20px 30px;"}"> |
| 244 | <!-- Thread title (Initial post) --> |
| 245 | ${index == 0 ? /*html*/` |
| 246 | <h4 style="font-weight: bold">${thread.title}</h4> |
| 247 | ` : ''} |
| 248 | |
| 249 | <!-- Author header --> |
| 250 | <div ${index == 0 ? `style="margin-bottom: 32px;"` : ""} class="discussionHeader"> |
| 251 | ${post.author ? /*html*/` |
| 252 | <img src="${post.author.photoURL}" /> |
| 253 | <h5>${post.author.name}</h5> |
| 254 | ` : ``} |
| 255 | |
| 256 | <i class="material-icons">calendar_today</i> |
| 257 | <span>${dtps.formatDate(post.postedAt)}</span> |
| 258 | |
| 259 | <!-- Thread info (initial post) --> |
| 260 | ${index == 0 ? /*html*/` |
| 261 | ${thread.locked ? `<i class="material-icons">lock</i>` : ""} |
| 262 | ${thread.requireInitialPost ? /*html*/` |
| 263 | <i class="material-icons">visibility</i> |
| 264 | <span>You must post before you can see other replies</span> |
| 265 | ` : ""} |
| 266 | ` : ''} |
| 267 | </div> |
| 268 | |
| 269 | ${post.body} |
| 270 | |
| 271 | ${replyHTML.join("")} |
| 272 | |
| 273 | <!-- Reply / Add post footer --> |
| 274 | ${post.replyURL ? /*html*/` |
| 275 | <div ${index == 0 ? `style="margin-top: 32px;"` : ""} class="discussionFooter"> |
| 276 | ${index == 0 ? /*html*/` |
| 277 | <button onclick="window.open('${post.replyURL}')" class="btn small"><i class="material-icons">post_add</i> Add Post</button> |
| 278 | ` : /*html*/` |
| 279 | <button onclick="window.open('${post.replyURL}')" class="btn small"><i class="material-icons">reply</i> Reply</button> |
| 280 | `} |
| 281 | </div> |
| 282 | ` : ""} |
| 283 | </div> |
| 284 | `); |
| 285 | }); |
| 286 | |
| 287 | //Render HTML |
| 288 | jQuery(".classContent").html(postHTML.join("")); |
| 289 | }).catch(function (err) { |
| 290 | dtps.error("Could not fetch discussion posts", "Caught promise rejection @ dtps.loadThreadPosts", err); |
| 291 | }); |
| 292 | } |
| 293 | |
| 294 | /** |
| 295 | * Renders the pages list for a class |
| 296 | * |
| 297 | * @param {string} courseID The course ID to render pages for |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 298 | * @param {string} [defaultPage] If provided, load the pageID by default |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 299 | */ |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 300 | dtps.loadPagesList = function (courseID, defaultPage) { |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 301 | //Get class index and set as selected class |
| 302 | var classNum = dtps.classes.map(course => course.id).indexOf(courseID); |
| 303 | dtps.selectedClass = classNum; |
| 304 | |
| 305 | //Set pages as the selected content |
| 306 | dtps.selectedContent = "pages"; |
| 307 | $("#dtpsTabBar .btn").removeClass("active"); |
| 308 | $("#dtpsTabBar .btn.pages").addClass("active"); |
| 309 | |
| 310 | if (classNum == -1) { |
| 311 | //Class does not exist |
| 312 | dtps.error("The selected class doesn't exist", "classNum check failed @ dtps.loadPagesList"); |
| 313 | } |
| 314 | |
| 315 | //Load class color and things |
| 316 | dtps.presentClass(classNum); |
| 317 | jQuery("body").removeClass("collapsedSidebar"); |
| 318 | |
| 319 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "pages")) { |
| 320 | //Render sidebar |
| 321 | jQuery(".sidebar").html(/*html*/` |
| 322 | <div class="bigLogo" style="text-align: center; margin: 10px 0 20px; height: 38px;"> |
| 323 | <i style="font-size: 28px; margin-right: 7px; vertical-align: middle;" class="material-icons">insert_drive_file</i> |
| 324 | <h4 style="color: var(--text); display: inline-block; font-size: 28px; vertical-align: middle; margin: 0px;">Pages</h4> |
| 325 | </div> |
| 326 | |
| 327 | <div class="items"> |
| 328 | <div class="spinner"></div> |
| 329 | </div> |
| 330 | `); |
| 331 | |
| 332 | //Delete existing class content HTML |
| 333 | jQuery(".classContent").html(""); |
| 334 | } |
| 335 | |
| 336 | dtpsLMS.fetchPages(dtps.classes[classNum].id).then(function (pagesData) { |
| 337 | //Store fetched pages data to the class |
| 338 | dtps.classes[classNum].pages = pagesData; |
| 339 | |
| 340 | if (pagesData.length == 0) { |
| 341 | //No pages in this class |
| 342 | jQuery(".sidebar .items").html(/*html*/` |
| 343 | <div onclick="fluid.screen('stream', '${dtps.classes[classNum].id}');" class="class item main back"> |
| 344 | <span class="label">Classes</span> |
| 345 | <div class="icon"> |
| 346 | <i class="material-icons">keyboard_arrow_left</i> |
| 347 | </div> |
| 348 | </div> |
| 349 | |
| 350 | <p style="text-align: center; font-weight: bold; margin-top: 60px;">No pages found</p> |
| 351 | <p style="text-align: center; font-size: 14px;">This class doesn't have any pages</p> |
| 352 | `); |
| 353 | } else { |
| 354 | //Loop over discusson threads array to create discussion thread HTML for the sidebar |
| 355 | var pageHTML = dtps.classes[classNum].pages.map(page => { |
| 356 | return /*html*/` |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 357 | <div data-pageID="${page.id}" class="item ${(defaultPage && (page.id == defaultPage)) ? "active" : ""}"> |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 358 | <span class="label">${page.title}</span> |
| 359 | <div class="icon"> |
| 360 | <i class="material-icons">insert_drive_file</i> |
| 361 | </div> |
| 362 | </div> |
| 363 | `; |
| 364 | }).join(""); |
| 365 | |
| 366 | //Render discussion threads in the sidebar |
| 367 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "pages")) { |
| 368 | jQuery(".sidebar .items").html(/*html*/` |
| 369 | <div onclick="fluid.screen('stream', '${dtps.classes[classNum].id}');" class="class item main back"> |
| 370 | <span class="label">Classes</span> |
| 371 | <div class="icon"> |
| 372 | <i class="material-icons">keyboard_arrow_left</i> |
| 373 | </div> |
| 374 | </div> |
| 375 | |
| 376 | <div class="divider"></div> |
| 377 | |
| 378 | ${pageHTML} |
| 379 | `); |
| 380 | } |
| 381 | |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 382 | //Load default page if provided |
| 383 | if (defaultPage) { |
| 384 | dtps.loadPage(classNum, defaultPage); |
| 385 | } |
| 386 | |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 387 | //Add click event listeners for pages |
| 388 | $(".sidebar .item:not(.back)").click(function (event) { |
| 389 | //Show the selected thread as active |
| 390 | $(this).siblings().removeClass("active"); |
| 391 | $(this).addClass("active"); |
| 392 | |
| 393 | //Get page ID from HTML attribute |
| 394 | var pageID = $(this).attr("data-pageID"); |
| 395 | |
| 396 | //Load the page content |
| 397 | dtps.loadPage(classNum, pageID); |
| 398 | }); |
| 399 | } |
| 400 | }).catch((err) => { |
| 401 | dtps.error("Couldn't fetch pages", "Caught promise rejection @ dtps.loadPagesList", err); |
| 402 | }); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * Fetches and renders a page and its contents |
| 407 | * |
| 408 | * @param {string} classNum The class number of the page to render |
| 409 | * @param {string} pageID The page ID to render |
| 410 | */ |
| 411 | dtps.loadPage = function (classNum, pageID) { |
| 412 | //Show loading indicator |
| 413 | if ((dtps.selectedClass == classNum) && (dtps.selectedContent == "pages")) { |
| 414 | jQuery(".classContent").html(`<div class="spinner"></div>`); |
| 415 | } |
| 416 | |
| 417 | //Get page data |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 418 | var page = null; |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 419 | dtps.classes[classNum].pages.forEach(pageCheck => { |
| 420 | if (pageCheck.id == pageID) { |
| 421 | page = pageCheck; |
| 422 | } |
| 423 | }); |
| 424 | |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 425 | if (!page) { |
| 426 | dtps.error("Page does not exist", "page is null @ dtps.loadPage"); |
| 427 | throw null; |
| 428 | } |
| 429 | |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 430 | //Fetch page content |
| 431 | dtpsLMS.fetchPageContent(dtps.classes[classNum].id, page.id).then(function (pageContentData) { |
| 432 | //Store page content in the page object |
| 433 | page.content = pageContentData; |
| 434 | |
| 435 | if ((dtps.classes[dtps.selectedClass].id == dtps.classes[classNum].id) && (dtps.selectedContent == "pages")) { |
| 436 | //Get computed background and text color to style the iFrame with |
| 437 | var computedBackgroundColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--cards"); |
| 438 | var computedTextColor = getComputedStyle($(".card.details")[0]).getPropertyValue("--text"); |
| 439 | |
| 440 | //Generate a blob with the page content and get its data URL |
| 441 | var blob = new Blob([` |
| 442 | <base target="_blank" /> |
| 443 | <link type="text/css" rel="stylesheet" href="https://cdn.jottocraft.com/CanvasCSS.css" media="screen,projection"/> |
| 444 | <style>body {background-color: ${computedBackgroundColor}; color: ${computedTextColor};</style> |
| 445 | ${page.content} |
| 446 | `], { type: 'text/html' }); |
| 447 | |
| 448 | //Get URL from blob |
| 449 | var pageContentURL = window.URL.createObjectURL(blob); |
| 450 | |
| 451 | //Render page card in the class content |
| 452 | jQuery(".classContent").html(/*html*/` |
| 453 | <div class="card"> |
| 454 | <!-- Page title --> |
| 455 | <h4 style="font-weight: bold;">${page.title}</h4> |
| 456 | |
| 457 | <!-- Page header --> |
| 458 | <div style="margin-bottom: 32px;" class="discussionHeader"> |
| 459 | ${page.author ? /*html*/` |
| 460 | <img src="${page.author.photoURL}" /> |
| 461 | <h5>${page.author.name}</h5> |
| 462 | ` : ``} |
| 463 | |
| 464 | <i class="material-icons">calendar_today</i> |
| 465 | <span>${"Last Updated " + dtps.formatDate(page.updatedAt)}</span> |
| 466 | </div> |
| 467 | |
| 468 | <!-- Page content --> |
| 469 | <br /> |
| 470 | <iframe id="classPageIframe" onload="dtps.iframeLoad('classPageIframe')" style="margin: 10px 0px; width: 100%; border: none; outline: none;" src="${pageContentURL}" /> |
| 471 | </div> |
| 472 | `); |
| 473 | } |
| 474 | }).catch((err) => { |
| 475 | dtps.error("Couldn't load page", "Caught promise rejection @ dtps.loadPage", err); |
| 476 | }); |
| 477 | } |
| 478 | |
| 479 | //Fluid UI screen definitions |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 480 | fluid.externalScreens.discussions = (param) => { |
| 481 | //Split parameter string into variables |
| 482 | var courseID = param.split("|")[0]; |
| 483 | var threadID = param.split("|")[1]; |
| 484 | |
| 485 | dtps.loadThreadsList(courseID, threadID); |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 488 | fluid.externalScreens.pages = (param) => { |
| 489 | //Split parameter string into variables |
| 490 | var courseID = param.split("|")[0]; |
| 491 | var pageID = param.split("|")[1]; |
| 492 | |
| 493 | dtps.loadPagesList(courseID, pageID); |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | //Type definitions |
| 497 | |
| 498 | /** |
| 499 | * @typedef {Object} DiscussionThread |
| 500 | * @description Defines discussion thread objects in DTPS |
| 501 | * @property {string} title Title of the discussion thread |
| 502 | * @property {string} id Discussion thread ID |
| 503 | * @property {DiscussionPost[]} posts Posts in this thread, with the initial one first. Assume that the topic has not been selected and loaded if this is undefined, and that there are no posts if this is an empty array. |
| 504 | * @property {boolean} [locked] True if posting to the discussion thread is locked |
| 505 | * @property {boolean} [requireInitialPost] True if the user must post before viewing others' posts |
| 506 | */ |
| 507 | |
| 508 | /** |
| 509 | * @typedef {Object} DiscussionPost |
| 510 | * @description Defines discussion post objects in DTPS |
| 511 | * @property {string} id Discussion post ID |
| 512 | * @property {string} body Discussion post body HTML |
| 513 | * @property {Date} postedAt Date for when the post was posted |
| 514 | * @property {number} [depth] The depth level this post is |
| 515 | * @property {User} [author] Discussion post author |
| 516 | * @property {DiscussionPost[]} [replies] Replies to this post. Nested replies (replies to replies) should be after this post in the array with a depth of 1, not in the replies key. |
| 517 | * @property {string} [replyURL] A URL that the user can visit to reply to this post |
| 518 | */ |
| 519 | |
| 520 | /** |
| 521 | * @typedef {Object} Page |
| 522 | * @description Defines Page objects in DTPS |
| 523 | * @property {string} title Page title |
| 524 | * @property {string} id Page ID |
| 525 | * @property {string} content Page content. Assume the page hasn't been selected/loaded if this is undefined. |
| 526 | * @property {Date} [updatedAt] When the page was last updated |
| 527 | * @property {User} [author] Page author |
| 528 | */</code></pre> |
| 529 | </article> |
| 530 | </section> |
| 531 | |
| 532 | |
| 533 | |
| 534 | |
| 535 | </div> |
| 536 | |
| 537 | <nav> |
| 538 | <h2><a href="index.html">Home</a></h2><h3>Namespaces</h3><ul><li><a href="dtps.html">dtps</a></li><li><a href="dtpsLMS.html">dtpsLMS</a></li></ul><h3><a href="global.html">Global</a></h3> |
| 539 | </nav> |
| 540 | |
| 541 | <br class="clear"> |
| 542 | |
| 543 | <footer> |
| j | 35a697e | 2020-07-24 20:28:00 -0700 | [diff] [blame^] | 544 | Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Fri Jul 24 2020 19:25:37 GMT-0700 (Pacific Daylight Time) |
| j | 1c53f82 | 2020-06-07 15:32:06 -0700 | [diff] [blame] | 545 | </footer> |
| 546 | |
| 547 | <script> prettyPrint(); </script> |
| 548 | <script src="scripts/linenumber.js"> </script> |
| 549 | </body> |
| 550 | </html> |