pull/1/head
yflory 7 years ago
parent c85a551546
commit 470f404a24

@ -761,7 +761,7 @@ define([
UI.getFileIcon = function (data) {
var $icon = UI.getIcon();
if (!data) { return $icon; }
var href = data.href;
var href = data.href || data.roHref;
var type = data.type;
if (!href && !type) { return $icon; }

@ -73,6 +73,8 @@ define([
data.password = val;
}));
}).nThen(function (waitFor) {
var base = common.getMetadataMgr().getPrivateData().origin;
/* XXX
common.getPadAttribute('href', waitFor(function (err, val) {
var base = common.getMetadataMgr().getPrivateData().origin;
@ -93,6 +95,12 @@ define([
if (!hrefsecret.keys) { return; }
var viewHash = Hash.getViewHashFromKeys(hrefsecret);
data.roHref = hBase + viewHash;
}));*/
common.getPadAttribute('href', waitFor(function (err, val) {
data.href = base + val;
}));
common.getPadAttribute('roHref', waitFor(function (err, val) {
data.roHref = base + val;
}));
common.getPadAttribute('channel', waitFor(function (err, val) {
data.channel = val;
@ -162,7 +170,7 @@ define([
$d.append(password);
}
var parsed = Hash.parsePadUrl(data.href);
var parsed = Hash.parsePadUrl(data.href || data.roHref);
if (owned && parsed.hashData.type === 'pad') {
var sframeChan = common.getSframeChannel();
var changePwTitle = Messages.properties_changePassword;
@ -186,7 +194,7 @@ define([
UI.confirm(changePwConfirm, function (yes) {
if (!yes) { return; }
sframeChan.query("Q_PAD_PASSWORD_CHANGE", {
href: data.href,
href: data.href || data.roHref,
password: $(newPassword).find('input').val()
}, function (err, data) {
if (err || data.error) {
@ -195,11 +203,11 @@ define([
UI.findOKButton().click();
if (data.warning) {
return void UI.alert(Messages.properties_passwordWarning, function () {
common.gotoURL(hasPassword ? undefined : data.href);
common.gotoURL(hasPassword ? undefined : (data.href || data.roHref));
}, {force: true});
}
return void UI.alert(Messages.properties_passwordSuccess, function () {
common.gotoURL(hasPassword ? undefined : data.href);
common.gotoURL(hasPassword ? undefined : (data.href || data.roHref));
}, {force: true});
});
});

@ -613,7 +613,7 @@ define([
if (!parsed.hash) { return void cb({ error: 'EINVAL_HREF' }); }
var warning = false;
var newHash;
var newHash, newRoHref;
var oldChannel;
if (parsed.hashData.password) {
newHash = parsed.hash;
@ -678,6 +678,11 @@ define([
common.setPadAttribute('channel', secret.channel, waitFor(function (err) {
if (err) { warning = true; }
}), href);
var viewHash = Hash.getViewHashFromKeys(secret);
newRoHref = '/' + parsed.type + '/#' + viewHash;
common.setPadAttribute('roHref', newRoHref, waitFor(function (err) {
if (err) { warning = true; }
}), href);
if (parsed.hashData.password) { return; } // same hash
common.setPadAttribute('href', newHref, waitFor(function (err) {
@ -687,7 +692,8 @@ define([
cb({
warning: warning,
hash: newHash,
href: newHref
href: newHref,
roHref: newRoHref
});
});
};

@ -666,10 +666,10 @@ define([
var openFile = function (el, href) {
if (!href) {
var data = filesOp.getFileData(el);
if (!data || !data.href) {
if (!data || (!data.href && !data.roHref)) {
return void logError("Missing data for the file", el, data);
}
href = data.href;
href = data.href || data.roHref;
}
window.open(APP.origin + href);
};
@ -1271,9 +1271,10 @@ define([
if (!filesOp.isFile(element)) { return; }
var data = filesOp.getFileData(element);
var href = data.href || data.roHref;
if (!data) { return void logError("No data for the file", element); }
var hrefData = Hash.parsePadUrl(data.href);
var hrefData = Hash.parsePadUrl(href);
if (hrefData.type) {
$span.addClass('cp-border-color-'+hrefData.type);
}
@ -1305,7 +1306,7 @@ define([
$span.attr('title', name);
var type = Messages.type[hrefData.type] || hrefData.type;
common.displayThumbnail(data.href, data.channel, data.password, $span, function ($thumb) {
common.displayThumbnail(href || data.roHref, data.channel, data.password, $span, function ($thumb) {
// Called only if the thumbnail exists
// Remove the .hide() added by displayThumnail() because it hides the icon in
// list mode too
@ -1847,7 +1848,7 @@ define([
var data = filesOp.getFileData(id);
if (!data) { return ''; }
if (prop === 'type') {
var hrefData = Hash.parsePadUrl(data.href);
var hrefData = Hash.parsePadUrl(data.href || data.roHref);
return hrefData.type;
}
if (prop === 'atime' || prop === 'ctime') {
@ -1882,7 +1883,7 @@ define([
};
}
if (prop === 'type') {
var hrefData = Hash.parsePadUrl(e.href);
var hrefData = Hash.parsePadUrl(e.href || e.roHref);
return hrefData.type;
}
if (prop === 'atime' || prop === 'ctime') {
@ -2690,10 +2691,12 @@ define([
return $div.html();
};
/* XXX
var getReadOnlyUrl = APP.getRO = function (id) {
if (!filesOp.isFile(id)) { return; }
var data = filesOp.getFileData(id);
if (!data) { return; }
if (data.roHref) { return data.roHref; }
var parsed = Hash.parsePadUrl(data.href);
if (parsed.hashData.type !== "pad") { return; }
var i = data.href.indexOf('#') + 1;
@ -2702,7 +2705,7 @@ define([
if (!hrefsecret.keys) { return; }
var viewHash = Hash.getViewHashFromKeys(hrefsecret);
return base + viewHash;
};
};*/
// Disable middle click in the context menu to avoid opening /drive/inner.html# in new tabs
$(window).click(function (e) {
@ -2717,12 +2720,14 @@ define([
if (!filesOp.isFile(el)) {
return void cb('NOT_FILE');
}
var ro = filesOp.isReadOnlyFile(el);
//var ro = filesOp.isReadOnlyFile(el);
var base = APP.origin;
var data = JSON.parse(JSON.stringify(filesOp.getFileData(el)));
if (!data || !data.href) { return void cb('INVALID_FILE'); }
data.href = base + data.href;
data.roHref = base + data.roHref;
/* XXX
var roUrl;
if (ro) {
data.roHref = data.href;
@ -2731,6 +2736,7 @@ define([
roUrl = getReadOnlyUrl(el);
if (roUrl) { data.roHref = base + roUrl; }
}
*/
UIElements.getProperties(common, data, cb);
};
@ -2806,8 +2812,9 @@ define([
var el = filesOp.find(p.path);
if (filesOp.isPathIn(p.path, [FILES_DATA])) { el = el.href; }
if (!el || filesOp.isFolder(el)) { return; }
var roUrl = getReadOnlyUrl(el);
openFile(null, roUrl);
// var roUrl = getReadOnlyUrl(el);
openFile(el);
//, roUrl); XXX
});
}
else if ($(this).hasClass('cp-app-drive-context-newfolder')) {
@ -2847,7 +2854,7 @@ define([
el = filesOp.find(paths[0].path);
var data = filesOp.getFileData(el);
if (!data) { return void console.error("Expected to find a file"); }
var href = data.href;
var href = data.href || data.roHref;
common.updateTags(href);
}
else if ($(this).hasClass("cp-app-drive-context-empty")) {

Loading…
Cancel
Save