Move out script tag and use js instead

This commit is contained in:
Yukai Huang 2016-10-07 23:06:10 +08:00
parent 325d1f1a32
commit 8e11c19bed
3 changed files with 80 additions and 58 deletions

1
public/js/app.js Normal file
View File

@ -0,0 +1 @@
require('./index');

View File

@ -1,3 +1,75 @@
/* include jquery ui */
require('jquery-ui/ui/widgets/resizable');
require('jquery-ui/ui/widgets/tooltip');
require('jquery-ui/ui/widgets/controlgroup');
require('jquery-ui/ui/widgets/autocomplete');
/* jquery and jquery plugins */
require('jquery');
require('jquery-textcomplete');
require('jquery-mousewheel');
require('../vendor/jquery-scrollspy');
require('../vendor/showup/showup');
/* bootstrap */
require('bootstrap');
/* code mirror plugins */
require('codemirror/keymap/vim');
require('codemirror/keymap/emacs');
require('codemirror/keymap/sublime');
require('../vendor/inlineAttachment/inline-attachment');
require('../vendor/inlineAttachment/codemirror.inline-attachment');
require('../vendor/codemirror-spell-checker/spell-checker.min');
/* operational transformation */
require('../vendor/ot/ot.min');
/* other vendors plugin */
require('markdown-it');
require('markdown-it-abbr');
require('markdown-it-footnote');
require('markdown-it-deflist');
require('markdown-it-mark');
require('markdown-it-ins');
require('markdown-it-sub');
require('markdown-it-sup');
require('markdown-it-container');
require('markdown-it-mathjax');
require('markdown-it-regexp');
require('markdown-it-imsize');
require('gist-embed');
require('lz-string');
require('xss');
require('string');
require('highlight.js');
require('prismjs');
require('prismjs/components/prism-wiki');
require('js-cookie');
require('emojify.js');
require('to-markdown');
require('raphael');
require('js-sequence-diagrams');
require('flowchart.js');
require('viz.js');
require('pdfobject');
require('file-saver');
require('store');
require('js-url');
require('visibilityjs');
require('list.js');
require('../vendor/md-toc');
require('randomcolor');
require('keymaster');
var common = require('./common.js');
var serverurl = common.serverurl;
var defaultTextHeight = 20; var defaultTextHeight = 20;
var viewportMargin = 20; var viewportMargin = 20;
var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault; var mac = CodeMirror.keyMap["default"] == CodeMirror.keyMap.macDefault;
@ -126,7 +198,7 @@ function wrapTextWith(cm, symbol) {
}; };
var postText = cm.getRange(postEndPos, from); var postText = cm.getRange(postEndPos, from);
var postIndex = wrapSymbols.indexOf(postText); var postIndex = wrapSymbols.indexOf(postText);
// check if surround symbol are list in array and matched // check if surround symbol are list in array and matched
if (preIndex > -1 && postIndex > -1 && preIndex === postIndex) { if (preIndex > -1 && postIndex > -1 && preIndex === postIndex) {
cm.replaceRange("", to, preEndPos, '+delete'); cm.replaceRange("", to, preEndPos, '+delete');
cm.replaceRange("", postEndPos, from, '+delete'); cm.replaceRange("", postEndPos, from, '+delete');
@ -1035,7 +1107,7 @@ function checkEditorStyle() {
}, },
stop: function (e) { stop: function (e) {
lastEditorWidth = ui.area.edit.width(); lastEditorWidth = ui.area.edit.width();
// workaround that scroll event bindings // workaround that scroll event bindings
preventSyncScrollToView = 2; preventSyncScrollToView = 2;
preventSyncScrollToEdit = true; preventSyncScrollToEdit = true;
editor.setOption('viewportMargin', viewportMargin); editor.setOption('viewportMargin', viewportMargin);
@ -1269,12 +1341,12 @@ function changeMode(type) {
preventSyncScrollToView = 2; preventSyncScrollToView = 2;
syncScrollToEdit(null, true); syncScrollToEdit(null, true);
} }
if (lastMode == modeType.edit && currentMode == modeType.both) { if (lastMode == modeType.edit && currentMode == modeType.both) {
preventSyncScrollToEdit = 2; preventSyncScrollToEdit = 2;
syncScrollToView(null, true); syncScrollToView(null, true);
} }
if (lastMode == modeType.both && currentMode != modeType.both) { if (lastMode == modeType.both && currentMode != modeType.both) {
preventSyncScrollToView = false; preventSyncScrollToView = false;
preventSyncScrollToEdit = false; preventSyncScrollToEdit = false;
@ -1675,7 +1747,7 @@ function parseRevisions(_revisions) {
} }
} }
function selectRevision(time) { function selectRevision(time) {
if (time == revisionTime) return; if (time == revisionTime) return;
$.get(noteurl + '/revision/' + time) $.get(noteurl + '/revision/' + time)
.done(function(data) { .done(function(data) {
revision = data; revision = data;

View File

@ -14,65 +14,15 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script> <script src="//cdnjs.cloudflare.com/ajax/libs/mermaid/6.0.0/mermaid.min.js" defer></script>
<% } else { %> <% } else { %>
<script src="<%- url %>/vendor/spin.js/spin.min.js" defer></script> <script src="<%- url %>/vendor/spin.js/spin.min.js" defer></script>
<script src="<%- url %>/vendor/jquery/dist/jquery.min.js"></script>
<script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script> <script src="<%- url %>/vendor/velocity/velocity.min.js" defer></script>
<script src="<%- url %>/vendor/jquery-mousewheel/jquery.mousewheel.min.js" defer></script>
<script src="<%- url %>/vendor/bootstrap/dist/js/bootstrap.min.js" defer></script>
<script src="<%- url %>/vendor/socket.io-client/socket.io.js" defer></script> <script src="<%- url %>/vendor/socket.io-client/socket.io.js" defer></script>
<script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script> <script src="<%- url %>/vendor/js-yaml/dist/js-yaml.min.js" defer></script>
<script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script> <script type="text/javascript" src="<%- url %>/vendor/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" defer></script>
<script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script> <script src="<%- url %>/vendor/moment/min/moment-with-locales.js" defer></script>
<script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script> <script src="<%- url %>/vendor/mermaid/dist/mermaid.min.js" defer></script>
<% } %> <% } %>
<script src="<%- url %>/vendor/jquery-ui/jquery-ui.min.js" defer></script> <script src="<%- url %>/vendor/idle.min.js" defer></script>
<!--codemirror--> <script src="<%- url %>/build/js/app.js" defer></script>
<script src="<%- url %>/vendor/codemirror/codemirror.min.js" defer></script>
<script src="<%- url %>/vendor/inlineAttachment/inline-attachment.js" defer></script>
<script src="<%- url %>/vendor/inlineAttachment/codemirror.inline-attachment.js" defer></script>
<script src="<%- url %>/vendor/codemirror-spell-checker/spell-checker.min.js" defer></script>
<!--ot-->
<script src="<%- url %>/vendor/ot/ot.min.js" defer></script>
<!--others-->
<script src="<%- url %>/vendor/markdown-it/dist/markdown-it.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-abbr/dist/markdown-it-abbr.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-footnote/dist/markdown-it-footnote.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-deflist/dist/markdown-it-deflist.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-mark/dist/markdown-it-mark.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-ins/dist/markdown-it-ins.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-sub/dist/markdown-it-sub.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-sup/dist/markdown-it-sup.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-container/dist/markdown-it-container.min.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-mathjax.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-regexp.js" defer></script>
<script src="<%- url %>/vendor/markdown-it-imsize.js" defer></script>
<script src="<%- url %>/vendor/gist-embed/gist-embed.min.js" defer></script>
<script src="<%- url %>/vendor/lz-string/libs/lz-string.min.js" defer></script>
<script src="<%- url %>/vendor/xss/dist/xss.min.js" defer></script>
<script src="<%- url %>/vendor/string/dist/string.min.js" defer></script>
<script src="<%- url %>/vendor/highlightjs/highlight.pack.min.js" defer></script>
<script src="<%- url %>/vendor/prism/prism.js" defer></script>
<script src="<%- url %>/vendor/prism/components/prism-wiki.min.js" defer></script>
<script src="<%- url %>/vendor/js-cookie/src/js.cookie.js" defer></script>
<script src="<%- url %>/vendor/handlebars/handlebars.min.js" defer></script>
<script src="<%- url %>/vendor/emojify/js/emojify.min.js" defer></script>
<script src="<%- url %>/vendor/to-markdown/dist/to-markdown.js" defer></script>
<script src="<%- url %>/vendor/raphael/raphael.min.js" defer></script>
<script src="<%- url %>/vendor/lodash/dist/lodash.min.js" defer></script>
<script src="<%- url %>/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script>
<script src="<%- url %>/vendor/flowchart/release/flowchart.min.js" defer></script>
<script src="<%- url %>/vendor/viz.js/viz.js" defer></script>
<script src="<%- url %>/vendor/pdfobject/pdfobject.min.js" defer></script>
<script src="<%- url %>/vendor/file-saver/FileSaver.min.js" defer></script>
<script src="<%- url %>/vendor/store-js/store.min.js" defer></script>
<script src="<%- url %>/vendor/js-url/url.min.js" defer></script>
<script src="<%- url %>/vendor/jquery-textcomplete/jquery.textcomplete.js" defer></script>
<script src="<%- url %>/vendor/Idle.Js/build/idle.min.js" defer></script>
<script src="<%- url %>/vendor/visibilityjs/lib/visibility.core.js" defer></script>
<script src="<%- url %>/vendor/list.js/dist/list.min.js" defer></script>
<script src="<%- url %>/vendor/md-toc.js" defer></script>
<script src="<%- url %>/vendor/showup/showup.js" defer></script>
<script src="<%- url %>/vendor/randomcolor/randomColor.js" defer></script>
<script src="<%- url %>/vendor/keymaster/keymaster.js" defer></script>
<script src="<%- url %>/js/google-drive-upload.js" defer></script> <script src="<%- url %>/js/google-drive-upload.js" defer></script>
<script src="<%- url %>/js/google-drive-picker.js" defer></script> <script src="<%- url %>/js/google-drive-picker.js" defer></script>
<script src="<%- url %>/js/common.js" defer></script> <script src="<%- url %>/js/common.js" defer></script>
@ -81,4 +31,3 @@
<script src="<%- url %>/js/history.js" defer></script> <script src="<%- url %>/js/history.js" defer></script>
<script src="<%- url %>/js/reveal-markdown.js" defer></script> <script src="<%- url %>/js/reveal-markdown.js" defer></script>
<script src="<%- url %>/js/syncscroll.js" defer></script> <script src="<%- url %>/js/syncscroll.js" defer></script>
<script src="<%- url %>/js/index.js" defer></script>