3 lines
2.4 KiB
JavaScript
3 lines
2.4 KiB
JavaScript
define ("core/network",["jquery","core/ajax","core/config","core/notification","core/str"],function(a,b,c,d,e){var f=!1,g=!1,h=0,i=0,j=!1,k=!1,l=1e3*Math.min(c.sessiontimeout/10,600),m=0<c.sessiontimeoutwarning?1e3*c.sessiontimeoutwarning:2*l,n=0<c.sessiontimeoutwarning?Math.min(1e3*(c.sessiontimeout-c.sessiontimeoutwarning),5*l):5*l,o=function(a){k=!0;g=!1;p(a);q()},p=function(a){a.destroy()},q=function(){return b.call([{methodname:"core_session_time_remaining",args:{}}],!0,!0,!0)[0].then(function(a){if(1e3*a.timeremaining>m){return!1}else{return e.get_strings([{key:"sessionexpired",component:"error"},{key:"sessionerroruser",component:"error"},{key:"loginagain",component:"moodle"},{key:"cancel",component:"moodle"}]).then(function(a){d.confirm(a[0],a[1],a[2],a[3],function(){location.reload();return!0});return!0}).catch(d.exception)}})},r=function(){if(k){return q()}else{return b.call([{methodname:"core_session_touch",args:{}}],!0,!0,!1,i)[0].then(function(){if(0<h){setTimeout(r,h)}return!0}).catch(function(){d.alert("",j)})}},s=function(){k=!1;return b.call([{methodname:"core_session_time_remaining",args:{}}],!0,!0,!0)[0].then(function(a){if(0>=a.userid){return!1}if(0>=a.timeremaining){return q()}else if(1e3*a.timeremaining<=m&&!g){g=!0;e.get_strings([{key:"norecentactivity",component:"moodle"},{key:"sessiontimeoutsoon",component:"moodle"},{key:"extendsession",component:"moodle"},{key:"cancel",component:"moodle"}]).then(function(a){return d.confirm(a[0],a[1],a[2],a[3],function(){r();g=!1;setTimeout(s,n);return!0},function(){setTimeout(s,l)})}).then(function(b){setTimeout(o,1e3*a.timeremaining,b)}).catch(d.exception)}else{setTimeout(s,l)}return!0})},t=function(){if(0<h){setTimeout(r,h)}else{setTimeout(s,n)}},u=function(){if(window.parent===window){return!1}var a;try{a=window.parent.location.href}catch(a){return!1}return a.startsWith(M.cfg.wwwroot)},v=function(){if(f){return}f=!0;if(u()){window.console.log("Not starting Moodle session timeout warning in this iframe.");return}window.console.log("Starting Moodle session timeout warning.");t()},w=function(a,b,c){if(f){window.console.warn("Ignoring session keep-alive. The core/network module was already initialised.");return}f=!0;if(u()){window.console.warn("Ignoring session keep-alive in this iframe inside another Moodle page.");return}window.console.log("Starting Moodle session keep-alive.");h=1e3*a;j=c;i=1e3*b;t()};return{keepalive:w,init:v}});
|
|
//# sourceMappingURL=network.min.js.map
|