mirror of https://github.com/status-im/codimd.git
Optimize finishView selector performance by avoid using universal selector, fix finishView code indentation and remove empty line
This commit is contained in:
parent
843f025cb5
commit
eb724b05a7
|
@ -218,12 +218,12 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//youtube
|
//youtube
|
||||||
view.find(".youtube.raw").removeClass("raw")
|
view.find("div.youtube.raw").removeClass("raw")
|
||||||
.click(function () {
|
.click(function () {
|
||||||
imgPlayiframe(this, '//www.youtube.com/embed/');
|
imgPlayiframe(this, '//www.youtube.com/embed/');
|
||||||
});
|
});
|
||||||
//vimeo
|
//vimeo
|
||||||
view.find(".vimeo.raw").removeClass("raw")
|
view.find("div.vimeo.raw").removeClass("raw")
|
||||||
.click(function () {
|
.click(function () {
|
||||||
imgPlayiframe(this, '//player.vimeo.com/video/');
|
imgPlayiframe(this, '//player.vimeo.com/video/');
|
||||||
})
|
})
|
||||||
|
@ -253,7 +253,7 @@ function finishView(view) {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
}
|
}
|
||||||
//mathjax
|
//mathjax
|
||||||
var mathjaxdivs = view.find('.mathjax.raw').removeClass("raw").toArray();
|
var mathjaxdivs = view.find('span.mathjax.raw').removeClass("raw").toArray();
|
||||||
try {
|
try {
|
||||||
if (mathjaxdivs.length > 1) {
|
if (mathjaxdivs.length > 1) {
|
||||||
MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs]);
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs]);
|
||||||
|
@ -264,7 +264,7 @@ function finishView(view) {
|
||||||
}
|
}
|
||||||
} catch (err) {}
|
} catch (err) {}
|
||||||
//sequence diagram
|
//sequence diagram
|
||||||
var sequences = view.find(".sequence-diagram.raw").removeClass("raw");
|
var sequences = view.find("div.sequence-diagram.raw").removeClass("raw");
|
||||||
sequences.each(function (key, value) {
|
sequences.each(function (key, value) {
|
||||||
try {
|
try {
|
||||||
var $value = $(value);
|
var $value = $(value);
|
||||||
|
@ -285,7 +285,7 @@ function finishView(view) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//flowchart
|
//flowchart
|
||||||
var flow = view.find(".flow-chart.raw").removeClass("raw");
|
var flow = view.find("div.flow-chart.raw").removeClass("raw");
|
||||||
flow.each(function (key, value) {
|
flow.each(function (key, value) {
|
||||||
try {
|
try {
|
||||||
var $value = $(value);
|
var $value = $(value);
|
||||||
|
@ -308,7 +308,7 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
//graphviz
|
//graphviz
|
||||||
var Viz = require("viz.js");
|
var Viz = require("viz.js");
|
||||||
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
|
var graphvizs = view.find("div.graphviz.raw").removeClass("raw");
|
||||||
graphvizs.each(function (key, value) {
|
graphvizs.each(function (key, value) {
|
||||||
try {
|
try {
|
||||||
var $value = $(value);
|
var $value = $(value);
|
||||||
|
@ -323,7 +323,6 @@ function finishView(view) {
|
||||||
console.warn(err);
|
console.warn(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//mermaid
|
//mermaid
|
||||||
var mermaids = view.find("div.mermaid.raw").removeClass("raw");
|
var mermaids = view.find("div.mermaid.raw").removeClass("raw");
|
||||||
mermaids.each(function (key, value) {
|
mermaids.each(function (key, value) {
|
||||||
|
@ -370,7 +369,7 @@ function finishView(view) {
|
||||||
$(value).closest("blockquote").css('border-left-color', $(value).attr('data-color'));
|
$(value).closest("blockquote").css('border-left-color', $(value).attr('data-color'));
|
||||||
});
|
});
|
||||||
//slideshare
|
//slideshare
|
||||||
view.find(".slideshare.raw").removeClass("raw")
|
view.find("div.slideshare.raw").removeClass("raw")
|
||||||
.each(function (key, value) {
|
.each(function (key, value) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -392,7 +391,7 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//speakerdeck
|
//speakerdeck
|
||||||
view.find(".speakerdeck.raw").removeClass("raw")
|
view.find("div.speakerdeck.raw").removeClass("raw")
|
||||||
.each(function (key, value) {
|
.each(function (key, value) {
|
||||||
var url = 'https://speakerdeck.com/oembed.json?url=https%3A%2F%2Fspeakerdeck.com%2F' + encodeURIComponent($(value).attr('data-speakerdeckid'));
|
var url = 'https://speakerdeck.com/oembed.json?url=https%3A%2F%2Fspeakerdeck.com%2F' + encodeURIComponent($(value).attr('data-speakerdeckid'));
|
||||||
//use yql because speakerdeck not support jsonp
|
//use yql because speakerdeck not support jsonp
|
||||||
|
@ -424,7 +423,7 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//pdf
|
//pdf
|
||||||
view.find(".pdf.raw").removeClass("raw")
|
view.find("div.pdf.raw").removeClass("raw")
|
||||||
.each(function (key, value) {
|
.each(function (key, value) {
|
||||||
var url = $(value).attr('data-pdfurl');
|
var url = $(value).attr('data-pdfurl');
|
||||||
var inner = $('<div></div>');
|
var inner = $('<div></div>');
|
||||||
|
@ -434,7 +433,7 @@ function finishView(view) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//syntax highlighting
|
//syntax highlighting
|
||||||
view.find("pre > code.raw").removeClass("raw")
|
view.find("code.raw").removeClass("raw")
|
||||||
.each(function (key, value) {
|
.each(function (key, value) {
|
||||||
var langDiv = $(value);
|
var langDiv = $(value);
|
||||||
if (langDiv.length > 0) {
|
if (langDiv.length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue