This file contains hidden or 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
// Settings in here override those in "Default/Preferences.sublime-settings", and | |
// are overridden in turn by file type specific settings. | |
{ | |
"font_size": 11, | |
"tab_size": 2, | |
"rulers": [100], | |
"highlight_line": true, | |
"scroll_past_end": false, | |
"trim_trailing_white_space_on_save": true, | |
"default_line_ending": "unix", |
This file contains hidden or 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
// Set the style attribute of e to the string s with either of these lines: | |
e.setAttribute("style", s); | |
e.style.cssText = s; | |
// Query the inline style string of the element e with either of these: | |
s = e.getAttribute("style"); | |
s = e.style.cssText; |
This file contains hidden or 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
<audio id="a" controls> | |
<source src="http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3" type="audio/mpeg"> | |
</audio> | |
<script> | |
var a = document.getElementById('a'); | |
var playFix = false; | |
var playFixRequired = true; | |
a.addEventListener('play', function() { | |
if (playFixRequired) { |
This file contains hidden or 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
/* | |
* Return the classList property of e, if it has one. | |
* Otherwise, return an object that simulates the DOMTokenList API for e. | |
* The returned object has contains(), add(), remove(), toggle() and toString() | |
* methods for testing and altering the set of classes of the element e. | |
* If the classList property is natively supported, the returned object is | |
* array-like and has length and array index properties. The simulated | |
* DOMTokenList is not array-like, but has a toArray() method that returns | |
* a true-array snapshot of the element's class names. | |
*/ |
This file contains hidden or 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
function getSelectedText() { | |
if (window.getSelection) // The HTML5 standard API | |
return window.getSelection().toString(); | |
else if (document.selection) // This is the IE-specific technique. | |
return document.selection.createRange().text; | |
} |
This file contains hidden or 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
function append(content, element) { | |
var element = element || document.body; | |
element.appendChild(content); | |
} | |
function prepend(content, element) { | |
var element = element || document.body; | |
var firstNode = element.firstChild; | |
element.insertBefore(content, firstNode); | |
} | |
function replaceWith(newNode, oldNode) { |
This file contains hidden or 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
function outerHTML(node) { | |
if(node.outerHTML) return node.outerHTML; | |
var container = document.createElement("div"); | |
container.appendChild(node.cloneNode(true)); | |
return container.innerHTML; | |
} |
This file contains hidden or 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
function html(element, htmlContent) { | |
if(htmlContent === undefined) { | |
return element.innerHTML; | |
} else { | |
element.innerHTML = htmlContent; | |
} | |
} | |
function text(element, value) { | |
var content = element.textContent; | |
if (value === undefined) { |
This file contains hidden or 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
function hasAttribute(e, a) { | |
if(e.hasAttribute) return e.hasAttribute(a); | |
var fixAttr = { | |
tabindex: 'tabIndex', | |
readonly: 'readOnly', | |
'for': 'htmlFor', | |
'class': 'className', | |
maxlength: 'maxLength', | |
cellspacing: 'cellSpacing', | |
cellpadding: 'cellPadding', |
This file contains hidden or 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
function attr(e, n, v) { | |
var fixAttr = { | |
tabindex: 'tabIndex', | |
readonly: 'readOnly', | |
'for': 'htmlFor', | |
'class': 'className', | |
maxlength: 'maxLength', | |
cellspacing: 'cellSpacing', | |
cellpadding: 'cellPadding', | |
rowspan: 'rowSpan', |