Add dummy open-in-code in drive context menu

This commit is contained in:
ClemDee
2019-07-24 14:06:04 +02:00
parent cb76211a38
commit fe2539394b
2 changed files with 41 additions and 1 deletions

View File

@@ -319,6 +319,25 @@ define([], function () {
return window.innerHeight < 800 || window.innerWidth < 800;
};
Util.isPlainTextFile = function (metadata) {
if (!metadata || !metadata.href) { return; }
console.log("%c" + metadata.title + " : " + metadata.fileType, "color: #3a7");
console.log(metadata);
var href = metadata.roHref || metadata.href;
// is it a file ?
if (!href || href.indexOf("/file/") === -1) { return false; }
// does its type begins with "text/"
if (metadata.fileType.indexOf("text/") === 0) { return true; }
// no type and no file extension -> let's guess it's plain text
var parsedName = /^(\.?.+?)(\.[^.]+)?$/.exec(metadata.title) || [];
if (!metadata.fileType && !parsedName[2]) { return true; }
// other exceptions
if (metadata.fileType === 'application/x-javascript') { return true; }
if (metadata.fileType === 'application/xml') { return true; }
return false;
};
return Util;
});
}(self));