Log javascript exceptions with Google Analytics
Source: Exception Tracking | Analytics for Web (analytics.js) | Google Developers
My bookmarks and blogposts regarding Software Development in .NET, C#, Angular, JavaScript, CSS, Html
Log javascript exceptions with Google Analytics
Source: Exception Tracking | Analytics for Web (analytics.js) | Google Developers
In this continuation of his series, Sahil focuses on TypeScript and why it’s mandatory if you want to write good, reliable code in JavaScript.
$(function () {
//page is ready
//Prevents users from accidentally submitting form with enter key (e.g. IE problem)
//http://stackoverflow.com/questions/895171/prevent-users-from-submitting-form-by-hitting-enter
$(document).on("keyup keypress", "form input[type='text']", function (e) {
if (e.keyCode === 13 /*enterkey*/ || event.keyCode === 169 /*enter on numpad*/) {
e.preventDefault();
return false;
}
});
});
Works in ajax templated context as well.
Ever wanted a simple overview of your javascript functions in Visual Studio 2013? This extension fixes that.
Especially useful if you use namespacing a lot and wants a simple navigation inside the js file.
Its also a “linter” which tells you about faulty js code.
You can tweak the settings in Visual Studio options:
Here is a little hack to make javascript behave more like .NET with string.format…
usage:
var selector = String.format("#container{0} div.lineItem{1}[data-entryid='{2}']", containerId, itemId, entryId);
js code:
//String.format for js.
if (!String.format) {
String.format = function (format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
This is how you do if/else in Mustache (perfectly supported):
{{#repo}}
I have repos!
{{/repo}}
{{^repo}}
No repos :(
{{/repo}}
via javascript – How do I accomplish an if/else in mustache.js? – Stack Overflow.
“Bookmarkets can be defined as mini applications masquerading as tiny snippets of JavaScript awesomeness that reside in your browser and provide additional functionalities to a web page.
Today, we’re going to look into creating bookmarklets from scratch and on the way, some best practices to follow.”
via Create Bookmarklets – The Right Way – Tuts+ Code Tutorial.