summaryrefslogtreecommitdiff
path: root/public/js/history.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-06-21 21:42:03 +0800
committerCheng-Han, Wu2016-06-21 21:42:03 +0800
commit558304ff62a648e604b03afe3372ef9566aea850 (patch)
treef01521782685784508e4e5017d25a9c6b7768d06 /public/js/history.js
parentad6982e77e1948bd7b74538af0c5a24120a38370 (diff)
Update to support new metadata: title, description, tags and google-analytics (GA) and refactor render publish slide response function
Diffstat (limited to 'public/js/history.js')
-rw-r--r--public/js/history.js32
1 files changed, 24 insertions, 8 deletions
diff --git a/public/js/history.js b/public/js/history.js
index 9bdca709..0840580d 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -202,28 +202,44 @@ function writeHistoryToStorage(view) {
}
}
+if (!Array.isArray) {
+ Array.isArray = function(arg) {
+ return Object.prototype.toString.call(arg) === '[object Array]';
+ };
+}
+
function renderHistory(view) {
var title = renderFilename(view);
var tags = [];
var rawtags = [];
- view.find('h6').each(function (key, value) {
- if (/^tags/gmi.test($(value).text())) {
- var codes = $(value).find("code");
- for (var i = 0; i < codes.length; i++)
- rawtags.push(codes[i]);
+ if (md && md.meta && md.meta.tags && (typeof md.meta.tags == "string" || typeof md.meta.tags == "number")) {
+ var metaTags = ('' + md.meta.tags).split(',');
+ for (var i = 0; i < metaTags.length; i++) {
+ var text = metaTags[i].trim();
+ if (text) rawtags.push(text);
}
- });
+ } else {
+ view.find('h6').each(function (key, value) {
+ if (/^tags/gmi.test($(value).text())) {
+ var codes = $(value).find("code");
+ for (var i = 0; i < codes.length; i++) {
+ var text = codes[i].innerHTML.trim();
+ if (text) rawtags.push(text);
+ }
+ }
+ });
+ }
for (var i = 0; i < rawtags.length; i++) {
var found = false;
for (var j = 0; j < tags.length; j++) {
- if (tags[j] == rawtags[i].innerHTML) {
+ if (tags[j] == rawtags[i]) {
found = true;
break;
}
}
if (!found)
- tags.push(rawtags[i].innerHTML);
+ tags.push(rawtags[i]);
}
//console.debug(tags);
var id = urlpath ? location.pathname.slice(urlpath.length + 1, location.pathname.length).split('/')[1] : location.pathname.split('/')[1];