1 2/* 3 * Helper function for converting an object into a query string for use in URLs 4 */ 5function formatUrlForRequest(baseUrl, params) { 6 try { 7 if (!baseUrl || !params) { 8 return false; 9 } 10 var formattedUrl = baseUrl; 11 var queryString = ''; 12 Object.keys(params).forEach(function (key, index) { 13 var value = encodeURIComponent(params[key]); 14 if (queryString && index != 0) { 15 queryString += '&'; 16 } 17 queryString += key + '=' + value; 18 }); 19 20 if (!queryString) { 21 return false; 22 } else { 23 if (formattedUrl.split('?')[1]) { 24 formattedUrl += '&' + queryString; 25 } else { 26 formattedUrl += '?' + queryString; 27 } 28 return formattedUrl; 29 } 30 } catch (error) {} 31} 32 33$(document).off('click.IDme.Custom.Button').on('click.IDme.Custom.Button','button[name="IDme-custom-button"]', function(event) { 34 event.preventDefault(); 35 var $idmeButton = $('#idme-wallet-button'); 36 if ($idmeButton) { 37 var scope = $idmeButton.attr('data-scope'); 38 var multiGroup = scope.indexOf(',') > -1; 39 var authorizeUrl = multiGroup ? 'https://groups.id.me/' : 'https://api.id.me/oauth/authorize'; 40 var params = { 41 client_id: $idmeButton.attr('data-client-id'), 42 redirect_uri: $idmeButton.attr('data-redirect'), 43 response_type: 'code' 44 } 45 if (multiGroup) { 46 params.scopes = scope; 47 } else { 48 params.scope = scope; 49 } 50 var isPopup = $idmeButton.attr('data-display'); 51 var formattedUrl = decodeURIComponent(formatUrlForRequest(authorizeUrl, params)); 52 if (formattedUrl) { 53 if (isPopup) { 54 var width = 775; 55 var height = 850; 56 var left = (window.innerWidth - width) / 2; 57 var top = (window.innerHeight - height) / 2; 58 // open ID.me login in popup 59 window.open(formattedUrl, '_blank', 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top); 60 } else { 61 // navigate to ID.me login 62 window.location.href = formattedUrl; 63 } 64 } 65 } 66}); 67 68 69 70
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.