Added sanitizer extension

This commit is contained in:
benweet 2014-05-28 00:34:49 +01:00
parent 3ccc267028
commit 580fd66b15
2 changed files with 250 additions and 205 deletions

View File

@ -20,6 +20,7 @@ define([
var modifiedSections = [];
var insertBeforeSection;
var fileChanged = false;
function updateSectionList() {
var newSectionList = [];
var newLinkDefinition = '\n';
@ -111,6 +112,7 @@ define([
var footnoteContainerElt;
var previewContentsElt;
function refreshSections() {
// Remove outdated sections
@ -121,6 +123,7 @@ define([
var wmdPreviewElt = document.getElementById("wmd-preview");
var childNode = wmdPreviewElt.firstChild;
function createSectionElt(section) {
var sectionElt = crel('div', {
id: 'wmd-preview-section-' + section.id,
@ -166,7 +169,8 @@ define([
elt.textContent = index + 1;
var id = elt.id.substring(6);
usedFootnoteIds.push(id);
footnoteElts.appendChild(footnoteMap[id].cloneNode(true));
var footnoteElt = footnoteMap[id];
footnoteElt && footnoteElts.appendChild(footnoteElt.cloneNode(true));
});
if(usedFootnoteIds.length > 0) {
// Append the whole footnotes at the end of the document

View File

@ -10,6 +10,47 @@ define([
var utils = {};
utils.msie = (function() {
/**
* IE 11 changed the format of the UserAgent string.
* See http://msdn.microsoft.com/en-us/library/ms537503.aspx
*/
var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
if (isNaN(msie)) {
msie = parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1], 10);
}
return msie;
})();
utils.urlResolve = (function() {
var urlParsingNode = document.createElement("a");
return function urlResolve(url) {
var href = url;
if (utils.msie) {
// Normalize before parse. Refer Implementation Notes on why this is
// done in two steps on IE.
urlParsingNode.setAttribute("href", href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute('href', href);
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
urlParsingNode.pathname : '/' + urlParsingNode.pathname
};
};
})();
// Faster than setTimeout (see http://dbaron.org/log/20100309-faster-timeouts)
utils.defer = (function() {
var timeouts = [];