I'm debugging a problem with my Meteor application, when using IE8, IE9.
When using Chrome or Safari i haven't this problem:
In Ie errors:
"Template" is undefined.
"Meteor" is undefined.
If i wrap all templates from my files in 'if':
if (Meteor.isClient) {my Template code};
or if it is server code:
if (Meteor.isServer) {my Template code};
It work in ie9, but not in ie8.
I think Meteor create my templates in it's template, such as:
my code:
if (Meteor.isClient) {
Template.default.rendered = function () {
$(window).resize(function () {
myFunction();
});
}
}
Meteor wrap my template and in ie8 i can see my template and this:
(function () {
Template.__define__("default", (function () {
var self = this;
var template = this;
return [ Spacebars.include(self.lookupTemplate("navbar")), "\n\n ", HTML.DIV({
"class": "content-wrapper"
}, "\n ", HTML.DIV({
"class": "container"
}, "\n\n ", Spacebars.include(self.lookupTemplate("yield")), "\n\n "), "\n "), "\n\n ", Spacebars.include(self.lookupTemplate("footer")) ];
}));
})();
In application use libraries iron-router, nvd3js, bootstrap-3. may be it is their errors, but a think it is Meteors error. I'm use Meteor 0.8.0.
If my meteor application can work with ie8-9 - please, say me! And if you can - say how? I'm will be very thankful!
This usually happens when some other error causes the rest of the Meteor Javascript not to load properly. You should examine the first error that is printed out in the console, which is almost always the culprit.
If you can update your question with the whole error log, I can update my answer with the diagnosis.
Related
I'm trying to add push messaging to my service worker and facing issue that is eluding me since last night.
In my main HTML file, I have the following -
<script>
if('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js', {scope: '/pwa/'}).then(registration => {
console.log('Service Worker Registered: ', registration);
registration.pushManager.subscribe({userVisibleOnly:true});
});
})
}
</script>
I do get "Service Worker Registered" message on the console. Which means the registration is successful. Chrome however follows it with following line that doesn't say anything about the error -
Uncaught (in promise) DOMException (index):1
Clicking on the (index):1 takes me to the top of corresponding page /pwa/, and highlights the <!DOCTYPE html>.
It does not give me any meaningful information to investigate the issue further.
Would appreciate if you could guide me in fixing this issue. I'll paste the rest of my code and setup below.
Backend framework: Laravel.
Entry in my webpack.mix.js
const workboxPlugin = require('workbox-webpack-plugin');
mix.webpackConfig({
plugins: [
new workboxPlugin.InjectManifest({
swSrc: 'public/service-worker-offline.js', // more control over the caching
swDest: 'service-worker.js', // the service-worker file name
importsDirectory: 'service-worker-assets' // have a dedicated folder for sw files
})
],
output: {
publicPath: '' // Refer: https://github.com/GoogleChrome/workbox/issues/1534
}
});
Entry in my service-worker-offline.js -
workbox.skipWaiting();
workbox.clientsClaim();
// some other entries, followed by
self.addEventListener('push', (event) => {
const title = 'Aha! Push Notifications with Service Worker';
const options = {
'body' : event.data.text()
};
event.waitUntil(self.registration.showNotification(title, options))
});
I look forward to your responses and thank you in advance for your help.
Addendum:
I did further investigation and found out that if I do -
Notification.requestPermission().then(function(permission) {
registration.pushManager.subscribe({userVisibleOnly: true});
})
then the push notification works; but the error still remains. However, the error now points to registration.pushManager.subscribe({userVisibleOnly: true}); line in the JS. What could be the reason?
The DOMException has details that are not always visible. Catch your DOMException, and make sure to log the message to the console. It will generally be much more informative. In my case, the "Registration failed - permission denied" message reminded me that I had blocked all notifications in my chrome settings.
If you are using react, fix serviceWorker.unregister () with serviceWorker.register () in index.js. I solved it like this
I am creating a VSCode Extension.
I have added MSTranslator as a node module because I want to call the Microsoft Translator API
but when I run the example either nothing happens,
or I get a Error Connect EACCES. I get this error 2 or 3 times but now it has stopped returning anything, it just jumps the code and continues
I am running this on a MacBook
if (!api_key) {
console.log('missing api_key');
}
var params = {
text: 'How\'s it going?',
from: 'en',
to: 'es'
};
var client = new MsTranslator({ api_key: api_key });
client.initialize_token(function (err) {
if (err) {
console.log("initialize_token", err);
return;
}
client.translate(params, function (err, data) {
if (err) console.log('error:' + err.message);
console.log(data);
process.exit();
});
});
and when it enters client.initialize_token it reaches this line in MsTranslator and does nothing, just jumps out of function.
var req = https.request(self.options, function(res) {
My Radio Silence firewall is switched off, and the network monitor shows no activity.
If I call the same URL using the same details in self.options using Postman, I get back a token as expected.
Is there a problem running https.request within a VSCode extension, or do I have a different problem?
I reworked the "Clip to DEVONthink" to use in Opera 15+. The problem I'm left with is that the extension only works after a browser restart.
Update 1: Tested on Mac OS X 10.9.2 with Opera 21.0.1432.67, Opera Next 22.0.1471.40 and Google Chrome 35.0.1916.114. They all behave the same.
Update 2: Opera's own example for message passing got the same behavior. I'm left with the question if that's the expected behavior.
There's a background script defined in manifest.json:
"background": {
"scripts": [ "main.js" ]
},
and a content script:
"content_scripts": [ {
"js": [ "add_listener.js" ],
"matches": [ "http://*/*", "https://*/*" ],
}],
... and in main.js in chrome.browserAction.onClicked.addListener a message is send to the content script to request page title & content, etc.
chrome.browserAction.onClicked.addListener(
function (tab) {
chrome.tabs.sendMessage(tab.id, {line: 'getdevonthinkurl' });
}
);
... and the content script sends a message back:
chrome.runtime.onMessage.addListener(
function (request, sender){
if (request.line=='getdevonthinkurl'){
chrome.runtime.sendMessage({devonthinkurl:getDEVONthinkURL()});
}
}
);
... and that message is received by the main.js background script:
chrome.runtime.onMessage.addListener(
function (request, sender) {
if (request.devonthinkurl){
chrome.tabs.update(sender.tab.id, {"url": request.devonthinkurl});
}
}
);
As mentioned above it works perfect after a browser restart but it don't understand why it won't work without.
Does anyone have got an idea (I may add I'm not strong at programming and there's maybe an fundamental flaw in the design)?
The only thing which comes to my mind is that you reloading extension, but just after this step you are not refreshing page where content script is injected. Is there any error in background page? I tried several times and it works for me. Anyway you can use callback in message which can be more readable.
So main.js can look like:
chrome.browserAction.onClicked.addListener(function (tab) {
chrome.tabs.sendMessage(tab.id, {line: 'getdevonthinkurl'},
function(response){
chrome.tabs.update(tab.id, {'url': request.devonthinkurl});
});
});
And add_listener.js like this:
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse){
if (request.line=='getdevonthinkurl'){
sendResponse({devonthinkurl:getDEVONthinkURL()});
}
}
);
We are using Cordova 3.4.0 to develop an app. Everything works fine on Android and iOS and also if we launch our app in a desktop browser. But we are stuck with really strange issue on Windows Phone 8.1.
Here is a simplified code example to test.
index.html in the application root:
<!DOCTYPE html>
<html>
<head>
<title>Mobile sandbox</title>
<meta charset="UTF-8">
<script type="text/javascript" src="libs/jquery/jquery.min.js"></script>
</head>
<body>
<div id="redbox" style="width:100px;height:100px;background-color:red;">
</div>
<div id="greenbox" style="width:100px;height:100px;background-color:green;">
</div>
<script>
$(function () {
alert("Requesting data for redbox...");
$.ajax("test/redText.html")
.done(function (text) {
alert("Filling redbox with contents " + text);
$("#redbox").html(text);
})
.fail(function () {
alert("Error in redbox");
})
.always(function () {
alert("Complete redbox");
});
alert("Requesting data for greenbox...");
$.ajax("test/greenText.html")
.done(function (text) {
alert("Filling greenbox with contents " + text);
$("#greenbox").html(text);
})
.fail(function () {
alert("Error in greenbox");
})
.always(function () {
alert("Complete greenbox");
});
});
</script>
</body>
</html>
test/greenText.html:
<span>GREEN</span>
test/redText.html:
<span>RED</span>
The only dependency to run this test is jQuery which we have put in libs/jquery/ folder.
Now, if we run this code in every desktop browser and in iOS and Android, no matter if from local folder (with browser flags for local AJAX) or from server, we get the right sequence of alerts and AJAX loads correct data in appropriate boxes:
Requesting data for redbox...
Requesting data for greenbox...
Filling redbox with contents <span>RED</span>
Complete redbox
Filling greenbox with contents <span>GREEN</span>
Complete greenbox
We get the same result if we run the index.html on Windows Phone through its Internet Explorer.
But when we deploy the same code to Windows Phone as Cordova app, strange thing happens. The redbox request never receives any data, nor any errors. The greenbox request receives data of redbox, and thus we have empty red box and green box with text "RED" in it.
Here is the sequence of alerts:
Requesting data for redbox...
Requesting data for greenbox...
Filling greenbox with contents <span>RED</span>
Complete greenbox
What's going on there, why one AJAX request does not return and the other receives wrong response? How do we fix it?
EDIT 1:
Our nest step will be to find out if it's Cordova specific issue (I see there is some XHRHelper object in the Corodva WP8 template) or it's Microsoft's phone:WebBrowser fault.
EDIT 2:
It seems, WebBrowser itself does not support AJAX requests to local files (I got "Access denied") and that's why Cordova invented XHRHelper class. But I found a related bugreport which they closed as "Cannot reproduce":
https://issues.apache.org/jira/browse/CB-4873
Is there any Cordova developer here who could suggest a fix for XHRHelper, so it supports multiple sequential AJAX requests?
Again, I cannot reproduce your results. I quickly put together a version which I will post to the JIRA issue: https://issues.apache.org/jira/browse/CB-4873
Requesting data for redbox...
Requesting data for greenbox...
Filling redbox with contents
<span>REd</span>
Complete redbox
Filling greenbox with contents
<span>GREEN</span>
Complete greenbox
I modified your source a little just to make sure there were no issues with alert interfering ...
var eventLog = [];
var oneDone = false;
$(function () {
eventLog.push("Requesting data for redbox...");
$.ajax("redText.html")
.done(function (text) {
eventLog.push("Filling redbox with contents " + text);
$("#redbox").html(text);
})
.fail(function (e) {
eventLog.push("Error in redbox" + JSON.stringify(e));
})
.always(function () {
eventLog.push("Complete redbox");
if (oneDone) {
console.log(eventLog.join("\n"));
alert(eventLog.join("\n"));
}
else {
oneDone = true;
}
});
eventLog.push("Requesting data for greenbox...");
$.ajax("greenText.html")
.done(function (text) {
eventLog.push("Filling greenbox with contents " + text);
$("#greenbox").html(text);
})
.fail(function () {
eventLog.push("Error in greenbox");
})
.always(function () {
eventLog.push("Complete greenbox");
if (oneDone) {
console.log(eventLog.join("\n"));
alert(eventLog.join("\n"));
}
else {
oneDone = true;
}
});
});
I have been trying to setup custom ajaxTransports for jQuery to short-circuit some workflows in certain scenarios for our product. However, I have had zero success in getting these transports to be honored (whereas I have many working custom ajaxPrefilters).
Tested with multiple versions of jQuery:
1.5.2
1.6.4
1.7.2
1.8.0
Tested with multiple browsers:
Firefox 15
Chrome 21
iOS 5 webviews
...
None of them worked.
JsFiddle test case: http://jsfiddle.net/PVYut/
...
If I add a dataType to narrow it down, then it works fine.
JsFiddle test case: http://jsfiddle.net/PVYut/1/
...
Am I just doing something all wrong? I'd be happy to be told so, so long as I can get this working! -_-
$.ajaxTransport("+*", function(options, originalOptions, jqXHR, headers, completeCallback ) {
console.log("Executing ajaxTransport");
return {
send: function( headers, completeCallback ) {
completeCallback(404, "error", {});
},
abort: function() {
/* abort code */
}
}
});
$.ajax("?jqTrans=" + (+(new Date())))
.done(function() {
console.log("ERROR: Should not have been successful!");
})
.fail(function() {
console.log("SUCCESS: Should have failed.");
});
Here is jsFiddle