$(document).delegate("#demoPage", "pageinit", function() { // DOM Ready $("#user-agent").html(navigator.userAgent); loadMostRecentPhoto(); }); Fse.takePictureHold = function(partnerId, partnerType, fnCallBack) { Fse.updateUploadStatus(1); for (var start = 1; start < 10; start++) setTimeout(function () { fnCallBack(); }, 20000); } Fse.getVoiceCommand_archive = function() { $("#getVoiceCommandButton").addClass('ui-disabled'); $("#getVoiceCommandButton").addClass('voice-btn-cancel'); // Pause briefly to make sure the SDK has time to start recording. Later I can add another callback // to let the JS code know for sure when recording has started. setTimeout(function() { $("#voic-cmd-results-socket").html("

Recording...

"); FSEAPI.voice.getCommand( function (results) { //$("#voic-cmd-results-socket").html("

Probable commands, most likely first:

" + JSON.stringify(results) + "

"); //$("#voic-cmd-results-socket").html("

Probable commands, most likely first:

" + results + "

"); document.frmSrchVoice.command.value = results; $("#getVoiceCommandButton").removeClass('ui-disabled'); $("#getVoiceCommandButton").removeClass('voice-btn-cancel'); Fse.submitVoiceCommand(); }, function (failureReason) { $("#voic-cmd-results-socket").html("

Detection failure. Reason:

" + failureReason + "

"); $("#getVoiceCommandButton").removeClass('ui-disabled'); $("#getVoiceCommandButton").removeClass('voice-btn-cancel'); }, { "language" : "en_US", // Default. Could also be "en_GB", "fr_FR", or "de_DE" "recognizerType" : "dictation", // Default. Could also be "search" to optimize for search queries. "detectionType" : "short" // Default. Could also be "long" to record until a long pause. } ) }, 500); } Fse.getVoiceCommand = function() { if( window["FSEAndroid"] ) { var fnCallback = function( results ) { document.frmSrchVoice.command.value = results; $("#getVoiceCommandButton").removeClass('ui-disabled'); Fse.submitVoiceCommand(); } getVoiceCommand( fnCallback ); return; } if (!$("#getVoiceCommandButton").hasClass("recording")) { //$("#getVoiceCommandButton").addClass('voice-btn-cancel'); //$("#getVoiceCommandButton").addClass("recording"); //$("#getVoiceCommandButton .ui-btn-text").html("Cancel"); //$("#voic-cmd-results-socket").html("

Recording...

"); $("#getVoiceCommandButton").addClass("recording"); $("#getVoiceCommandButton .ui-btn-text").html("Connecting"); $("#voic-cmd-results-socket").html("

Please hold...

"); FSEAPI.voice.getCommand( function (results) { $("#getVoiceCommandButton").removeClass('voice-btn-cancel'); $("#getVoiceCommandButton").removeClass("recording"); $("#getVoiceCommandButton .ui-btn-text").html("Enter Voice Command"); $("#voic-cmd-results-socket").html("

Processing Request...

"); /* $("#voic-cmd-results-socket").html("

Probable commands, most likely first:

" + JSON.stringify(results) + "

"); if (results.length > 0) { FSEAPI.voice.speak({ text: "You said, \"" + results[0]+ "\".", // List of voices at http://dragonmobile.nuancemobiledeveloper.com/public/index.php?task=supportedLanguages voice: "Samantha" // Defaults to Samantha. Tom option. }, function(spokenText) { $("#voic-cmd-results-socket").html($("#voic-cmd-results-socket").html() + "

Spoken text: \"" + spokenText + "\"

"); }, function(failureReason) { $("#voic-cmd-results-socket").html($("#voic-cmd-results-socket").html() + "

Speech error: " + failureReason + "

"); }); }*/ document.frmSrchVoice.command.value = results; $("#getVoiceCommandButton").removeClass('ui-disabled'); Fse.submitVoiceCommand(); }, function (failureReason) { $("#getVoiceCommandButton").removeClass('voice-btn-cancel'); $("#getVoiceCommandButton").removeClass("recording"); $("#getVoiceCommandButton .ui-btn-text").html("Enter Voice Command"); if (failureReason.indexOf('cancelled') < 0) { // don't show error if user cancel $("#voic-cmd-results-socket").html("

Detection failure. Reason:

" + failureReason + "

"); } }, { "language" : "en_US", // Default. Could also be "en_GB", "fr_FR", or "de_DE" "recognizerType" : "dictation", // Default. Could also be "search" to optimize for search queries. "detectionType" : "short", // Default. Could also be "long" to record until a long pause. "onRecordingStarted" : function() { //$("#getVoiceCommandButton").addClass("recording"); //$("#getVoiceCommandButton").removeClass('ui-disabled'); //$("#getVoiceCommandButton .ui-btn-text").html("Cancel"); //$("#voiceCommand").html("

Recording...

"); $("#getVoiceCommandButton").addClass('voice-btn-cancel'); $("#getVoiceCommandButton").addClass("recording"); $("#getVoiceCommandButton .ui-btn-text").html("Cancel"); $("#voic-cmd-results-socket").html("

Recording...

"); FSEAPI.sound.play("ding.wav"); } } ) } else { $("#getVoiceCommandButton").removeClass('voice-btn-cancel'); $("#getVoiceCommandButton").removeClass("recording"); $("#getVoiceCommandButton .ui-btn-text").html("Enter Voice Command"); $("#voic-cmd-results-socket").html("

Recording cancelled.

"); FSEAPI.voice.cancelRecording(); } } Fse.takePicture = async function(partnerId, partnerType, fnCallBack, useProduction) { var tempMessage = ""; if ( useProduction == undefined ) { useProduction = 'YES'; } var tempUserAgent = navigator.userAgent.toLowerCase(); var tempCallback = ""; if ( tempUserAgent.includes("_maui") == true && useProduction.toUpperCase() == "YES") { tempCallback = fnCallBack.name; tempMessage = encodeURI("TakePicture^" + partnerId + "^" + partnerType + "^https://www.appslibrary.com/mobileapps/crm/uploadImage.cfm" + "^" + tempCallback); HybridWebView.SendRawMessageToDotNet(tempMessage); return; } if( window["FSEAndroid"] ) { if ( useProduction.toUpperCase() == "YES" ) { takePictureAndUpload( partnerId, partnerType, "https://www.appslibrary.com/mobileapps/crm/uploadImage.cfm", fnCallBack, function( sMessage ) { alert( "takePictureAndUploadFailed: " + sMessage ) } ); } else { takePictureAndUpload( partnerId, partnerType, "http://dev.fsenablers.com/fse/z_appsMaster/mobileapps/crm/uploadImage.cfm", fnCallBack, function( sMessage ) { alert( "takePictureAndUploadFailed: " + sMessage ) } ); } return; } FSEAPI.camera.getPicture( function (fileURL) { if (fileURL) { var options = new FSEAPI.FileUploadOptions(); options.fileKey="photo"; options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); options.mimeType="image/png"; options.fileURL = fileURL; var params = {}; params.partnerId = partnerId; params.partnerType = partnerType; options.params = params; Fse.updateUploadStatus(1); $.mobile.showPageLoadingMsg(); if ( useProduction.toUpperCase() == "YES" ) { var _uploadHandlerURL = 'https://www.appslibrary.com/mobileapps/crm/uploadImage.cfm'; } else { var _uploadHandlerURL = 'http://dev.fsenablers.com/fse/z_appsMaster/mobileapps/crm/uploadImage.cfm'; } var ft = new FSEAPI.FileTransfer(); ft.upload( fileURL, _uploadHandlerURL, function (r) { $.mobile.hidePageLoadingMsg(); if (fnCallBack) { fnCallBack(); } }, function (error) { Fse.updateUploadStatus(-1); $.mobile.hidePageLoadingMsg(); alert("An error has occurred: " + error); }, options ); } else { // User hit cancel. Do nothing. $.mobile.hidePageLoadingMsg(); } }, function (failureReason) { alert("Couldn't get image because: \n" + failureReason); } ) } /*$(document).delegate("#takePictureButton", "tap", function() { FSEAPI.camera.getPicture( function (fileURL) { if (fileURL) { var options = new FSEAPI.FileUploadOptions(); options.fileKey="photo[image]"; options.fileName=fileURL.substr(fileURL.lastIndexOf('/')+1); options.mimeType="image/png"; var params = {}; params.value1 = "test"; params.value2 = "param"; options.params = params; var ft = new FSEAPI.FileTransfer(); ft.upload( fileURL, "http://preview.fsenablers.com/mobile/uploadtest.cfm", function (r) { alert ("Image uploaded successfully."); //loadMostRecentPhoto(); }, function (error) { alert("An error has occurred: " + error); }, options ); } else { // User hit cancel. Do nothing. } }, function (failureReason) { alert("Couldn't get image because: \n" + failureReason); } ) });*/ /* $(document).delegate("#scanBarcodeButton", "tap", function() { FSEAPI.camera.getBarcode( function (barcodeData) { if (barcodeData) { alert("Got barcode: \n" + barcodeData); } }, function (failureReason) { alert("Couldn't get barcode because: \n" + failureReason); } ) }); */ Fse.scanBarcode = function(fnCallBack) { var tempMessage = ""; var returnFunctionName = fnCallBack.name; var tempUserAgent = navigator.userAgent.toLowerCase(); if ( tempUserAgent.includes("_maui") == true ) { tempMessage = encodeURI("ScanBarcode" + "^" + returnFunctionName); HybridWebView.SendRawMessageToDotNet(tempMessage); return; } if( window["FSEAndroid"] ) { // default var fnCallBack2 = function( scanResult ) { alert( "Android Scanned: " + scanResult ); } // default is overridden by caller if( fnCallBack ) { fnCallBack2 = fnCallBack; } scanBarCode( fnCallBack2 ); return; } FSEAPI.camera.getBarcode( function (barcodeData) { if (barcodeData) { if (fnCallBack) { fnCallBack(barcodeData); } } }, function (failureReason) { alert("Couldn't get barcode because: \n" + failureReason); } ) } Fse.rescanBarcode = function(fnCallBack) { var tempMessage = ""; var returnFunctionName = fnCallBack.name; var tempUserAgent = navigator.userAgent.toLowerCase(); if ( tempUserAgent.includes("_maui") == true ) { tempMessage = encodeURI("ReScanBarcode" + "^" + returnFunctionName); HybridWebView.SendRawMessageToDotNet(tempMessage); return; } if( window["FSEAndroid"] ) { // default var fnCallBack2 = function( scanResult ) { alert( "Android Scanned: " + scanResult ); } // default is overridden by caller if( fnCallBack ) { fnCallBack2 = fnCallBack; } scanBarCode( fnCallBack2 ); return; } FSEAPI.camera.getBarcode( function (barcodeData) { if (barcodeData) { if (fnCallBack) { fnCallBack(barcodeData); } } }, function (failureReason) { alert("Couldn't get barcode because: \n" + failureReason); } ) } Fse.scanBarcodehold = function(fnCallBack) { if (fnCallBack) { fnCallBack('1234567890'); } } loadMostRecentPhoto = function() { $.getJSON('/photos.json', function(data) { var items = []; if (data.length > 0) { $('#photoContainer').html(""); } else { $('#photoContainer').html("(No images found)"); } }); }