1 2// Google Identity Services client id, printed on this script's tag by alogin.inc.php. 3// Read at load time: document.currentScript is null inside later callbacks. 4var googleClientId = (function(){ 5 var s = document.currentScript || $('script[data-google-client-id]').get(0); 6 return s ? (s.getAttribute('data-google-client-id') || '') : ''; 7})(); 8 9var adminLogin = function(event){ 10 e = event || window.event; 11 if (e.shiftKey && e.keyCode == 113) { 12 adminLoginDialog(); 13 } 14}; 15 16var adminLoginDialog = function(){ 17 if( $('#adminLoginDialog').length ) { 18 $('#adminLoginDialog').dialog('destroy'); 19 $('#adminLoginDialog').remove(); 20 return; 21 } 22 $('<div id="adminLoginDialog" title="'+jslang.login+'"/>').appendTo('body') 23 .load('/cms/alogin/alogin.dialog.php', function(){ 24 $(this).dialog({ 25 modal: true, 26 width: 350, 27 resizable: false, 28 // The password Login button ({ text: jslang.login, click: doLogin }) is dropped with the 29 // hidden password fields in alogin.dialog.php; doLogin below is kept as the fallback. 30 buttons: [ 31 { text: jslang.cancel, click: function(){ $(this).dialog('destroy'); $('#adminLoginDialog').remove(); } } 32 ] 33 }); 34 renderGoogleSignin($('#adminLoginDialog .google-signin').get(0)); 35 }); 36}; 37 38// The dialog is inserted dynamically, so the GIS data-attribute auto-render does not fire: 39// use the JS API instead. The GIS script is loaded by alogin.inc.php (async). 40var renderGoogleSignin = function(el){ 41 if(!el) return; 42 if(googleClientId == ''){ 43 $('#adminLoginDialog .alert').html('Google sign-in is not configured').show(); 44 return; 45 } 46 if(!(window.google && google.accounts && google.accounts.id)){ 47 $('#adminLoginDialog .alert').html('Google sign-in is still loading, try again').show(); 48 return; 49 } 50 google.accounts.id.initialize({client_id: googleClientId, callback: googleLoginCallback}); 51 google.accounts.id.renderButton(el, {type: 'standard', size: 'large'}); 52}; 53 54// GIS callback, shared by the /login page (data-callback on #g_id_onload in cms/login.inc.php) 55// and the dialog (initialize() above). Posts the ID token for server-side verification. 56window.googleLoginCallback = function(response){ 57 var $err = $('#adminLoginDialog .alert'); 58 if(!$err.length) $err = $('#googleLoginError'); 59 $err.hide(); 60 $.post('/cms/alogin/google.login.ajax.php', {credential: response.credential}, 61 function(res){ 62 if(res != 'ok'){ 63 $err.html(res).show(); 64 } else if($('#g_id_onload').length) { 65 document.location.href = '/'; // the /login page has nothing to reload into 66 } else { 67 document.location.reload(); 68 } 69 }); 70}; 71 72var doLogin = function(){ 73 $('#adminLoginDialog .alert').html('').hide(); 74 var login = $('#adminlogin').val(); 75 var pswd = $('#pswd').val(); 76 if(login == '' || pswd == '') return; 77 $.post('/cms/alogin/alogin.ajax.php', 78 {login:login, pswd:pswd}, 79 function(res){ 80 if(res != 'ok'){ 81 $('#adminLoginDialog .alert').html(res).show(); 82 } else { 83 document.location.reload(); 84 } 85 }); 86}; 87 88$(function(){ $(document).on("keydown", adminLogin); });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.