From 558304ff62a648e604b03afe3372ef9566aea850 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Tue, 21 Jun 2016 21:42:03 +0800 Subject: Update to support new metadata: title, description, tags and google-analytics (GA) and refactor render publish slide response function --- public/js/extra.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'public/js/extra.js') diff --git a/public/js/extra.js b/public/js/extra.js index 953770be..e67eee53 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -43,12 +43,16 @@ function updateLastChangeUser() { //get title function getTitle(view) { - var h1s = view.find("h1"); var title = ""; - if (h1s.length > 0) { - title = h1s.first().text(); + if (md && md.meta && md.meta.title && (typeof md.meta.title == "string" || typeof md.meta.title == "number")) { + title = md.meta.title; } else { - title = null; + var h1s = view.find("h1"); + if (h1s.length > 0) { + title = h1s.first().text(); + } else { + title = null; + } } return title; } @@ -93,7 +97,7 @@ function parseMeta(md, edit, view, toc, tocAffix) { spellcheck = meta.spellcheck; } //text language - if (lang) { + if (lang && typeof lang == "string") { view.attr('lang', lang); toc.attr('lang', lang); tocAffix.attr('lang', lang); @@ -107,7 +111,7 @@ function parseMeta(md, edit, view, toc, tocAffix) { edit.removeAttr('lang', lang); } //text direction - if (dir) { + if (dir && typeof dir == "string") { view.attr('dir', dir); toc.attr('dir', dir); tocAffix.attr('dir', dir); -- cgit v1.2.3