sbkwgh 7 лет назад
Родитель
Сommit
95f2d3f8c4
3 измененных файлов с 11 добавлено и 2 удалено
  1. 5 2
      frontend/src/assets/js/linkExpander.js
  2. 5 0
      package-lock.json
  3. 1 0
      package.json

+ 5 - 2
frontend/src/assets/js/linkExpander.js

@@ -1,9 +1,12 @@
+import debounce from 'lodash.debounce'
+
 export default {
 	install (Vue) {
 		//Takes a HTML string then parses it and replaces appropriate
 		//links with the relevant expansion
 		//Returns a callback with the 'expanded' HTML string
-		Vue.prototype.$linkExpander = function (HTML, cb) {
+		Vue.prototype.$linkExpander = debounce(function (HTML, cb) {
+			console.log(cb)
 			let parsed = document.createElement('div');
 			parsed.innerHTML = HTML;
 
@@ -44,6 +47,6 @@ export default {
 					cb(parsed.innerHTML);
 				}
 			}
-		}
+		}, 1000);
 	}
 }

+ 5 - 0
package-lock.json

@@ -2286,6 +2286,11 @@
         "lodash._isiterateecall": "3.0.9"
       }
     },
+    "lodash.debounce": {
+      "version": "4.0.8",
+      "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
+      "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
+    },
     "lodash.escape": {
       "version": "3.2.0",
       "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz",

+ 1 - 0
package.json

@@ -26,6 +26,7 @@
     "express-session": "^1.15.1",
     "helmet": "^3.9.0",
     "highlight.js": "^9.10.0",
+    "lodash.debounce": "^4.0.8",
     "marked": "^0.3.9",
     "multer": "^1.3.0",
     "mysql": "^2.13.0",