Merge branch 'rohref' into sharedfolder
This commit is contained in:
@@ -398,10 +398,16 @@ Version 1
|
||||
Hash.findWeaker = function (href, channel, recents) {
|
||||
var parsed = parsePadUrl(href);
|
||||
if (!parsed.hash) { return false; }
|
||||
// We can't have a weaker hash if we're already in view mode
|
||||
if (parsed.hashData && parsed.hashData.mode === 'view') { return; }
|
||||
var weaker;
|
||||
Object.keys(recents).some(function (id) {
|
||||
var pad = recents[id];
|
||||
var p = parsePadUrl(pad.href);
|
||||
if (pad.href || !pad.roHref) {
|
||||
// This pad has an edit link, so it can't be weaker
|
||||
return;
|
||||
}
|
||||
var p = parsePadUrl(pad.roHref);
|
||||
if (p.type !== parsed.type) { return; } // Not the same type
|
||||
if (p.hash === parsed.hash) { return; } // Same hash, not stronger
|
||||
if (channel !== pad.channel) { return; } // Not the same channel
|
||||
@@ -430,6 +436,10 @@ Version 1
|
||||
var stronger;
|
||||
Object.keys(recents).some(function (id) {
|
||||
var pad = recents[id];
|
||||
if (!pad.href) {
|
||||
// This pad doesn't have an edit link, so it can't be stronger
|
||||
return;
|
||||
}
|
||||
var p = parsePadUrl(pad.href);
|
||||
if (p.type !== parsed.type) { return; } // Not the same type
|
||||
if (p.hash === parsed.hash) { return; } // Same hash, not stronger
|
||||
|
||||
@@ -665,7 +665,7 @@ define([
|
||||
// Update the current state
|
||||
loading.driveState = data.state;
|
||||
data.progress = data.progress || 100;
|
||||
data.msg = Messages['loading_drive_'+data.state] || '';
|
||||
data.msg = Messages['loading_drive_'+ Math.floor(data.state)] || '';
|
||||
$progress.html(data.msg);
|
||||
if (data.progress) {
|
||||
$progress.append(h('div.cp-loading-progress-bar', [
|
||||
@@ -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,26 +73,14 @@ define([
|
||||
data.password = val;
|
||||
}));
|
||||
}).nThen(function (waitFor) {
|
||||
var base = common.getMetadataMgr().getPrivateData().origin;
|
||||
common.getPadAttribute('href', waitFor(function (err, val) {
|
||||
var base = common.getMetadataMgr().getPrivateData().origin;
|
||||
|
||||
var parsed = Hash.parsePadUrl(val);
|
||||
if (parsed.hashData.mode === "view") {
|
||||
data.roHref = base + val;
|
||||
return;
|
||||
}
|
||||
|
||||
// We're not in a read-only pad
|
||||
if (!val) { return; }
|
||||
data.href = base + val;
|
||||
|
||||
// Get Read-only href
|
||||
if (parsed.hashData.type !== "pad") { return; }
|
||||
var i = data.href.indexOf('#') + 1;
|
||||
var hBase = data.href.slice(0, i);
|
||||
var hrefsecret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
if (!hrefsecret.keys) { return; }
|
||||
var viewHash = Hash.getViewHashFromKeys(hrefsecret);
|
||||
data.roHref = hBase + viewHash;
|
||||
}));
|
||||
common.getPadAttribute('roHref', waitFor(function (err, val) {
|
||||
if (!val) { return; }
|
||||
data.roHref = base + val;
|
||||
}));
|
||||
common.getPadAttribute('channel', waitFor(function (err, val) {
|
||||
data.channel = val;
|
||||
@@ -162,7 +150,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 +174,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 +183,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
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -115,23 +115,25 @@ define([
|
||||
var newRecentPads = proxy.drive[newFo.FILES_DATA];
|
||||
var oldFiles = oldFo.getFiles([newFo.FILES_DATA]);
|
||||
var newHrefs = Object.keys(newRecentPads).map(function (id) {
|
||||
return newRecentPads[id].href;
|
||||
return newRecentPads[id].href || newRecentPads[id].roHref;
|
||||
});
|
||||
oldFiles.forEach(function (id) {
|
||||
var href = oldRecentPads[id].href;
|
||||
var href = oldRecentPads[id].href || oldRecentPads[id].roHref;
|
||||
var isRo = href === oldRecentPads[id].roHref;
|
||||
// Do not migrate a pad if we already have it, it would create a duplicate in the drive
|
||||
if (newHrefs.indexOf(href) !== -1) { return; }
|
||||
// If we have a stronger version, do not add the current href
|
||||
if (Hash.findStronger(href, oldRecentPads[id].channel, newRecentPads)) { return; }
|
||||
// If the current href is read-only, don't check, we won't have a stronger
|
||||
if (isRo && Hash.findStronger(href, oldRecentPads[id].channel, newRecentPads)) { return; }
|
||||
// If we have a weaker version, replace the href by the new one
|
||||
// NOTE: if that weaker version is in the trash, the strong one will be put in unsorted
|
||||
var weaker = Hash.findWeaker(href, oldRecentPads[id].channel, newRecentPads);
|
||||
if (weaker) {
|
||||
// Update RECENTPADS
|
||||
weaker.href = href;
|
||||
// Update the file in the drive
|
||||
newFo.replace(weaker.href, href);
|
||||
return;
|
||||
// If the current href is an edit link, don't check, we won't have a weaker
|
||||
if (!isRo) {
|
||||
var weaker = Hash.findWeaker(href, oldRecentPads[id].channel, newRecentPads);
|
||||
if (weaker) {
|
||||
// Update RECENTPADS
|
||||
weaker.href = href;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Here it means we have a new href, so we should add it to the drive at its old location
|
||||
var paths = oldFo.findFile(id);
|
||||
|
||||
@@ -123,12 +123,58 @@ define([
|
||||
}));
|
||||
});
|
||||
});
|
||||
n.nThen(waitFor());
|
||||
n.nThen(waitFor(function () {
|
||||
Feedback.send('Migrate-6', true);
|
||||
userObject.version = version = 6;
|
||||
}));
|
||||
};
|
||||
if (version < 6) {
|
||||
addChannelId();
|
||||
Feedback.send('Migrate-6', true);
|
||||
userObject.version = version = 6;
|
||||
}
|
||||
}).nThen(function (waitFor) {
|
||||
var addRoHref = function () {
|
||||
var data = userObject.drive.filesData;
|
||||
var el, parsed;
|
||||
var n = nThen(function () {});
|
||||
var padsLength = Object.keys(data).length;
|
||||
Object.keys(data).forEach(function (k, i) {
|
||||
n = n.nThen(function (w) {
|
||||
setTimeout(w(function () {
|
||||
el = data[k];
|
||||
if (!el.href || (el.roHref && false)) {
|
||||
// Already migrated
|
||||
return void progress(7, Math.round(100*i/padsLength));
|
||||
}
|
||||
parsed = Hash.parsePadUrl(el.href);
|
||||
if (parsed.hashData.type !== "pad") {
|
||||
// No read-only mode for files
|
||||
return void progress(7, Math.round(100*i/padsLength));
|
||||
}
|
||||
if (parsed.hashData.mode === "view") {
|
||||
// This is a read-only pad in our drive
|
||||
el.roHref = el.href;
|
||||
delete el.href;
|
||||
console.log('Move href to roHref in filesData ', el.roHref);
|
||||
} else {
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
var hash = Hash.getViewHashFromKeys(secret);
|
||||
if (hash) {
|
||||
// Version 0 won't have a view hash available
|
||||
el.roHref = '/' + parsed.type + '/#' + hash;
|
||||
console.log('Adding missing roHref in filesData ', el.href);
|
||||
}
|
||||
}
|
||||
progress(6, Math.round(100*i/padsLength));
|
||||
}));
|
||||
});
|
||||
});
|
||||
n.nThen(waitFor(function () {
|
||||
Feedback.send('Migrate-7', true);
|
||||
userObject.version = version = 7;
|
||||
}));
|
||||
};
|
||||
if (version < 7) {
|
||||
addRoHref();
|
||||
}
|
||||
/*}).nThen(function (waitFor) {
|
||||
// Test progress bar in the loading screen
|
||||
|
||||
@@ -426,10 +426,11 @@ define([
|
||||
cb(JSON.parse(JSON.stringify(metadata)));
|
||||
};
|
||||
|
||||
var makePad = function (href, title) {
|
||||
var makePad = function (href, roHref, title) {
|
||||
var now = +new Date();
|
||||
return {
|
||||
href: href,
|
||||
roHref: roHref,
|
||||
atime: now,
|
||||
ctime: now,
|
||||
title: title || Hash.getDefaultName(Hash.parsePadUrl(href)),
|
||||
@@ -437,8 +438,15 @@ define([
|
||||
};
|
||||
|
||||
Store.addPad = function (clientId, data, cb) {
|
||||
if (!data.href) { return void cb({error:'NO_HREF'}); }
|
||||
var pad = makePad(data.href, data.title);
|
||||
if (!data.href && !data.roHref) { return void cb({error:'NO_HREF'}); }
|
||||
if (!data.roHref) {
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
if (parsed.hashData.type === "pad") {
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
data.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
}
|
||||
}
|
||||
var pad = makePad(data.href, data.roHref, data.title);
|
||||
if (data.owners) { pad.owners = data.owners; }
|
||||
if (data.expire) { pad.expire = data.expire; }
|
||||
if (data.password) { pad.password = data.password; }
|
||||
@@ -736,9 +744,9 @@ define([
|
||||
// Edit > Edit (present) > View > View (present)
|
||||
for (var id in allPads) {
|
||||
var pad = allPads[id];
|
||||
if (!pad.href) { continue; }
|
||||
if (!pad.href && !pad.roHref) { continue; }
|
||||
|
||||
var p2 = Hash.parsePadUrl(pad.href);
|
||||
var p2 = Hash.parsePadUrl(pad.href || pad.roHref);
|
||||
var h2 = p2.hashData;
|
||||
|
||||
// Different types, proceed to the next one
|
||||
@@ -789,8 +797,14 @@ define([
|
||||
|
||||
// Add the pad if it does not exist in our drive
|
||||
if (!contains) {
|
||||
var roHref;
|
||||
if (h.mode === "view") {
|
||||
roHref = href;
|
||||
href = undefined;
|
||||
}
|
||||
Store.addPad(clientId, {
|
||||
href: href,
|
||||
roHref: roHref,
|
||||
channel: channel,
|
||||
title: title,
|
||||
owners: owners,
|
||||
@@ -827,7 +841,7 @@ define([
|
||||
};
|
||||
store.userObject.getFiles(where).forEach(function (id) {
|
||||
var data = store.userObject.getFileData(id);
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
var parsed = Hash.parsePadUrl(data.href || data.roHref);
|
||||
if ((!types || types.length === 0 || types.indexOf(parsed.type) !== -1) &&
|
||||
hashes.indexOf(parsed.hash) === -1 &&
|
||||
!isFiltered(parsed.type, data)) {
|
||||
@@ -1421,7 +1435,7 @@ define([
|
||||
}).nThen(function (waitFor) {
|
||||
Migrate(proxy, waitFor(), function (version, progress) {
|
||||
postMessage(clientId, 'LOADING_DRIVE', {
|
||||
state: 2,
|
||||
state: (2 + (version / 10)),
|
||||
progress: progress
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,19 +50,6 @@ define([
|
||||
var data = exp.getFileData(id);
|
||||
cb(null, clone(data[attr]));
|
||||
};
|
||||
var removePadAttribute = exp.removePadAttribute = function (f) {
|
||||
if (typeof(f) !== 'string') {
|
||||
console.error("Can't find pad attribute for an undefined pad");
|
||||
return;
|
||||
}
|
||||
Object.keys(files).forEach(function (key) {
|
||||
var hash = f.indexOf('#') !== -1 ? f.slice(f.indexOf('#') + 1) : null;
|
||||
if (hash && key.indexOf(hash) === 0) {
|
||||
exp.debug("Deleting pad attribute in the realtime object");
|
||||
delete files[key];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exp.pushData = function (data, cb) {
|
||||
if (typeof cb !== "function") { cb = function () {}; }
|
||||
@@ -145,12 +132,9 @@ define([
|
||||
|
||||
if (!loggedIn && !config.testMode) {
|
||||
allFilesPaths.forEach(function (path) {
|
||||
var el = exp.find(path);
|
||||
if (!el) { return; }
|
||||
var id = exp.getIdFromHref(el.href);
|
||||
var id = path[1];
|
||||
if (!id) { return; }
|
||||
spliceFileData(id);
|
||||
removePadAttribute(el.href);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -259,7 +243,6 @@ define([
|
||||
if (!id) { return; }
|
||||
if (!loggedIn && !config.testMode) {
|
||||
// delete permanently
|
||||
exp.removePadAttribute(href);
|
||||
spliceFileData(id);
|
||||
return;
|
||||
}
|
||||
@@ -268,14 +251,7 @@ define([
|
||||
};
|
||||
|
||||
// REPLACE
|
||||
exp.replace = function (o, n) {
|
||||
var idO = exp.getIdFromHref(o);
|
||||
if (!idO || !exp.isFile(idO)) { return; }
|
||||
var data = exp.getFileData(idO);
|
||||
if (!data) { return; }
|
||||
data.href = n;
|
||||
};
|
||||
// If all the occurences of an href are in the trash, remvoe them and add the file in root.
|
||||
// If all the occurences of an href are in the trash, remove them and add the file in root.
|
||||
// This is use with setPadTitle when we open a stronger version of a deleted pad
|
||||
exp.restoreHref = function (href) {
|
||||
var idO = exp.getIdFromHref(href);
|
||||
@@ -563,13 +539,15 @@ define([
|
||||
continue;
|
||||
}
|
||||
// Clean missing href
|
||||
if (!el.href) {
|
||||
if (!el.href && !el.roHref) {
|
||||
debug("Removing an element in filesData with a missing href.", el);
|
||||
toClean.push(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
var parsed = Hash.parsePadUrl(el.href);
|
||||
var parsed = Hash.parsePadUrl(el.href || el.roHref);
|
||||
var secret;
|
||||
|
||||
// Clean invalid hash
|
||||
if (!parsed.hash) {
|
||||
debug("Removing an element in filesData with a invalid href.", el);
|
||||
@@ -583,6 +561,23 @@ define([
|
||||
continue;
|
||||
}
|
||||
|
||||
// If we have an edit link, check the view link
|
||||
if (el.href && parsed.hashData.type === "pad") {
|
||||
if (parsed.hashData.mode === "view") {
|
||||
el.roHref = el.href;
|
||||
delete el.href;
|
||||
} else if (!el.roHref) {
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
el.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
} else {
|
||||
var parsed2 = Hash.parsePadUrl(el.roHref);
|
||||
if (!parsed2.hash || !parsed2.type) {
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
el.roHref = '/' + parsed.type + '/#' + Hash.getViewHashFromKeys(secret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix href
|
||||
if (/^https*:\/\//.test(el.href)) { el.href = Hash.getRelativeHref(el.href); }
|
||||
// Fix creation time
|
||||
@@ -592,7 +587,9 @@ define([
|
||||
// Fix channel
|
||||
if (!el.channel) {
|
||||
try {
|
||||
var secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
if (!secret) {
|
||||
secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||
}
|
||||
el.channel = secret.channel;
|
||||
console.log('Adding missing channel in filesData ', el.channel);
|
||||
} catch (e) {
|
||||
|
||||
@@ -79,11 +79,7 @@ define([
|
||||
exp.isReadOnlyFile = function (element) {
|
||||
if (!isFile(element)) { return false; }
|
||||
var data = exp.getFileData(element);
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
if (!parsed) { return false; }
|
||||
var pHash = parsed.hashData;
|
||||
if (!pHash || pHash.type !== "pad") { return; }
|
||||
return pHash && pHash.mode === 'view';
|
||||
return Boolean(data.roHref && !data.href);
|
||||
};
|
||||
|
||||
var isFolder = exp.isFolder = function (element) {
|
||||
@@ -140,7 +136,7 @@ define([
|
||||
var getTitle = exp.getTitle = function (file, type) {
|
||||
if (workgroup) { debug("No titles in workgroups"); return; }
|
||||
var data = getFileData(file);
|
||||
if (!file || !data || !data.href) {
|
||||
if (!file || !data || !(data.href || data.roHref)) {
|
||||
error("getTitle called with a non-existing file id: ", file, data);
|
||||
return;
|
||||
}
|
||||
@@ -289,7 +285,8 @@ define([
|
||||
var getIdFromHref = exp.getIdFromHref = function (href) {
|
||||
var result;
|
||||
getFiles([FILES_DATA]).some(function (id) {
|
||||
if (files[FILES_DATA][id].href === href) {
|
||||
if (files[FILES_DATA][id].href === href ||
|
||||
files[FILES_DATA][id].roHref === href) {
|
||||
result = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -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,20 +2691,6 @@ define([
|
||||
return $div.html();
|
||||
};
|
||||
|
||||
var getReadOnlyUrl = APP.getRO = function (id) {
|
||||
if (!filesOp.isFile(id)) { return; }
|
||||
var data = filesOp.getFileData(id);
|
||||
if (!data) { return; }
|
||||
var parsed = Hash.parsePadUrl(data.href);
|
||||
if (parsed.hashData.type !== "pad") { return; }
|
||||
var i = data.href.indexOf('#') + 1;
|
||||
var base = data.href.slice(0, i);
|
||||
var hrefsecret = Hash.getSecrets(parsed.type, parsed.hash, data.password);
|
||||
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) {
|
||||
if (!e.target || !$(e.target).parents('.cp-dropdown-content').length) { return; }
|
||||
@@ -2717,19 +2704,16 @@ 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;
|
||||
if (!data || !(data.href || data.roHref)) { return void cb('INVALID_FILE'); }
|
||||
|
||||
var roUrl;
|
||||
if (ro) {
|
||||
data.roHref = data.href;
|
||||
delete data.href;
|
||||
} else {
|
||||
roUrl = getReadOnlyUrl(el);
|
||||
if (roUrl) { data.roHref = base + roUrl; }
|
||||
if (data.href) {
|
||||
data.href = base + data.href;
|
||||
}
|
||||
if (data.roHref) {
|
||||
data.roHref = base + data.roHref;
|
||||
}
|
||||
|
||||
UIElements.getProperties(common, data, cb);
|
||||
@@ -2804,10 +2788,15 @@ define([
|
||||
else if ($(this).hasClass('cp-app-drive-context-openro')) {
|
||||
paths.forEach(function (p) {
|
||||
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 href;
|
||||
if (filesOp.isPathIn(p.path, [FILES_DATA])) {
|
||||
href = el.roHref;
|
||||
} else {
|
||||
if (!el || filesOp.isFolder(el)) { return; }
|
||||
var data = filesOp.getFileData(el);
|
||||
href = data.roHref;
|
||||
}
|
||||
openFile(null, href);
|
||||
});
|
||||
}
|
||||
else if ($(this).hasClass('cp-app-drive-context-newfolder')) {
|
||||
@@ -2847,7 +2836,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")) {
|
||||
|
||||
@@ -237,7 +237,8 @@ define([
|
||||
&& typeof files.template[0] === "number"
|
||||
&& typeof files.filesData[files.template[0]] === "object"
|
||||
&& !files.filesData[files.template[0]].filename
|
||||
&& files.filesData[files.template[0]].href === href3
|
||||
&& !files.filesData[files.template[0]].href
|
||||
&& files.filesData[files.template[0]].roHref === href3
|
||||
&& typeof fileId2 === "number"
|
||||
&& typeof files.filesData[fileId2] === "object"
|
||||
&& files.filesData[fileId2].filename === "Trash"
|
||||
@@ -392,11 +393,6 @@ define([
|
||||
console.log("DRIVE operations: rename");
|
||||
return cb();
|
||||
}
|
||||
fo.replace(href1, href2);
|
||||
if (fo.getFileData(id1).href !== href2) {
|
||||
console.log("DRIVE operations: replace");
|
||||
return cb();
|
||||
}
|
||||
|
||||
cb(true);
|
||||
}, "DRIVE operations");
|
||||
|
||||
Reference in New Issue
Block a user