Your IP : 192.168.165.1


Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/
Upload File :
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ajax.min.js.map

{"version":3,"sources":["../src/ajax.js"],"names":["define","$","config","Log","URL","unloading","requestSuccess","responses","requests","exception","i","request","response","nosessionupdate","error","length","deferred","reject","resolve","data","Error","errorcode","window","location","relativeUrl","forEach","requestFail","jqXHR","textStatus","call","async","loginrequired","timeout","cachekey","bind","ajaxRequestData","promises","methodInfo","requestInfo","parseInt","push","index","methodname","args","Deferred","promise","done","fail","sort","join","JSON","stringify","settings","type","context","dataType","processData","contentType","script","url","wwwroot","sesskey","urlUseGet","encodeURIComponent","ajax","success"],"mappings":"AA2BAA,OAAM,aAAC,CAAC,QAAD,CAAW,aAAX,CAA0B,UAA1B,CAAsC,UAAtC,CAAD,CAAoD,SAASC,CAAT,CAAYC,CAAZ,CAAoBC,CAApB,CAAyBC,CAAzB,CAA8B,IAGhFC,CAAAA,CAAS,GAHuE,CAahFC,CAAc,CAAG,SAASC,CAAT,CAAoB,CAErC,GAAIC,CAAAA,CAAQ,CAAG,IAAf,CACIC,CAAS,CAAG,IADhB,CAEIC,CAAC,CAAG,CAFR,CAGIC,CAHJ,CAIIC,CAJJ,CAKIC,CALJ,CAOA,GAAIN,CAAS,CAACO,KAAd,CAAqB,CAIjB,KAAOJ,CAAC,CAAGF,CAAQ,CAACO,MAApB,CAA4BL,CAAC,EAA7B,CAAiC,CAC7BC,CAAO,CAAGH,CAAQ,CAACE,CAAD,CAAlB,CACAC,CAAO,CAACK,QAAR,CAAiBC,MAAjB,CAAwBV,CAAxB,CACH,CAED,MACH,CAED,IAAKG,CAAC,CAAG,CAAT,CAAYA,CAAC,CAAGF,CAAQ,CAACO,MAAzB,CAAiCL,CAAC,EAAlC,CAAsC,CAClCC,CAAO,CAAGH,CAAQ,CAACE,CAAD,CAAlB,CAEAE,CAAQ,CAAGL,CAAS,CAACG,CAAD,CAApB,CAEA,G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A3B,CACA,GAAIL,CAAJ,CAAc,CACV0B,CAAG,EAAI,aAAe1B,CAAtB,CACAmB,CAAQ,CAACC,IAAT,CAAgB,KACnB,CACJ,CAPD,IAOO,CACHM,CAAG,EAAID,CAAM,CAAG,WAAT,CAAuBxD,CAAM,CAAC2D,OAA9B,CAAwC,QAAxC,CAAmDvB,CAC7D,CAED,GAAIzB,CAAJ,CAAqB,CACjB8C,CAAG,EAAI,uBACV,CAED,GAAsB,MAAlB,GAAAP,CAAQ,CAACC,IAAb,CAA8B,CAC1BD,CAAQ,CAACjC,IAAT,CAAgBgB,CACnB,CAFD,IAEO,CACH,GAAI2B,CAAAA,CAAS,CAAGH,CAAG,CAAG,QAAN,CAAiBI,kBAAkB,CAAC5B,CAAD,CAAnD,CAEA,GAAI2B,CAAS,CAAC/C,MAAV,CAtFW,GAsFf,CAAqC,CACjCqC,CAAQ,CAACC,IAAT,CAAgB,MAAhB,CACAD,CAAQ,CAACjC,IAAT,CAAgBgB,CACnB,CAHD,IAGO,CACHwB,CAAG,CAAGG,CACT,CACJ,CAGD,GAAIhC,CAAJ,CAAW,CACP7B,CAAC,CAAC+D,IAAF,CAAOL,CAAP,CAAYP,CAAZ,EACKN,IADL,CACUxC,CADV,EAEKyC,IAFL,CAEUrB,CAFV,CAGH,CAJD,IAIO,CACH0B,CAAQ,CAACa,OAAT,CAAmB3D,CAAnB,CACA8C,CAAQ,CAACtC,KAAT,CAAiBY,CAAjB,CACAzB,CAAC,CAAC+D,IAAF,CAAOL,CAAP,CAAYP,CAAZ,CACH,CAED,MAAOhB,CAAAA,CACV,CA5IiC,CA8IzC,CA5OK,CAAN","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 * Standard Ajax wrapper for Moodle. It calls the central Ajax script,\n * which can call any existing webservice using the current session.\n * In addition, it can batch multiple requests and return multiple responses.\n *\n * @module     core/ajax\n * @class      ajax\n * @package    core\n * @copyright  2015 Damyon Wiese <damyon@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      2.9\n */\ndefine(['jquery', 'core/config', 'core/log', 'core/url'], function($, config, Log, URL) {\n\n    // Keeps track of when the user leaves the page so we know not to show an error.\n    var unloading = false;\n\n    /**\n     * Success handler. Called when the ajax call succeeds. Checks each response and\n     * resolves or rejects the deferred from that request.\n     *\n     * @method requestSuccess\n     * @private\n     * @param {Object[]} responses Array of responses containing error, exception and data attributes.\n     */\n    var requestSuccess = function(responses) {\n        // Call each of the success handlers.\n        var requests = this,\n            exception = null,\n            i = 0,\n            request,\n            response,\n            nosessionupdate;\n\n        if (responses.error) {\n            // There was an error with the request as a whole.\n            // We need to reject each promise.\n            // Unfortunately this may lead to duplicate dialogues, but each Promise must be rejected.\n            for (; i < requests.length; i++) {\n                request = requests[i];\n                request.deferred.reject(responses);\n            }\n\n            return;\n        }\n\n        for (i = 0; i < requests.length; i++) {\n            request = requests[i];\n\n            response = responses[i];\n            // We may not have responses for all the requests.\n            if (typeof response !== \"undefined\") {\n                if (response.error === false) {\n                    // Call the done handler if it was provided.\n                    request.deferred.resolve(response.data);\n                } else {\n                    exception = response.exception;\n                    nosessionupdate = requests[i].nosessionupdate;\n                    break;\n                }\n            } else {\n                // This is not an expected case.\n                exception = new Error('missing response');\n                break;\n            }\n        }\n        // Something failed, reject the remaining promises.\n        if (exception !== null) {\n            // Redirect to the login page.\n            if (exception.errorcode === \"servicerequireslogin\" && !nosessionupdate) {\n                window.location = URL.relativeUrl(\"/login/index.php\");\n            } else {\n                requests.forEach(function(request) {\n                    request.deferred.reject(exception);\n                });\n            }\n        }\n    };\n\n    /**\n     * Fail handler. Called when the ajax call fails. Rejects all deferreds.\n     *\n     * @method requestFail\n     * @private\n     * @param {jqXHR} jqXHR The ajax object.\n     * @param {string} textStatus The status string.\n     * @param {Error|Object} exception The error thrown.\n     */\n    var requestFail = function(jqXHR, textStatus, exception) {\n        // Reject all the promises.\n        var requests = this;\n\n        var i = 0;\n        for (i = 0; i < requests.length; i++) {\n            var request = requests[i];\n\n            if (unloading) {\n                // No need to trigger an error because we are already navigating.\n                Log.error(\"Page unloaded.\");\n                Log.error(exception);\n            } else {\n                request.deferred.reject(exception);\n            }\n        }\n    };\n\n    return /** @alias module:core/ajax */ {\n        // Public variables and functions.\n        /**\n         * Make a series of ajax requests and return all the responses.\n         *\n         * @method call\n         * @param {Object[]} requests Array of requests with each containing methodname and args properties.\n         *                   done and fail callbacks can be set for each element in the array, or the\n         *                   can be attached to the promises returned by this function.\n         * @param {Boolean} async Optional, defaults to true.\n         *                  If false - this function will not return until the promises are resolved.\n         * @param {Boolean} loginrequired Optional, defaults to true.\n         *                  If false - this function will call the faster nologin ajax script - but\n         *                  will fail unless all functions have been marked as 'loginrequired' => false\n         *                  in services.php\n         * @param {Boolean} nosessionupdate Optional, defaults to false.\n         *                  If true, the timemodified for the session will not be updated.\n         * @param {Integer} timeout number of milliseconds to wait for a response. Defaults to no limit.\n         * @param {Integer} cachekey This is used in order to identify the request. If this id changes then we\n         *                  will be sending a different URL and any caching (eg. browser, proxy) knows that it\n         *                  should perform another request and not use the cache. Note - this variable is only\n         *                  used when we are calling 'service-nologin.php'. See MDL-65794.\n         * @return {Promise[]} Array of promises that will be resolved when the ajax call returns.\n         */\n        call: function(requests, async, loginrequired, nosessionupdate, timeout, cachekey) {\n            $(window).bind('beforeunload', function() {\n                unloading = true;\n            });\n            var ajaxRequestData = [],\n                i,\n                promises = [],\n                methodInfo = [],\n                requestInfo = '';\n\n            var maxUrlLength = 2000;\n\n            if (typeof loginrequired === \"undefined\") {\n                loginrequired = true;\n            }\n            if (typeof async === \"undefined\") {\n                async = true;\n            }\n            if (typeof timeout === 'undefined') {\n                timeout = 0;\n            }\n            if (typeof cachekey === 'undefined') {\n                cachekey = null;\n            } else {\n                cachekey = parseInt(cachekey);\n                if (cachekey <= 0) {\n                    cachekey = null;\n                } else if (!cachekey) {\n                    cachekey = null;\n                }\n            }\n\n            if (typeof nosessionupdate === \"undefined\") {\n                nosessionupdate = false;\n            }\n            for (i = 0; i < requests.length; i++) {\n                var request = requests[i];\n                ajaxRequestData.push({\n                    index: i,\n                    methodname: request.methodname,\n                    args: request.args\n                });\n                request.nosessionupdate = nosessionupdate;\n                request.deferred = $.Deferred();\n                promises.push(request.deferred.promise());\n                // Allow setting done and fail handlers as arguments.\n                // This is just a shortcut for the calling code.\n                if (typeof request.done !== \"undefined\") {\n                    request.deferred.done(request.done);\n                }\n                if (typeof request.fail !== \"undefined\") {\n                    request.deferred.fail(request.fail);\n                }\n                request.index = i;\n                methodInfo.push(request.methodname);\n            }\n\n            if (methodInfo.length <= 5) {\n                requestInfo = methodInfo.sort().join();\n            } else {\n                requestInfo = methodInfo.length + '-method-calls';\n            }\n\n            ajaxRequestData = JSON.stringify(ajaxRequestData);\n            var settings = {\n                type: 'POST',\n                context: requests,\n                dataType: 'json',\n                processData: false,\n                async: async,\n                contentType: \"application/json\",\n                timeout: timeout\n            };\n\n            var script = 'service.php';\n            var url = config.wwwroot + '/lib/ajax/';\n            if (!loginrequired) {\n                script = 'service-nologin.php';\n                url += script + '?info=' + requestInfo;\n                if (cachekey) {\n                    url += '&cachekey=' + cachekey;\n                    settings.type = 'GET';\n                }\n            } else {\n                url += script + '?sesskey=' + config.sesskey + '&info=' + requestInfo;\n            }\n\n            if (nosessionupdate) {\n                url += '&nosessionupdate=true';\n            }\n\n            if (settings.type === 'POST') {\n                settings.data = ajaxRequestData;\n            } else {\n                var urlUseGet = url + '&args=' + encodeURIComponent(ajaxRequestData);\n\n                if (urlUseGet.length > maxUrlLength) {\n                    settings.type = 'POST';\n                    settings.data = ajaxRequestData;\n                } else {\n                    url = urlUseGet;\n                }\n            }\n\n            // Jquery deprecated done and fail with async=false so we need to do this 2 ways.\n            if (async) {\n                $.ajax(url, settings)\n                    .done(requestSuccess)\n                    .fail(requestFail);\n            } else {\n                settings.success = requestSuccess;\n                settings.error = requestFail;\n                $.ajax(url, settings);\n            }\n\n            return promises;\n        }\n    };\n});\n"],"file":"ajax.min.js"}