Apache Cordova ContactFind - javascript

Okay so for the past two days I've been struggling to get my first Cordova/Eclipse project up and running. I'm trying to retrieve the contacts from my phone, using the ful sample code provided on the Apache Cordova website. http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html
But it's not working. I keep getting this error: "Uncaught ReferenceError: ContactFindOptions". And yes, I have included the needed plugin using the Cordova CLI. I also tried adding it manually, to no avail.
// Cordova is ready
function onDeviceReady() {
// find all contacts with 'Bob' in any name field
var options = **new ContactFindOptions()**;
options.filter="Bob";
var fields = ["displayName", "name"];
navigator.contacts.find(fields, onSuccess, onError, options);
}
I also included the Cordova.js file in my btw. I'm at a complete loss here, and all I can find about this particular problem are more people asking this question, without an answer that works for me :(

It seems I'm supposed to answer my own question instead of putting the answer in the edit.
Okay, so I figured it out by trial and error. Apparently sometimes Cordova doesn't update the Cordova_plugins.js file after adding plugins with the CLI. So you need to run the 'build' command from the project folder in CLI.
So when you get the Uncaught ReferenceError warning, just check your cordova_plugins.js. If it's not updated do it manually!
Hope I can help someone with the same issues by providing this solution, however 'green' it might be.

Related

TypeError: cleanUrl is not a function while creating a React Project

Hey everybody I am getting this error after hosting a website on firebase or I am not sure about it.
It's the replace-info.js screenshot.
I am not able to find the solution on stackoverflow or on other website.
This error had appeared on my side after npm update npm#lastest
What I did to fix it:
Go to AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\lib\index.js.
Add module.exports.cleanUrl = require('./clean-url.js') at the end of the file.
P.S. I just copied it from there https://github.com/npm/npm-registry-fetch/blob/main/lib/index.js

Setting up Sentry (Raven) with Sail.js

I am quiet new to sails.js and currently trying to integrate sentry with it. I read up the following tutorial on it.
https://docs.sentry.io/clients/node/
But i am not able to register error on sentry if i use patchGlobal command, it works on local errors when i declare it env/production file but if i define it in other places it doesn't even register local errors.
I also tried integrating it as a middleware but i am not able to integrate it correctly since the link they have provided is for express.
https://docs.sentry.io/clients/node/integrations/express/
Any help would be really appreciated !
Thanks
This might be a solution to your problem:
https://www.npmjs.com/package/sails-hook-sentry
In the end , i was able to use Winston to log errors using Sentry in Sails. Following is the link:
https://github.com/guzru/winston-sentry

How to integrate tesseract OCR with Cordova/Phonegap app

Im trying use tesseract OCR with my app and by instructions posted here
http://scn.sap.com/community/developer-center/front-end/blog/2015/05/15/create-an-ocr-android-app-with-cordova-and-tesseract
several times I followed the instructions but with no success.When im inspecting code with Google Chrome Dev console thru the WebVieW it give me
Uncaught SyntaxError: Unexpected token }
in file tesseractPlugin.js:11
thats located somewhere in
file:///android_asset/www/plugins/com.tesseract.phonegap/tesseractPlugin/tesseractPlugin.js
and
Uncaught Error: Module com.tesseract.phonegap.tesseractPlugin.TesseractPlugin does not exist.
in cordova.js:1431
witch i think means the cordova cant find the plugin but i dont know why.I think it's something with the version of Cordova and its access to plugins
its frustrating because there are no other options on the web and i dont know how to write my own cordova plugin.
I would also like to add that I created the project exactly as instructed to avoid the mistakes and over I have found that it is not possible to download the plugin by git from
https://github.com/engzhaowei/Tesseract-phonegap-android-example/tree/master/plugins/com.tesseract.phonegap.tesseractPlugin
so i downloaded full package and fetch plugin from
C:\xxx\plugins\com.tesseract.phonegap.tesseractPlugin
There is tessaract js http://tesseract.projectnaptha.com/
which is a javascript library and you can use it and will work for phonegap its very easy to implement.
Just reference the cdn script in the header and call the code snippet it should work. Be warned actress is slow.
<script src='https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/tesseract.js'></script>
var myimage = document.getElementById("largeImage").src;
Tesseract.recognize(myimage)
.then(function(result){
// console.log(result);
document.getElementById("textarea1").value = result.text; // assign results to a textbox

Visual composer doesn't load and gives TypeError: _.template(...).trim is not a function

My visual composer plugin doesn't work. It stuck on the loading page. And it gives an error "TypeError: .template(...).trim is not a function"
Error is on this line of code:
this.$controls = $(.template(template, data, vc.template_options).trim()).addClass('vc_controls');
Please help me to fix this out.
Here is the error which I get:
If you are unable to solve this error by upgrading or downgrading your theme or plugin, you could at least make the below changes.
1. Open the following two files:
wp-content\plugins\js_composer\assets\js\frontend_editor\frontend_editor.js
wp-content\plugins\js_composer\assets\js\frontend_editor\custom_views.js
2. Replace
this.$controls = $( _.template( template, data, vc.template_options ).trim() ).addClass( 'vc_controls' );
with
this.$controls = $( ( "vc.template_options" ).trim() ).addClass( 'vc_controls' );
This will surely work.
Solution Goto file /wp-content/plugins/js_composer_salient/assets/js/dist/backend.min.js around line 4045:
======> Replace the code
html2element: function(html) {
var $template, attributes = {},
template = html;
$template = $(template(this.model.toJSON()).trim()), _.each($template.get(0).attributes, function(attr) {
attributes[attr.name] = attr.value
}), this.$el.attr(attributes).html($template.html()), this.setContent(), this.renderContent()
},
Upgrade to Visual Composer version 4.11.2+
Note Wordpress 4.5 compatibility was fixed on 13th April:
https://wpbakery.atlassian.net/wiki/display/VC/Release+Notes
You should try to fix this by up/downgrading your theme/plugin. But if you, like me, can't solve it this way and just need to do a quick hack to get past this particular problem, the following worked for me.
Edit the following two files:
wp-content\plugins\js_composer\assets\js\frontend_editor\frontend_editor.js
wp-content\plugins\js_composer\assets\js\frontend_editor\custom_views.js
Change a single line in each of them, adding (). Change:
this.$controls = $( _.template( template, data, vc.template_options ).trim() ).addClass( 'vc_controls' );
to:
this.$controls = $( _.template( template, data, vc.template_options )().trim() ).addClass( 'vc_controls' );
As Shady sherif said at Maulik's suggestion, this is what I've changed in 2 places at frontend-editor.min.js and it worked!! Thanks to you both!
Change this:
this.$controls=$(_.template(template,data,_.extend({},vc.template_options,{ evaluate:/\{#([\s\S]+?)#}/g})).trim()).addClass("vc_controls");
With this:
this.$controls=$(("vc.template_options").trim()).addClass("vc_controls");
UPDATE:
in current updates none of this is needed just replace the plugin
I had problem with WPBakery Page Builder in version 6.0.2.
Wordpress: Version 5.2.1
ERROR: Uncaught TypeError: window.vc.frame_window.jQuery is not a function at window.vc.ShortcodesBuilder.buildFromContent (frontend-editor.min.js? Ver = 6.0.2: 10)
     at Object.vc.build (frontend-editor.min.js? ver = 6.0.2: 10)
     at frontend-editor.min.js? ver = 6.0.2: 10
I was reluctant to upgrade, as there might be a bug. (But it is a fact that an update is bug fix)
Since the update to version 6.0.3 was not successful.
Solution:
Mine was restoring the backup of the whole site.
Tip: Never forget Backup.
This article suggests rolling back your worpress version prior to 4.5. http://forums.artbees.net/t/urgent-wordpress-4-5-broken-vc-backend-editor-workaround-fix-in-comments/2734
This is where you can find older versions of wp to install https://wordpress.org/download/release-archive/30
I haven't tried this myself just a suggestion.
If this is still a problem for you I solved this same error I was getting by manually updating my theme through ftp. I downloaded the latest version of the theme because automatic updates were not working. I kept wordpress version 4.5. Here are the steps I took as follows.
I renamed the theme example x-updating once uploaded named the current theme x-previous then changed x-updating to x and deleted x-previous.
I updated js_composer the same way as step 1. Uploaded latest version of js_composer which was bundled with the theme. This is updated in plugins outside the theme. At this point you should be able to update visual composer from the wp dashboard if it hasn't already.
This got vc working again but left me with some weird errors happening in vc_templates vc_column.php file. I had to manually comment out the trouble code to get the errors to go away.
These 3 steps are a little nerve racking if you are not familiar with uploading files directly to your public_html root directory of your website. Some themes may offer support and do the ftp uploading for you if you provide them with ftp username password.
One more thing to do is clear your cache for your website. In chrome you can clear your cache by going to chrome://settings/cookies enter website.com in the search bar and click remove all clearing all locally stored data for your website. Manual updating themes and plugins is recommended only if auto updates aren't possible then you do the above. For my theme and this same exact error in question I followed these really well-done steps https://community.theme.co/kb/updating-your-theme-and-plugins/. However this will be different depending which theme you have. And if you would rather roll back your wp version you can follow my original suggestion. But for me I like to have everything new and up-to-date.
One more important note if you do have this theme then I had to delete x-shortcodes plugin from plugins direcotry of my website because my updated theme uses cornerstone instead of x-shortcodes to process important shortcodes to make vc work properly. Another thing to know is none of your data should be harmed while uploading plugins and themes all the data/content is stored safely in your data-base not in your theme.
I tried the following solutions:
maulik`s (but there was no such files on my plugin folder - frontend_editor.js and custom_views.js, just a "vendors" folder on "/wp-content/plugins/js_composer/assets/js/frontend_editor"),
Amritosh pandey`s solution (does not work even after cache & history cleaning),
Berein`s solution (does not work too).
I solved the problem by using a Amritoshpandey's solution:
https://gist.github.com/levantoan/519bb0d42c9f7bd6c4d78ef1686bb848
("The following code has completely corrected my problems, I can load the page, add, clone, remove, etc")
The Amritoshpandey's code should be pasted in /wp-content/plugins/js_composer/assets/js/dist/backend.min.js instead of:
render:function(){var $shortcode_template_el=$("#vc_shortcode-template-"+this.model.get("shortcode"));if($shortcode_template_el.is("script"))this.html2element(_.template($shortcode_template_el.html(),this.model.toJSON(),vc.templateOptions["default"]));else{var params=this.model.get("params");$.ajax({type:"POST",url:window.ajaxurl,data:{action:"wpb_get_element_backend_html",data_element:this.model.get("shortcode"),data_width:_.isUndefined(params.width)?"1/1":params.width,_vcnonce:window.vcAdminNonce},dataType:"html",context:this}).done(function(html){this.html2element(html)})}return this.model.view=this,this.$controls_buttons=this.$el.find(".vc_controls > :first"),this},
If you have Visual Composer 4.9, just replace these 2 files from archive
- frontend-editor.min.js
- backend.min.js
path: /wp-content/plugins/js_composer/assets/js/dist
Don't forget to make a backup of your files.
https://yadi.sk/d/JH4cbtnH3UoU3F
click "download add"
(tested with VC 4.9 & WP 4.9.5)
I used version 4.10 and upload the file assets/js/frontend-editor.min.js to the same file in 4.12 version.
Note: I keep my version and update only this file. I things this issues risen after update my php version, but i dont sure about that.
That`s work fine.
I get this file here: https://www.downloadfreethemes.io/visual-composer-v5-0-1-page-builder-for-wordpress/
I have theme license.
Replacing file
> wp-content\plugins\js_composer\assets\js\frontend_editor\frontend_editor.js
> wp-content\plugins\js_composer\assets\js\frontend_editor\custom_views.js
is not a solution, you can download cracked version and resolve it:
https://www86.zippyshare.com/v/fguQVId6/file.html
1.Please Deactivate the plugin
2.Delete all the files from plugin folder (js_composer folder)
3.Download the Latest Version of Visual Composer
4.Add new Plugin --> and select the downloaded plugin -->Upload --->Activate

Intel XDK cordova file api 1.3.3 file not found

Simply the issue im calling the file system as :
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory+'/www/icons', function(dirEntry){example=dirEntry}, onError);
and im 100% sure the directory exists in my source folders before building application , but after building application i can see that www/index.html exists but no other folders are found , only when i check particular files like www/img/example.svg cause im sure this will be included as they appear in application preview , and are included in css files , the problem is that i get the following error :
Error occurred during request to file system pointer. Error code is: 1
After lot of searching it appears to be that it is not only who has this issue check this post
a temporary solution is to fall back to old API ver 0.2.5 which works well without this bug , but just in case anyone knows what is going wrong , please provide a clear answer .
It appears to be a bug in 1.3.3 being resolved , for further details check this , and this , just in case anyone is searching for a solution sounds that version 1.3.4 will solve this.

Categories