Untitled
unknown
javascript
2 years ago
3.7 kB
8
Indexable
# In Dashboard.controller.js - just replace this function with the current one onPressOcr: function () { var that = this; var list = { "data": [] }; this.getView().setModel(new sap.ui.model.json.JSONModel(list), "listData"); function onSuccess(imageData) { function onDeviceReady() { function onDeviceReadySuccess(recognizedText) { if (recognizedText.words.wordtext.length === 1) { var equipmentNo = recognizedText.words.wordtext[0].toUpperCase(); var onDataReceived = { success: function (oData, oResponse) { var isFuncLoc = false; that.ShowEquipmentDetailsWithId(equipmentNo, isFuncLoc); }.bind(that), error: function (oData, oResponse) { if (oData.statusCode === "404") { that.searchFuncLocWithId(equipmentNo); } else { that.errorCallBackShowInPopUp(); } }.bind(that) }; that.getView().getModel().read("/EquipmentsSet('" + equipmentNo + "')", onDataReceived); } else { var listModel = that.getView().getModel("listData"); recognizedText.words.wordtext.forEach(function (word) { listModel.getProperty("/data").push({ text: word.toUpperCase() }); }); that.getView().setModel(new sap.ui.model.json.JSONModel(list), "listData"); if (!that._ocrTextPopover) { that._ocrTextPopover = sap.ui.xmlfragment("OcrPopover", "com.twobm.mobileworkorder.components.dashboard.fragments.OcrSelectTextPopover", that); that.getView().addDependent(that._ocrTextPopover); } that._ocrTextPopover.open(); } } function onDeviceReadyFail(message) { sap.m.MessageToast.show("OCR failed: " + message); } mltext.getText(onDeviceReadySuccess.bind(this), onDeviceReadyFail.bind(this) ,{imgType : 0, imgSrc : imageData}); } document.addEventListener("deviceready", onDeviceReady, false); } function onFail(message) { sap.m.MessageToast.show("OCR failed: " + message); } navigator.camera.getPicture(onSuccess, onFail, { quality: 100, correctOrientation: true }); }, # In StructureBrowser.controller.js - also replace onPressOcr: function () { var that = this; var list = { "data": [] }; this.getView().setModel(new sap.ui.model.json.JSONModel(list), "listData"); navigator.camera.getPicture(onSuccess, onFail, { quality: 100, correctOrientation: true }); function onSuccess(imageData) { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { mltext.getText(onSuccess.bind(this), onFail.bind(this) ,{imgType : 0, imgSrc : imageData}); function onSuccess(recognizedText) { if (recognizedText.words.wordtext.length === 1) { var searchString = recognizedText.words.wordtext[0]; that.getView().byId("searchField").setValue(searchString); that.searchStructure(searchString); return; } else { var listModel = that.getView().getModel("listData"); recognizedText.words.wordtext.forEach(function (word) { listModel.getProperty("/data").push({ text: word }); }); that.getView().setModel(new sap.ui.model.json.JSONModel(list), "listData"); if (!that._ocrTextPopover) { that._ocrTextPopover = sap.ui.xmlfragment("OcrPopoverStructures", "com.twobm.mobileworkorder.components.structureBrowser.fragments.OcrSelectTextPopover", that); that.getView().addDependent(that._ocrTextPopover); } that._ocrTextPopover.open(); } } function onFail(message) { console.log("OCR failed: " + message); } } } function onFail(message) { console.log("OCR failed: " + message); } },
Editor is loading...