Skip to content

Commit 0226801

Browse files
author
socrateslee
committed
Add a link for opening document's folder.
1 parent d83f24f commit 0226801

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

js/mdreader.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@
6262
return link
6363
}
6464

65+
/**
66+
* Get the folder link of a docuemnt.
67+
*
68+
* @param (Object) file object.
69+
*
70+
*/
71+
function getFolderLink(fileObject){
72+
var index = fileObject.alternateLink.indexOf('/file/d');
73+
if(index === -1){
74+
return '';
75+
}
76+
var base = fileObject.alternateLink.substring(0, index);
77+
var folderId = fileObject.parents[fileObject.parents.length-1].id;
78+
return base + "/?authuser=" + authuserIndex.toString() + "#folders/" + folderId;
79+
}
80+
6581
/**
6682
* Called for get the info of a document.
6783
*
@@ -74,8 +90,12 @@
7490
'method': 'GET'});
7591
callback = function(resp) {
7692
if(!resp.error){
77-
appendLink(topNav, getOutboundLink(id), resp.title, 'Please right click copy the link address for sharing.');
93+
94+
appendLink(topNav, getOutboundLink(id), "|" + resp.title + "|", 'Please right click copy the link address for sharing.');
7895
document.title = "[" + resp.title + "]" + "mdReader -- Markdown reader for Google Drive";
96+
97+
appendLink(topNav, getFolderLink(resp), '|Open Folder|', 'Open the folder containing this document.');
98+
7999
if(resp.downloadUrl){
80100
getDocumentContent(resp.downloadUrl);
81101
}

0 commit comments

Comments
 (0)