Double arrows on js console log in chrome - google-chrome

I noticed a double arrow console log from the code below in the console. What does this mean? I'm worried that this is a bug and that the data traced is corrupted some how. Does some one know what the double arrow means and Why im getting it?
LoginDispatcher.register(function(payload){
var action = payload.action;
var text;
log.trace(action);
switch(action.actionType) {
case AppConstants.LOGIN:
setUser(action.data);
break;
default:
return true;
}
LoginStore.emitChange();
return true;
});
When inspecting the call it looks allright.
Opening the folding arrows I see the following info

I noticed that this is the default behaviour of the console.log.trace function. So there was nothing wrong.

Related

Is there a way to have a bookmark be created upon clicking a button/link?

I'm trying to figure out if it's possible to make it so that if you click a link or button, a bookmark will be created. Anything that comes up on Google has to do with ebooks, and I can't seem to find anything. If anyone has the answer, it would be a huge help!
function addFavorites(a) {
pageTitle = document.title;
pageURL = document.location;
try {
// Internet Explorer solution
eval("window.external.AddFa-vorite(pageURL, pageTitle)".replace(/-/g, ''));
} catch (e) {
try {
// Mozilla Firefox solution
window.sidebar.addPanel(pageTitle, pageURL, "");
} catch (e) {
// Opera solution
if (typeof(opera) == "object") {
a.rel = "sidebar";
a.title = pageTitle;
a.url = pageURL;
return true;
} else {
// The rest browsers (i.e Chrome, Safari)
alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D to bookmark this page.');
}
}
}
return false;
}
Add to Favorites
Source: https://rudrastyh.com/javascript/favorite-button.html
Be aware of eval()
eval() may be a dangerous function under certain circumstances, which executes the code it's passed with the privileges of the caller.
Get advised by Mozilla.org and use with caution
No, there's no stright forward way for that.
Opera, Google Chrome and Safari do not provide a way to add new elements to the Favorites (Bookmarks) from JavaScript.
There was an API for that however, which is the Window.external API, and I believe it used to work as window.external.AddFavorite() in Internet Explorer, and window.sidebar.addPanel() in Firefox (obsolete, deprecated, i.e. dead, see for the API).
Not sure this info would help, but you might have to create a browser extension for that, then connect your button with your extension, this way you can ensure its stability.
My suggestion is to simply ask the users to bookmark the webpage they're in if that would help to solve the problem you're trying to solve (not sure what you're trying to create).

Show different default page depending on stored value

I am trying to make an windows store app where the default page (first page that comes up when app loads) changes depending on stored value.
I have following files
- js
|- default.js
- default.html
- page_A.html
- page_B.html
default.js has the following code:
if (localStorage["value"] == undefined || localStorage["value"] == "pageA") {
localStorage["value"] = "pageA";
//WinJS.Navigation.navigate("page_A.html");
window.location.assign = "page_A.html";
} else {
localStorage["value"] = "pageB";
//WinJS.Navigation.navigate("page_B.html");
window.location.assign = "page_B.html";
}
WinJS.Navigation code does not work at all. So I tried using window.location and what's happening is instead of loading the actual page, it loads an empty page as shown below.
I tried using both href and assign for windows.location object. What's interesting is that it seems like href and assign loads the page because if I have page_A/B.js associated with pageA/B.html and have a simple console.log statement, then the log statement does get logged, but it does not render the page.
Any ideas? I've been stuck for a while.
Try putting your default.js at the root of your project, next to page_A.html and page_B.html, or, and I don't know if this works, you can try calling those pages with ..\page_X.html.
Also, you can add an error handler function to your navigate in case there's something else going on that you're not seeing.
WinJS.Navigation.navigate('page_A.html', {}).then(function () {
// it worked!
}, function (err){
// something went wrong
});

Windows Phone speech recognition - words that are not in grammar

consider a grammar like this ; speech.Recognizer.Grammars.AddGrammarFromList("answer",new string[] { "Go.","no" });
When I say something else that are not in grammar, she says "sorry didnt catch" and then tries to start it again. Same goes for null input.
What I want is that it should only recognize the words in grammar and for everything else it should just pass the recognition. I don't want to see anything like "sorry didnt catch" and second time recognotion. Any idea ? thanks.
Edit : with try-catch I can avoid from second time recognotion if the word is unknown but now it's waiting too long on "sorry didnt catch" part.
try
{
SpeechRecognizerUI speech = new SpeechRecognizerUI();
speech.Settings.ReadoutEnabled = false;
speech.Settings.ShowConfirmation = false;
speech.Recognizer.Settings.InitialSilenceTimeout = System.TimeSpan.FromSeconds(0.8);
speech.Recognizer.Grammars.AddGrammarFromList("answer", new string[] { "Go.", "no" });
SpeechRecognitionUIResult result = await speech.RecognizeWithUIAsync();
if (result.RecognitionResult.Text == "Go.") { .... }
}
catch
{
..... }
In my opinion, you must build your own UI to avoid this. So you should use SpeechRecognizer and then you can handle the input as you want.
In my case I even created two SpeechRecognizer, on with own Wordlist, the other one with default dictionary. It works like a charm, but I couldn't get it to work with SpeechRecognizerUI.

HTML is not updated when using Mootools dragging

I'm using Mootools (don't think it is related to the problem) to drag and drop and element.
var draggable = new Drag(timeHandle, {
onDrag: function () {
var calculatedTime = calcTime();
$('timeLabel').innerHTML = calculatedTime;
},
});
Basically, I can drag my 'timeHandle' and the 'timeLabel' is getting updated properly.
The problem is that sometimes, after moving the handle a little bit, suddently, the UI is not getting updated. The 'timeHandle' is not moving and the 'timeLabel' is not getting updted.
The problem is not with the drag event, I can see it keeps on getting called.
When I move
$('timeLabel').innerHTML = calculatedTime;
everything works fine.
So, the problem is not with the 'Drag' object since the event is kept on calling.
Looks like some UI performance issue.
Thanks
To simplify your code, you can use Element.set('text', 'my text here');
var element = $('timeLabel');
var draggable = new Drag(timeHandle, {
onDrag: function () {
element.set('text', calcTime());
}
});
Also, remember to remove that last comma or it will throw errors in Internet Explorer.
OK, found a to make it work.
I still not sure what caused the problem but it looks like the 'innerHTML' command has either really poor performance which causes problems in the GUI updates or maybe some kind of internal mechanism (IE only? which is supposed to prevent the UI from updates overflow.
Anyway, instead of using the innerHTML, I'm doing the following:
var draggable = new Drag(timeHandle, {
onDrag: function () {
var calculatedTime = calcTime();
var element = $('timeLabel');
element.removeChild(element.firstChild);l
element.appendChild(element.ownerDocument.createTextNode(calculatedTime));
},
});
Works like a charm

window.onbeforeunload and window.location.href in IE

We are using window.location.href to navigate the user to a page.
Also, we have configured the window.onbeforeunload event to alert users in case there are any unsaved changes.
window.onbeforeunload = confirmBeforeClose;
function confirmBeforeClose() {
if (jwd.global.inEditMode)
return "Your changes will not be saved :) and you will be punished to death";
}
In places where there are unsaved changes, and I try to use window.location.href to navigate the user, I get the alert message.
It works fine if I click OK on the popup. However, if I click CANCEL, the JS throws an unspecified error at window.location.href.
Any help is appreciated.
I was also experiencing this issue (in IE7 and above, not in IE6 however).
The only solution that I could find was wrapping the window.location.href call in a try/catch block.
The below is a complete example that reproduces the problem. If you uncomment out the try/catch then it works as desired in all browsers.
JavaScript (in HTML head):
window.onbeforeunload = confirmBeforeClose;
function confirmBeforeClose( )
{
return 'You have made changes on this page that will be lost if you navigate away without saving.';
}
function leavePage( )
{
// try {
window.location.href = "http://www.example.com";
// } catch( e ) { }
}
HTML:
<body>
Leave this page
</body>