summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorYukai Huang2016-10-13 08:56:56 +0800
committerYukai Huang2016-10-13 08:56:56 +0800
commit43c9f68b9a67fa7f5b3e5a7f0dc6d5f8c9114d20 (patch)
tree2569cf018e90a089ae8baa64ed3888a97d44e866 /public
parentb90c26fe908c126a03b286ed952b719a4624731b (diff)
Refactor webpack module
Diffstat (limited to '')
-rw-r--r--public/js/extra.js97
-rw-r--r--public/js/index.js16
-rw-r--r--public/js/public.js4
-rw-r--r--public/js/slide.js8
4 files changed, 53 insertions, 72 deletions
diff --git a/public/js/extra.js b/public/js/extra.js
index 1dd86760..24d53fe7 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -2,6 +2,7 @@ var hljs = require('highlight.js');
var PDFObject = require('pdfobject');
var S = require('string');
var saveAs = require('file-saver').saveAs;
+require('../vendor/md-toc');
//auto update last change
var createtime = null;
@@ -262,49 +263,49 @@ function finishView(view) {
MathJax.Hub.Queue(viewAjaxCallback);
}
} catch (err) {}
- //sequence diagram
- var sequences = view.find(".sequence-diagram.raw").removeClass("raw");
- sequences.each(function (key, value) {
- try {
- var $value = $(value);
- var $ele = $(value).parent().parent();
-
- var sequence = $value;
- sequence.sequenceDiagram({
- theme: 'simple'
- });
-
- $ele.addClass('sequence-diagram');
- $value.children().unwrap().unwrap();
- var svg = $ele.find('> svg');
- svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height'));
- svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet');
- } catch (err) {
- console.warn(err);
- }
- });
- //flowchart
- var flow = view.find(".flow-chart.raw").removeClass("raw");
- flow.each(function (key, value) {
- try {
- var $value = $(value);
- var $ele = $(value).parent().parent();
+ //sequence diagram
+ var sequences = view.find(".sequence-diagram.raw").removeClass("raw");
+ sequences.each(function (key, value) {
+ try {
+ var $value = $(value);
+ var $ele = $(value).parent().parent();
+
+ var sequence = $value;
+ sequence.sequenceDiagram({
+ theme: 'simple'
+ });
- var chart = flowchart.parse($value.text());
- $value.html('');
- chart.drawSVG(value, {
- 'line-width': 2,
- 'fill': 'none',
- 'font-size': '16px',
- 'font-family': "'Andale Mono', monospace"
- });
+ $ele.addClass('sequence-diagram');
+ $value.children().unwrap().unwrap();
+ var svg = $ele.find('> svg');
+ svg[0].setAttribute('viewBox', '0 0 ' + svg.attr('width') + ' ' + svg.attr('height'));
+ svg[0].setAttribute('preserveAspectRatio', 'xMidYMid meet');
+ } catch (err) {
+ console.warn(err);
+ }
+ });
+ //flowchart
+ var flow = view.find(".flow-chart.raw").removeClass("raw");
+ flow.each(function (key, value) {
+ try {
+ var $value = $(value);
+ var $ele = $(value).parent().parent();
+
+ var chart = flowchart.parse($value.text());
+ $value.html('');
+ chart.drawSVG(value, {
+ 'line-width': 2,
+ 'fill': 'none',
+ 'font-size': '16px',
+ 'font-family': "'Andale Mono', monospace"
+ });
- $ele.addClass('flow-chart');
- $value.children().unwrap().unwrap();
- } catch (err) {
- console.warn(err);
- }
- });
+ $ele.addClass('flow-chart');
+ $value.children().unwrap().unwrap();
+ } catch (err) {
+ console.warn(err);
+ }
+ });
//graphviz
var Viz = require("viz.js");
var graphvizs = view.find(".graphviz.raw").removeClass("raw");
@@ -434,14 +435,14 @@ function finishView(view) {
});
//pdf
view.find(".pdf.raw").removeClass("raw")
- .each(function (key, value) {
- var url = $(value).attr('data-pdfurl');
- var inner = $('<div></div>');
- $(this).append(inner);
- PDFObject.embed(url, inner, {
- height: '400px'
+ .each(function (key, value) {
+ var url = $(value).attr('data-pdfurl');
+ var inner = $('<div></div>');
+ $(this).append(inner);
+ PDFObject.embed(url, inner, {
+ height: '400px'
+ });
});
- });
//syntax highlighting
view.find("pre.raw").removeClass("raw")
.each(function (key, value) {
diff --git a/public/js/index.js b/public/js/index.js
index f8f997d8..626799c4 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -7,25 +7,16 @@ require('bootstrap/dist/css/bootstrap.css');
require('prismjs/themes/prism.css');
require('highlight.js/styles/github-gist.css');
-/* other vendors plugin */
-require('gist-embed');
-require('string');
require('prismjs');
require('prismjs/components/prism-wiki');
-require('to-markdown');
+var toMarkdown = require('to-markdown');
-require('raphael');
-require('js-sequence-diagrams');
-
-require('flowchart.js');
var saveAs = require('file-saver').saveAs;
-require('store');
require('js-url');
-require('visibilityjs');
-var List = require('list.js');
-require('../vendor/md-toc');
require('randomcolor');
+var List = require('list.js');
+
var common = require('./common.js');
var urlpath = common.urlpath;
var noteid = common.noteid;
@@ -2268,6 +2259,7 @@ function havePermission() {
window.havePermission = havePermission;
//socket.io actions
+var io = require("socket.io-client");
var socket = io.connect({
path: urlpath ? '/' + urlpath + '/socket.io/' : '',
timeout: 5000 //5 secs to timeout
diff --git a/public/js/public.js b/public/js/public.js
index 83d94144..5fd3fd79 100644
--- a/public/js/public.js
+++ b/public/js/public.js
@@ -15,10 +15,6 @@ require('prismjs');
require('prismjs/components/prism-wiki');
require('to-markdown');
-require('raphael');
-require('js-sequence-diagrams');
-
-require('flowchart.js');
require('file-saver');
require('store');
require('js-url');
diff --git a/public/js/slide.js b/public/js/slide.js
index 6230d159..1f4892f9 100644
--- a/public/js/slide.js
+++ b/public/js/slide.js
@@ -4,19 +4,11 @@ require('bootstrap/dist/css/bootstrap.css');
require('prismjs/themes/prism.css');
/* other vendors plugin */
-require('gist-embed');
var S = require('string');
require('prismjs');
require('prismjs/components/prism-wiki');
require('to-markdown');
-require('raphael');
-require('js-sequence-diagrams');
-
-require('flowchart.js');
-require('file-saver');
-require('store');
-require('visibilityjs');
require('../vendor/md-toc');
require('randomcolor');