This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Prototypal inheritence</title> | |
</head> | |
<body> | |
<form> | |
<div><button onclick="animal.speak();return false;">animal.speak()</button></div> | |
<div><button onclick="dog.speak();return false;">dog.speak()</button></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 Max Irwin http://www.binarymax.com/ | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Not intended to be fast. | |
var WebVTTCueTextParser = (function(){ // this will return just the WebVTTCueTextParser function and not leak anything else | |
// local scope: | |
var | |
NEWLINE = /\r\n|\r|\n/, | |
SPACE = /[\u0020\t\f]/, | |
NOSPACE = /[^\u0020\t\f]/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// the case: | |
// runner.js | |
module.exports = { | |
arr: [], | |
fetch: function(str){ this.arr.push(str); } | |
}; | |
// mod1.js | |
module.exports = function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = ZeParser.createParser(value); | |
parser.tokenizer.fixValues(); | |
var ide = parser.tokenizer.wtree.map(function(t){ | |
if (t.name == 14) ta.className = 'error'; | |
return '<span class="t'+t.name+'">'+(t.name==13?'\u29e6':(t.name==14?'\u292c':t.value))+'</span>'; | |
}); | |
div.innerHTML = ide.join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parser = ZeParser.createParser(ta.value); | |
parser.tokenizer.fixValues(); | |
var wtree = parser.tokenizer.wtree; | |
ta.className = ''; | |
var ide = wtree.map(function(t){ | |
if (t.name == 14) ta.className = 'error'; | |
return '<span class="t'+t.name+'">'+(t.name==13?'\u29e6':(t.name==14?'\u292c':t.value)).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>')+'</span>'; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var NCA = function(type, version, compiler){ | |
this.type = type; | |
this.version = version; | |
// compiler must have interface method "compile", | |
// which accepts a string as single argument | |
this.compiler = compiler; | |
}; | |
NCA.prototype = { | |
queue: [], | |
fetching: false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// requires ZeParser (see repo) | |
// input is a string, your js input with tagliterals | |
function compile(input){ | |
var tree = []; | |
var tokenizer = new Tokenizer(input); | |
tokenizer.tagLiterals = true; // enable tag literals in the engine | |
var parser = new ZeParser(input, tokenizer, tree); | |
parser.parse(); | |
tokenizer.fixValues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ordered = pieces.slice(i).sort(function(a,b){ | |
var pa = this.distanceBetween(p,a); | |
var pb = this.distanceBetween(p.b); | |
if (pa < pb) return -1; | |
if (pa > pb) return 1; | |
return 0; | |
}.bind(this)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCharPos1: function() { | |
// Get cursor position | |
var charPos = 0; | |
var cursorPos = this.editor.getCursorPosition(); | |
for (var i=0; i<cursorPos.row; i++){ | |
charPos += this.editor.session.$rowLengthCache[i]; // +1 for newline | |
} | |
charPos += cursorPos.column + cursorPos.row; // Add row count to compensate for newlines | |
return charPos; |
OlderNewer