Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"validator.min.js","sources":["../src/validator.js"],"sourcesContent":["// 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/**\n * Our validator that splits the user's input then fires off to a webservice\n *\n * @module     tool_moodlenet/validator\n * @copyright  2020 Mathew May <mathew.solutions>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery', 'core/ajax', 'core/str', 'core/notification'], function($, Ajax, Str, Notification) {\n    /**\n     * Handle form validation\n     *\n     * @method validation\n     * @param {HTMLElement} inputElement The element the user entered text into.\n     * @return {Promise} Was the users' entry a valid profile URL?\n     */\n    var validation = function validation(inputElement) {\n        var inputValue = inputElement.value;\n\n        // They didn't submit anything or they gave us a simple string that we can't do anything with.\n        if (inputValue === \"\" || !inputValue.includes(\"@\")) {\n            // Create a promise and immediately reject it.\n            $.when(Str.get_string('profilevalidationerror', 'tool_moodlenet')).then(function(strings) {\n                return Promise.reject().catch(function() {\n                    return {result: false, message: strings[0]};\n                });\n            }).fail(Notification.exception);\n        }\n\n        return Ajax.call([{\n            methodname: 'tool_moodlenet_verify_webfinger',\n            args: {\n                profileurl: inputValue,\n                course: inputElement.dataset.courseid,\n                section: inputElement.dataset.sectionid\n            }\n        }])[0].then(function(result) {\n            return result;\n        }).catch();\n    };\n    return {\n        validation: validation,\n    };\n});\n"],"names":["define","$","Ajax","Str","Notification","validation","inputElement","inputValue","value","includes","when","get_string","then","strings","Promise","reject","catch","result","message","fail","exception","call","methodname","args","profileurl","course","dataset","courseid","section","sectionid"],"mappings":";;;;;;;AAsBAA,kCAAO,CAAC,SAAU,YAAa,WAAY,sBAAsB,SAASC,EAAGC,KAAMC,IAAKC,oBAgC7E,CACHC,WAzBa,SAAoBC,kBAC7BC,WAAaD,aAAaE,YAGX,KAAfD,YAAsBA,WAAWE,SAAS,MAE1CR,EAAES,KAAKP,IAAIQ,WAAW,yBAA0B,mBAAmBC,MAAK,SAASC,gBACtEC,QAAQC,SAASC,OAAM,iBACnB,CAACC,QAAQ,EAAOC,QAASL,QAAQ,UAE7CM,KAAKf,aAAagB,WAGlBlB,KAAKmB,KAAK,CAAC,CACdC,WAAY,kCACZC,KAAM,CACFC,WAAYjB,WACZkB,OAAQnB,aAAaoB,QAAQC,SAC7BC,QAAStB,aAAaoB,QAAQG,cAElC,GAAGjB,MAAK,SAASK,eACVA,UACRD"}