Sindbad~EG File Manager
{"version":3,"file":"snap_feeds.min.js","sources":["../src/snap_feeds.js"],"sourcesContent":["/**\n * This file is part of Moodle - http://moodle.org/\n *\n * Moodle is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * Moodle is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n *\n * @package\n * @copyright Copyright (c) 2024 Open LMS (https://www.openlms.net)\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/**\n * Snap feeds side menu.\n */\ndefine(['jquery', 'core/log','theme_snap/util', 'theme_snap/ajax_notification'],\n function($, log, util, ajaxNotify) {\n /**\n * Load Snap feeds content when advanced feeds are disabled.\n * @param {boolean} urlParameter\n *\n */\n var update = function(urlParameter) {\n $(document).ready(function() {\n var loadAjaxInfo = function(type) {\n // Target for data to be displayed on screen.\n var container = $('#snap-feeds-menu-' + type);\n if ($(container).length) {\n var cacheKey = M.cfg.sesskey + 'snap-feeds-menu-' + type;\n try {\n // Display old content while waiting\n if (util.supportsSessionStorage() && window.sessionStorage[cacheKey]) {\n log.info('using locally stored ' + type);\n var html = window.sessionStorage[cacheKey];\n $(container).html(html);\n }\n log.info('fetching ' + type);\n $.ajax({\n type: \"GET\",\n async: true,\n url: M.cfg.wwwroot + '/theme/snap/rest.php?action=get_' + type + '&contextid=' + M.cfg.context,\n success: function(data) {\n ajaxNotify.ifErrorShowBestMsg(data).done(function(errorShown) {\n if (errorShown) {\n return;\n } else {\n // No errors, update sesion storage.\n log.info('fetched ' + type);\n if (util.supportsSessionStorage() && typeof (data.html) != 'undefined') {\n window.sessionStorage[cacheKey] = data.html;\n }\n // Note: we can't use .data because that does not manipulate the dom, we need the data\n // attribute populated immediately so things like behat can utilise it.\n // .data just sets the value in memory, not the dom.\n $(container).attr('data-content-loaded', '1');\n if (urlParameter) {\n let modifiedHTML = modifyHTML(data.html);\n $(container).html(modifiedHTML);\n } else {\n $(container).html(data.html);\n }\n }\n });\n }\n });\n } catch (err) {\n sessionStorage.clear();\n log.error(err);\n }\n }\n };\n\n loadAjaxInfo('deadlines');\n loadAjaxInfo('graded');\n loadAjaxInfo('grading');\n loadAjaxInfo('messages');\n loadAjaxInfo('forumposts');\n });\n };\n\n /**\n * Modify the HTML to add the snapfeedsclicked label in the URL.\n * @param {string} html\n */\n var modifyHTML = function(html) {\n const beforeURLPattern = \"<div class=\\\"snap-media-body\\\">\\n<a href=\\\"\";\n const afterURLPattern = \"\\\"><h3>\";\n const regex = new RegExp(beforeURLPattern + \"(.*)\" + afterURLPattern, \"g\");\n const results = [...html.matchAll(regex)];\n let modifiedHTML = html;\n if (results.length > 0) {\n results.forEach(result => {\n const originalURL = result[1];\n const modifiedURL = originalURL + \"&snapfeedsclicked=on\";\n modifiedHTML = modifiedHTML.replace(originalURL, modifiedURL);\n });\n } else {\n return html;\n }\n return modifiedHTML;\n };\n\n /**\n * Apply Snap feeds side menu listeners.\n * @param {boolean} urlParameter\n */\n var applyListeners = function(urlParameter) {\n // On clicking snap feeds side menu trigger.\n $(document).on(\"click\", \".js-snap-feeds-side-menu-trigger\", function(event) {\n if ($('#snap_feeds_side_menu').is(':visible')) {\n update(urlParameter);\n }\n event.preventDefault();\n\n });\n };\n\n var init = function(urlParameter) {\n applyListeners(urlParameter);\n };\n\n return {\n init: init,\n };\n }\n);"],"names":["define","$","log","util","ajaxNotify","modifyHTML","html","regex","RegExp","beforeURLPattern","results","matchAll","modifiedHTML","length","forEach","result","originalURL","modifiedURL","replace","applyListeners","urlParameter","document","on","event","is","ready","loadAjaxInfo","type","container","cacheKey","M","cfg","sesskey","supportsSessionStorage","window","sessionStorage","info","ajax","async","url","wwwroot","context","success","data","ifErrorShow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