define([], () => { 'use strict'; class StartModule { } StartModule.prototype.preview = function(blob) { var reader = new FileReader(); var url; if (blob) { reader.onload = function(e) { url = window.URL.createObjectURL(blob); console.log("url is"); console.log(url); document.getElementById("navigation-bar-avatar").src = url; }; reader.readAsDataURL(blob); } }; StartModule.prototype.TruncateUserName = function(Username) { Username = Username.slice(2); console.log(Username); return Username; }; StartModule.prototype.GetInitials = function(Fullname) { var initials = Fullname.match(/\b\w/g) || []; initials = ((initials.shift() || '') + (initials.pop() || '')).toUpperCase(); console.log(initials); return initials; }; StartModule.prototype.ClearImage = function() { document.getElementById("navigation-bar-avatar").src = ''; }; StartModule.prototype.spinnerOn = function() { $("#vb-spinner").css("display", "block"); $("#vb-spinner").show(); // working $("#myDiv").hide(); }; /** * Handler for PWA 'Add' button click on PWA 'add to home screen' popup * @return {Promise} */ StartModule.prototype.addPWA = function (installPromptEventPayload){ // First close the popup through synchronous call document.getElementById('pwaAddToHomeScreen').close(); var installPromptEvent = installPromptEventPayload.getInstallPromptEvent(); if (installPromptEvent) { // Call prompt() to display the official prompt installPromptEvent.prompt().catch(function() {}); // Wait for the user to respond to the prompt return installPromptEvent.userChoice.then(function(choiceResult) { if (choiceResult.outcome === 'accepted') { console.log('user accepted the A2HS prompt'); return false; } console.log('user cancelled the A2HS prompt'); // Don't ask the user again return true; }); } return Promise.resolve(false); }; return StartModule; });