Skip to content

Instantly share code, notes, and snippets.

View hgoebl's full-sized avatar

Heinrich Goebl hgoebl

View GitHub Profile
@hgoebl
hgoebl / gist:7446989
Last active December 28, 2015 04:59
Example code for window.onbeforeunload (not generally usable!) There are two event-handlers for loggedOut and loggedIn.
// App.logout is just a AJAX call doing logout
var App = {
// ...
logout: function () {
return $.ajax({
url: REST.postLogout,
type: 'POST'
});
@hgoebl
hgoebl / gist:1503453
Created December 20, 2011 21:50
handle non-utf8 encoded XML files
case S.PROC_INST_ENDING:
if (c === ">") {
emitNode(parser, "onprocessinginstruction", {
name : parser.procInstName,
body : parser.procInstBody
})
if (parser.procInstName === "xml") {
var match = parser.procInstBody.match(/encoding\s*=\s*['"]([A-Za-z_0-9-]+)['"]/)
if (match) parser.encoding = match[1]
}