Update, and fix problem where the author patched the previous patch for hosting on other ports

This commit is contained in:
DUOLabs333
2022-04-25 19:29:38 -04:00
parent e2b23cefdc
commit af8387e39e
10 changed files with 16873 additions and 23381 deletions
+1 -1
View File
@@ -128,7 +128,7 @@ def find_and_replace(file,find,replace):
pp.write(file1) pp.write(file1)
#Allow any port to be used #Allow any port to be used
find_and_replace('code/pp/pp.js','8887','') find_and_replace('code/pp/pp.js','"\'$!|"))','"\'$!|"))||true')
#Don't load Google Analytics #Don't load Google Analytics
find_and_replace('index.html','//www.google-analytics.com/analytics.js','') find_and_replace('index.html','//www.google-analytics.com/analytics.js','')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4
View File
@@ -0,0 +1,4 @@
def hi():
return False or True
print(hi())
+13898 -13663
View File
File diff suppressed because one or more lines are too long
@@ -1,367 +1,472 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script> <script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
</head> <script src="https://accounts.google.com/gsi/client" async defer></script>
<body onload="go()"> </head>
<body onload="go()">
<script type="text/javascript"> <script type="text/javascript">
var sentFalse = false; var sentFalse = false;
var clientId = "463342976776-04ub3ijsr7i5qobn8ha32ap6vsaae75a.apps.googleusercontent.com"; var clientId = '463342976776-04ub3ijsr7i5qobn8ha32ap6vsaae75a.apps.googleusercontent.com';
var scope = 'https://www.googleapis.com/auth/drive'; var scope = 'https://www.googleapis.com/auth/drive';
var discoveryDocs = ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest']; var discoveryDocs = 'https://www.googleapis.com/discovery/v1/apis/drive/v3/rest';
var oauthToken;
var GoogleAuth;
function go() var client;
var isShared = false;
var sharedDrives = null;
function go()
{
var queryString = window.location.search;
var urlParams = new URLSearchParams(queryString);
if(urlParams.get('sharedDrive') == 'true') isShared = true;
window.addEventListener("message", onMessage, false);
gapi.load('client', gapiInit);
}
function saveToken(e)
{
localStorage.setItem("googledriveAccessToken", e.access_token);
localStorage.setItem("googledriveAccessTokenValidUntil", Date.now() + e.expires_in * 1000);
send("ready", true);
}
function gapiInit() {
gapi.client.init({})
.then(function() {
gapi.client.load(discoveryDocs)
.then(function() {
client = google.accounts.oauth2.initTokenClient({
client_id: clientId,
scope: scope,
callback: saveToken,
});
if(Date.now() < localStorage.getItem("googledriveAccessTokenValidUntil"))
{
gapi.client.setToken({ "access_token" : localStorage.getItem("googledriveAccessToken") });
send("ready", true);
}
else
{
send("ready", false);
sentFalse = true;
}
})
.catch(function(e) {handleError(e); });
})
.catch(function(e) {handleError(e); });
}
function handleError(e)
{
console.log(e);
if(e.result && e.result.error && e.result.error.code)
{ {
gapi.load('client:auth2', {'callback': onAuthApiLoad}); if(e.result.error.code == 403) {send("ready",false); sentFalse = true;}
} if(e.result.error.code == 401) {send("ready",false); sentFalse = true;}
}
function handleError(e) else if (e.error)
{ {
console.log(e); if(e.error == "access_denied") {send("ready",false); sentFalse = true;}
if(e.result && e.result.error && e.result.error.code) if(e.error == "popup_closed_by_user") {send("ready",false); sentFalse = true;}
if(e.error == "popup_blocked_by_browser") {send("ready",false); sentFalse = true;}
if(e.error == "multiple_colons") {send(1,"Rename path contains more than one colon.");}
}
}
function authorize(action,prms)
{
sentFalse = false;
client.requestAccessToken();
}
function getSharedDriveId(name)
{
for(var i = 0; i < sharedDrives.length; ++i)
{
if(sharedDrives[i].name == name) return sharedDrives[i].id;
}
return null;
}
function findFile(action, path, id, pageToken, buffer)
{
if(!id)
{
if(!isShared) id = "root";
else if(path.length == 1 && path[0] == "")
{ {
if(e.result.error.code == 403) {send("ready",false); sentFalse = true;} listDrives(null, []);
if(e.result.error.code == 401) {send("ready",false); sentFalse = true;} return;
} }
else if (e.error) else
{ {
if(e.error == "access_denied") {send("ready",false); sentFalse = true;} id = getSharedDriveId(path[0]);
if(e.error == "popup_closed_by_user") {send("ready",false); sentFalse = true;} path = path.slice(1);
if(e.error == "popup_blocked_by_browser") {send("ready",false); sentFalse = true;}
if(e.error == "multiple_colons") {send(1,"Rename path contains more than one colon.");}
} }
} }
function authorize(action,prms) if(!id) { handleError({"error" : "no_id"}); return; }
if(path.length == 0 || path[0] == '')
{ {
sentFalse = false; if(action == listDir)
GoogleAuth.signIn() {
.then(function () { var query = "'" + id + "' in parents";
send("ready",true); action(null, query, []);
if(action) { findFile(action, prms.path.slice(1).split("/"), null, null, prms.buffer); } }
}) else { action(id); }
.catch(function(e) { return;
handleError(e); }
}); if(path.length == 1 && action == createDir)
{
action(id,path[0]);
return;
}
if(path.length == 1 && action == checkFile)
{
action(id, path[0], null, buffer);
return;
} }
function onAuthApiLoad() var newFile = null;
{ if(path.length == 1 && action == renameFile)
window.addEventListener("message", onMessage, false); {
gapi.client.init({ var prmSplit = path[0].split(":");
clientId: clientId, if (prmSplit.length > 2) { handleError({"error" : "multiple_colons"}); return; }
scope: scope, else { path[0] = prmSplit[0]; newFile = prmSplit[1]; }
discoveryDocs :discoveryDocs }
})
.then(function () {
GoogleAuth = gapi.auth2.getAuthInstance();
if(!GoogleAuth.isSignedIn.get()) { sentFalse = true; send("ready",false); }
else { send("ready",true); }
})
.catch(handleError);
}
function findFile(action, path, id, pageToken, buffer) var query = "'" + id + "' in parents";
{ var req = {
if(!id) id = "root"; 'q': query,
if(path.length == 0 || path[0] == '') 'pageToken' : pageToken,
{ 'pageSize': 1000,
if(action == listDir) 'fields': "nextPageToken, files(id, name, size, modifiedTime, kind, mimeType, trashed)",};
{ if(isShared)
var query = "'" + id + "' in parents"; {
action(null, query, []); req['supportsAllDrives'] = true;
} req['includeItemsFromAllDrives'] = true;
else { action(id); } }
return; gapi.client.drive.files.list(req)
} .then(function(response) {
if(path.length == 1 && action == createDir) var files = response.result.files;
{ pageToken = response.result.nextPageToken;
action(id,path[0]); var found = false;
return; for (var i = 0; i < files.length; ++i)
} {
if(path.length == 1 && action == checkFile) if(files[i].trashed) continue;
{ if(files[i].name == path[0])
action(id, path[0], null, buffer); {
return; found = true;
} if(newFile && action == renameFile) { renameFile(files[i].id, newFile); return; }
else { findFile(action, path.slice(1), files[i].id, null, buffer); return; }
}
}
if(!found && pageToken) findFile(action, path, id, pageToken, buffer);
else if(action == checkFile) newFile(id,path[0],buffer);
else if(action == renameFile) { handleError("Could not find file to rename '"+path[0]+"'"); send(1, "Could not find file to rename '"+path[0]+"'"); }
})
.catch(handleError);
}
var newFile = null; function listDrives(pageToken, out)
if(path.length == 1 && action == renameFile) {
{ gapi.client.drive.drives.list(
var prmSplit = path[0].split(":"); {
if (prmSplit.length > 2) { handleError({"error" : "multiple_colons"}); return; } 'pageToken' : pageToken,
else { path[0] = prmSplit[0]; newFile = prmSplit[1]; } 'pageSize' : 50,
} fields: 'nextPageToken, drives(id, name, createdTime)',})
.then(function(response) {
var drives = response.result.drives;
sharedDrives = response.result.drives;
pageToken = response.result.nextPageToken;
for(var i = 0; i < drives.length; ++i)
{
out.push([drives[i].name, -1, Math.round(Date.parse(drives[i].createdTime)/1000)])
}
if(pageToken) listDir(pageToken,query,out);
else { send(0,out); }
})
.catch(handleError);
}
var query = "'" + id + "' in parents"; function listDir(pageToken, query, out)
{
gapi.client.drive.files.list({ var req = {
'q': query, 'q': query,
'pageToken' : pageToken, 'pageToken' : pageToken,
'pageSize': 1000, 'pageSize': 1000,
'fields': "nextPageToken, files(id, name, size, modifiedTime, kind, mimeType)",}) 'fields': "nextPageToken, files(id, name, size, modifiedTime, kind, mimeType, thumbnailLink, trashed)",};
.then(function(response) { if(isShared)
var files = response.result.files; {
pageToken = response.result.nextPageToken; req['supportsAllDrives'] = true;
var found = false; req['includeItemsFromAllDrives'] = true;
for (var i = 0; i < files.length; ++i) }
{ gapi.client.drive.files.list(req)
if(files[i].name == path[0]) .then(function(response) {
{ var files = response.result.files;
found = true; pageToken = response.result.nextPageToken;
if(newFile && action == renameFile) { renameFile(files[i].id, newFile); return; } for(var i = 0; i<files.length; ++i)
else { findFile(action, path.slice(1), files[i].id, null, buffer); return; } {
} if(files[i].trashed) continue;
} else if(files[i].mimeType == "application/vnd.google-apps.folder") { out.push([files[i].name, -1, Math.round(Date.parse(files[i].modifiedTime)/1000)]); }
if(!found && pageToken) findFile(action, path, id, pageToken, buffer); else if(files[i].mimeType.includes("application/vnd.google-apps.")) { }
else if(action == checkFile) newFile(id,path[0],buffer); else
else if(action == renameFile) { handleError("Could not find file to rename '"+path[0]+"'"); send(1, "Could not find file to rename '"+path[0]+"'"); } {
}) if(files[i].thumbnailLink) { out.push([files[i].name,files[i].size ? parseInt(files[i].size) : 0, Math.round(Date.parse(files[i].modifiedTime)/1000), files[i].thumbnailLink]); }
.catch(handleError);
}
function listDir(pageToken, query, out)
{
gapi.client.drive.files.list({
'q': query,
'pageToken' : pageToken,
'pageSize': 1000,
'fields': "nextPageToken, files(id, name, size, modifiedTime, kind, mimeType, thumbnailLink)",})
.then(function(response) {
var files = response.result.files;
pageToken = response.result.nextPageToken;
for(var i = 0; i<files.length; ++i)
{
if(files[i].mimeType == "application/vnd.google-apps.folder") { out.push([files[i].name, -1, Math.round(Date.parse(files[i].modifiedTime)/1000)]); }
else if(files[i].mimeType.includes("application/vnd.google-apps.")) { }
else
{
if(files[i].thumbnailLink) { out.push([files[i].name,files[i].size ? parseInt(files[i].size) : 0, Math.round(Date.parse(files[i].modifiedTime)/1000), files[i].thumbnailLink]); }
//but maybe we should only show thumbnail to files which Photopea can open - Gdrive also makes thumbnails for spreadsheets etc. //but maybe we should only show thumbnail to files which Photopea can open - Gdrive also makes thumbnails for spreadsheets etc.
else { out.push([files[i].name,parseInt(files[i].size), Math.round(Date.parse(files[i].modifiedTime)/1000)]); } else { out.push([files[i].name,parseInt(files[i].size), Math.round(Date.parse(files[i].modifiedTime)/1000)]); }
} }
} }
if(pageToken) listDir(pageToken,query,out); if(pageToken) listDir(pageToken,query,out);
else { send(0,out); } else { send(0,out); }
}) })
.catch(handleError); .catch(handleError);
} }
function downloadFile(fileId) function downloadFile(fileId)
{ {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', "https://www.googleapis.com/drive/v3/files/" + fileId + "?alt=media"); var shared = "";
xhr.responseType = "arraybuffer"; if(isShared) shared = "&supportsAllDrives=true";
xhr.setRequestHeader('Authorization', 'Bearer ' + GoogleAuth.currentUser.get().getAuthResponse().access_token); xhr.open('GET', "https://www.googleapis.com/drive/v3/files/" + fileId + "?alt=media" + shared);
xhr.onload = function(e) {window.parent.postMessage(e.target.response,"*"); }; xhr.responseType = "arraybuffer";
xhr.onerror = function(e) { console.error(e); }; xhr.setRequestHeader('Authorization', 'Bearer ' + gapi.client.getToken().access_token);
xhr.send(); xhr.onload = function(e) {window.parent.postMessage(e.target.response,"*"); };
} xhr.onerror = function(e) { console.error(e); };
xhr.send();
}
function downloadThumbnail(fileId) function downloadThumbnail(fileId)
{ {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', "https://www.googleapis.com/drive/v3/files/" + fileId + "?fields=thumbnailLink"); var shared = "";
xhr.setRequestHeader('Authorization', 'Bearer ' + GoogleAuth.currentUser.get().getAuthResponse().access_token); if(isShared) shared = "&supportsAllDrives=true";
xhr.onload = function(e) xhr.open('GET', "https://www.googleapis.com/drive/v3/files/" + fileId + "?fields=thumbnailLink" + shared);
{ xhr.setRequestHeader('Authorization', 'Bearer ' + gapi.client.getToken().access_token);
var link = JSON.parse(e.target.response).thumbnailLink; xhr.onload = function(e)
console.log(JSON.parse(e.target.response)); {
if (link) var link = JSON.parse(e.target.response).thumbnailLink;
{ console.log(JSON.parse(e.target.response));
var xhr2 = new XMLHttpRequest(); if (link)
xhr2.open('GET', link); {
xhr2.responseType = "arraybuffer"; var xhr2 = new XMLHttpRequest();
xhr2.onload = function(e) {window.parent.postMessage(e.target.response,"*"); }; xhr2.open('GET', link);
xhr2.onerror = function(e) { console.error(e); }; xhr2.responseType = "arraybuffer";
xhr2.send(); xhr2.onload = function(e) {window.parent.postMessage(e.target.response,"*"); };
} xhr2.onerror = function(e) { console.error(e); };
else { console.error("Could not get thumbnailLink."); } xhr2.send();
}; }
xhr.onerror = function(e) { console.error(e); }; else { console.error("Could not get thumbnailLink."); }
xhr.send(); };
} xhr.onerror = function(e) { console.error(e); };
xhr.send();
}
function deleteFile(fileId) function deleteFile(fileId)
{ {
gapi.client.drive.files.delete({ if(isShared) { trashFile(fileId); return; }
'fileId' : fileId, var req = { 'fileId' : fileId, };
}) if(isShared) req['supportsAllDrives'] = true;
.then(function(response) { gapi.client.drive.files.delete(req)
send(0,""); .then(function(response) {
}) send(0,"");
.catch(function(response) { })
send(1,response); .catch(function(response) {
handleError(response); send(1,response);
}); handleError(response);
} });
}
function createDir(parentId, name) function trashFile(fileId)
{ {
gapi.client.drive.files.create( var req = {
{ 'fileId' : fileId,
'resource' : 'resource' :
{ {
'name' : name, 'trashed' : true,
'parents' : [parentId], }
'mimeType': 'application/vnd.google-apps.folder', };
} if(isShared) req['supportsAllDrives'] = true;
}) gapi.client.drive.files.update(req)
.then(function(response) { .then(function(response) {
send(0,""); send(0,"");
}) })
.catch(function(response) { .catch(function(response) {
send(1,response); send(1,response);
handleError(response); handleError(response);
}); });
} }
function renameFile(fileId, newName) function createDir(parentId, name)
{ {
gapi.client.drive.files.update({ var req = {
'fileId' : fileId, 'resource' :
'resource' : {
{ 'name' : name,
'name' : newName, 'parents' : [parentId],
} 'mimeType': 'application/vnd.google-apps.folder',
}) }
.then(function(response) { }
send(0,""); if(isShared) req['supportsAllDrives'] = true;
}) gapi.client.drive.files.create( req )
.catch(function(response) { .then(function(response) {
send(1,response); send(0,"");
handleError(response); })
}); .catch(function(response) {
} send(1,response);
handleError(response);
});
}
function renameFile(fileId, newName)
{
var req = {
'fileId' : fileId,
'resource' :
{
'name' : newName,
}
};
if(isShared) req['supportsAllDrives'] = true;
gapi.client.drive.files.update(req)
.then(function(response) {
send(0,"");
})
.catch(function(response) {
send(1,response);
handleError(response);
});
}
//check if file exists, then overwrite, otherwise create new file. //check if file exists, then overwrite, otherwise create new file.
function checkFile(parentId, name, pageToken, buffer) function checkFile(parentId, name, pageToken, buffer)
{ {
var query = "'" + parentId + "' in parents"; var query = "'" + parentId + "' in parents";
gapi.client.drive.files.list({ var req = {
'q': query, 'q': query,
'pageToken' : pageToken, 'pageToken' : pageToken,
'pageSize': 1000, 'pageSize': 1000,
'fields': "nextPageToken, files(id, name)",}) 'fields': "nextPageToken, files(id, name, trashed)",};
.then(function(response) { if(isShared)
var files = response.result.files; {
pageToken = response.result.nextPageToken; req['supportsAllDrives'] = true;
var found = false; req['includeItemsFromAllDrives'] = true;
for (var i = 0; i < files.length; ++i) }
{ gapi.client.drive.files.list(req)
if(files[i].name == name) .then(function(response) {
{ var files = response.result.files;
found = true; pageToken = response.result.nextPageToken;
uploadFile(files[i].id,parentId,name,buffer); var found = false;
return; for (var i = 0; i < files.length; ++i)
} {
} if(files[i].trashed) continue;
if(!found && pageToken) checkFile(parentId, name, pageToken, buffer); if(files[i].name == name)
else uploadFile(null,parentId,name,buffer); {
}) found = true;
.catch(handleError); uploadFile(files[i].id,parentId,name,buffer);
} return;
}
function uploadFile(fileId, parentId, name, buffer) }
{ if(!found && pageToken) checkFile(parentId, name, pageToken, buffer);
var file = new Blob([buffer]); else uploadFile(null,parentId,name,buffer);
var metadata = { 'name': name, }; })
if(!fileId) metadata['parents'] = [parentId]; .catch(handleError);
var xhr = new XMLHttpRequest();
if(buffer.byteLength > 5000000)
{
var contentType = file.type || 'application/octet-stream';
metadata['mimeType'] = contentType;
metadata['Content-Type'] = contentType;
metadata['Content-Length'] = file.size;
if(!fileId) xhr.open("POST", "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable");
else xhr.open("PATCH", "https://www.googleapis.com/upload/drive/v3/files/" + fileId + "?uploadType=resumable");
xhr.setRequestHeader('Authorization', 'Bearer ' + GoogleAuth.currentUser.get().getAuthResponse().access_token);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('X-Upload-Content-Length', file.size);
xhr.setRequestHeader('X-Upload-Content-Type', contentType);
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
var locationUrl = xhr.getResponseHeader('Location');
var reader = new FileReader();
reader.onload = function(e) {
var xhr2 = new XMLHttpRequest();
xhr2.open('PUT', locationUrl, true);
xhr2.setRequestHeader('Content-Type', contentType);
xhr2.setRequestHeader('X-Upload-Content-Type', contentType);
xhr2.onreadystatechange = function() {
if(xhr2.readyState === XMLHttpRequest.DONE && xhr2.status === 200) {
send(0,"");
}
};
xhr2.onerror = function(e) { send(1,e); handleError(e)};
xhr2.send(reader.result);
};
reader.readAsArrayBuffer(file);
}
};
xhr.onerror = function(e) { send(1,e); handleError(e)};
xhr.send(JSON.stringify(metadata));
} }
else
function uploadFile(fileId, parentId, name, buffer)
{ {
var form = new FormData(); var file = new Blob([buffer]);
form.append('metadata', new Blob([JSON.stringify(metadata)], { type: 'application/json' })); var metadata = { 'name': name, };
form.append('file', file); if(!fileId) metadata['parents'] = [parentId];
if(!fileId) xhr.open('POST', 'https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id'); var xhr = new XMLHttpRequest();
else xhr.open('PATCH', 'https://www.googleapis.com/upload/drive/v3/files/' + fileId + '?uploadType=multipart&fields=id'); if(buffer.byteLength > 5000000)
xhr.setRequestHeader('Authorization', 'Bearer ' + GoogleAuth.currentUser.get().getAuthResponse().access_token); {
xhr.onload = function(response) { send(0,""); }; var contentType = file.type || 'application/octet-stream';
xhr.onerror = function(e) { send(1,e); handleError(e)}; metadata['mimeType'] = contentType;
xhr.send(form); metadata['Content-Type'] = contentType;
} metadata['Content-Length'] = file.size;
} var shared = "";
if(isShared) shared = "&supportsAllDrives=true";
if(!fileId) xhr.open("POST", "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable" + shared);
else xhr.open("PATCH", "https://www.googleapis.com/upload/drive/v3/files/" + fileId + "?uploadType=resumable" + shared);
xhr.setRequestHeader('Authorization', 'Bearer ' + gapi.client.getToken().access_token);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('X-Upload-Content-Length', file.size);
xhr.setRequestHeader('X-Upload-Content-Type', contentType);
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
var locationUrl = xhr.getResponseHeader('Location');
var reader = new FileReader();
reader.onload = function(e) {
var xhr2 = new XMLHttpRequest();
function signOutUser() xhr2.open('PUT', locationUrl, true);
{ xhr2.setRequestHeader('Content-Type', contentType);
GoogleAuth.signOut().then(function () { xhr2.setRequestHeader('X-Upload-Content-Type', contentType);
//console.log('User signed out.'); xhr2.onreadystatechange = function() {
send(0,""); if(xhr2.readyState === XMLHttpRequest.DONE && xhr2.status === 200) {
}) send(0,"");
.catch(handleError); }
} };
xhr2.onerror = function(e) { send(1,e); handleError(e)};
xhr2.send(reader.result);
};
reader.readAsArrayBuffer(file);
}
};
xhr.onerror = function(e) { send(1,e); handleError(e)};
xhr.send(JSON.stringify(metadata));
}
else
{
var form = new FormData();
form.append('metadata', new Blob([JSON.stringify(metadata)], { type: 'application/json' }));
form.append('file', file);
var shared = "";
if(isShared) shared = "&supportsAllDrives=true";
if(!fileId) xhr.open('POST', 'https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id' + shared);
else xhr.open('PATCH', 'https://www.googleapis.com/upload/drive/v3/files/' + fileId + '?uploadType=multipart&fields=id' + shared);
xhr.setRequestHeader('Authorization', 'Bearer ' + gapi.client.getToken().access_token);
xhr.onload = function(response) { send(0,""); };
xhr.onerror = function(e) { send(1,e); handleError(e)};
xhr.send(form);
}
}
function disconnectUser() function signOutUser()
{ {
GoogleAuth.disconnect().then(function () { localStorage.removeItem("googledriveAccessToken");
//console.log('User account disconnected.'); localStorage.removeItem("googledriveAccessTokenValidUntil");
send(0,""); var cred = gapi.client.getToken();
}) if (cred !== null) {
.catch(handleError); google.accounts.oauth2.revoke(cred.access_token, () => {console.log('Revoked: ' + cred.access_token)});
} gapi.client.setToken('');
}
}
function doAction(action, prms) function doAction(action, prms)
{ {
if(action == signOutUser) { signOutUser(); } if(action == signOutUser) { signOutUser(); }
//if(action == signOutUser) { disconnectUser(); } else if(sentFalse) { authorize(action, prms); }
else if(sentFalse) { authorize(action, prms); } else if(!gapi.client.getToken()) { send("ready", false); sentFalse = true; }
else if(!GoogleAuth.isSignedIn.get()) { send("ready", false); sentFalse = true; } else { findFile(action, prms.path.slice(1).split("/"), null, null, prms.buffer); }
else if(!GoogleAuth.currentUser.get().hasGrantedScopes(scope)) { send("ready", false); sentFalse = true; } }
else { findFile(action, prms.path.slice(1).split("/"), null, null, prms.buffer); }
}
function onMessage(e) { function onMessage(e) {
if(e.origin && (e.origin == "https://accounts.google.com" || e.origin == "https://content.googleapis.com")) { return; } if(e.origin && (e.origin == "https://accounts.google.com" || e.origin == "https://content.googleapis.com")) { return; }
if((typeof e.data) == "string") { if((typeof e.data) == "string") {
var msg = JSON.parse(e.data); var msg = JSON.parse(e.data);
console.log(msg); console.log(msg);
//TODO: cannot list directory if name contains forwardslash //TODO: cannot list directory if name contains forwardslash
if(msg.code=="show") { doAction(listDir, { "path" : msg.prm }) } if(msg.code=="show") { doAction(listDir, { "path" : msg.prm }) }
else if(msg.code=="load") { doAction(downloadFile, { "path" : msg.prm }); } else if(msg.code=="load") { doAction(downloadFile, { "path" : msg.prm }); }
//else if(msg.code=="load") { doAction(downloadThumbnail, { "path" : msg.prm }); }
else if(msg.code=="delete") { doAction(deleteFile, { "path" : msg.prm }); } else if(msg.code=="delete") { doAction(deleteFile, { "path" : msg.prm }); }
else if(msg.code=="save" && msg.prm.endsWith("/")) { doAction(createDir, { "path" : msg.prm.slice(0, -1) }); } else if(msg.code=="save" && msg.prm.endsWith("/")) { doAction(createDir, { "path" : msg.prm.slice(0, -1) }); }
//TODO: will not work if filename contains colon(s) //TODO: will not work if filename contains colon(s)
@@ -378,8 +483,8 @@
window.parent.postMessage(JSON.stringify({"code":code, "prm":prm}),"*"); window.parent.postMessage(JSON.stringify({"code":code, "prm":prm}),"*");
} }
</script> </script>
</body> </body>
</html> </html>
+9 -29
View File
@@ -10,29 +10,9 @@
<title>Photopea | Online Photo Editor</title> <title>Photopea | Online Photo Editor</title>
<!-- Facebook Pixel Code -->
<script>
window.addEventListener("load",function() {
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'/en_US/fbevents.js');
fbq('init', '2503069689824081');
fbq('track', 'PageView');
},false);
</script>
<noscript><img height="1" width="1" style="display:none"
src="/tr?id=2503069689824081&ev=PageView&noscript=1"
/></noscript>
<!-- End Facebook Pixel Code -->
<link rel="apple-touch-icon" href="promo/icon512.png"> <link rel="apple-touch-icon" href="promo/icon512.png">
<link rel="icon" sizes="256x256" href="promo/thumb256.png"> <link rel="icon" sizes="512x512" href="promo/icon512.png">
<link rel="image_src" type="image/png" href="promo/thumb256.png" /> <link rel="image_src" type="image/png" href="promo/icon512.png" />
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
<link rel="chrome-webstore-item" href="//chrome.google.com/webstore/detail/fmophgdjdipcbfjiopifpngdjmemonko"> <link rel="chrome-webstore-item" href="//chrome.google.com/webstore/detail/fmophgdjdipcbfjiopifpngdjmemonko">
@@ -66,7 +46,7 @@
<!----> <!---->
<div id="cap"> <div id="cap">
<span style="position:absolute;right:0;top:0;font-size:7em;margin:0 0.2em;cursor:pointer;" onclick="hideCap()"></span> <span style="position:absolute;right:0;top:0;font-size:7em;margin:0 0.2em;cursor:pointer;" onclick="hideCap()"></span>
<img style="width:8em; height:8em; margin-top:1em;" src="promo/thumb256.png" alt="Photopea logo" /> <img style="width:8em; height:8em; margin-top:1em;" src="promo/icon512.png" alt="Photopea logo" />
<h1>Photopea: advanced photo editor</h1> <h1>Photopea: advanced photo editor</h1>
<p style="font-size:1.3em">Free online photo editor supporting <b>PSD</b>, <b>XCF</b>, <b>Sketch</b>, <b>XD</b> and <b>CDR</b> formats. <p style="font-size:1.3em">Free online photo editor supporting <b>PSD</b>, <b>XCF</b>, <b>Sketch</b>, <b>XD</b> and <b>CDR</b> formats.
(<b>Adobe Photoshop</b>, <b>GIMP</b>, <b>Sketch App</b>, <b>Adobe XD</b> and <b>CorelDRAW</b>).</p> (<b>Adobe Photoshop</b>, <b>GIMP</b>, <b>Sketch App</b>, <b>Adobe XD</b> and <b>CorelDRAW</b>).</p>
@@ -86,14 +66,14 @@
<script src="code/dbs/DBS.js"></script> <script src="code/dbs/DBS.js"></script>
<script src="code/pp/pp.js"></script> <script src="code/pp/pp.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-4249565-37"></script>
<script> <script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ window.dataLayer = window.dataLayer || [];
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), function gtag(){dataLayer.push(arguments);}
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) gtag("js", new Date()); gtag("config", "UA-4249565-37");
})(window,document,'script','','ga');
ga('create', 'UA-4249565-37', 'photopea.com');
ga('send', 'pageview');
</script> </script>
</body> </body>
</html> </html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+71 -34
View File
@@ -181,10 +181,20 @@
} }
.toolbar .tools .toolbtn { .toolbar .tools .toolbtn {
border-radius:3px; border-radius:6px;
margin:2px 3px 1px 3px; margin:2px 1px 1px 1px;
padding:4px 4px; padding:4px 4px;
} }
.toolbar .tools .toolbtn:hover, .toolbar .tools .active {
background-color: var(--bg-bbtn);
}
.toolbar .tools .active {
border-left-width:3px;
border-left-color: var(--accent);
margin-left:-2px;
border-top-left-radius:0;
border-bottom-left-radius:0;
}
.toolbar .tools button { position:relative; } .toolbar .tools button { position:relative; }
.toolbar .tools button img .toolbar .tools button img
@@ -301,6 +311,8 @@
} }
.block .panelhead .label { .block .panelhead .label {
pointer-events: none; pointer-events: none;
margin: 4px 7px 0 7px;
line-height:1.9em;
} }
.mainblock .panelhead, .float .panelhead { .mainblock .panelhead, .float .panelhead {
@@ -316,7 +328,8 @@
.block .panelhead div .block .panelhead div
{ {
padding:0.2em 0.5em 0.25em 0.5em; height:26.1px;
/*padding:0.2em 0.5em 0.25em 0.5em;*/
display:inline-block; display:inline-block;
border-top-left-radius:4px; border-top-left-radius:4px;
border-top-right-radius:4px; border-top-right-radius:4px;
@@ -343,16 +356,15 @@
.block .panelhead div .cross .block .panelhead div .cross
{ {
cursor: pointer;
display:inline-block;
background-image: var(--icon_cross); background-image: var(--icon_cross);
filter: invert( var(--icon_cross_invrt) ); background-size: 10px 10px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center; background-position: center;
background-size: cover; /* Generic*/ width: 26px;
margin: 0.2em 0.2em 0 0.8em; height: 26px;
display:inline-block; vertical-align:top;
width: 0.8em;
height: 0.8em;
cursor: pointer;
} }
@@ -723,11 +735,25 @@
padding: 3px; padding: 3px;
box-sizing: border-box; box-sizing: border-box;
} }
/*
input, textarea, select { input, textarea, select {
background-color: var(--bg-input); background-color: var(--bg-input);
color: var(--text-color); color: var(--text-color);
border-radius: 3px; border-radius: 3px;
}*/
input, textarea, select {
background-color: var(--bg-input);
color: var(--text-color);
border-radius: 3px;
border: 1px solid var(--bg-input);
transition: border 0.5s;
} }
input:hover, textarea:hover, select:hover, input:focus, textarea:focus, select:focus {
border: 1px solid var(--accent); /* perhaps replace with var(--accent-color) */
outline: none!important;
}
textarea { vertical-align:top; } textarea { vertical-align:top; }
@@ -740,11 +766,17 @@
/*box-shadow: inset 0 0 60px rgba(0,0,0,0.5)*/ /*box-shadow: inset 0 0 60px rgba(0,0,0,0.5)*/
} }
.rangecontFloat { .rangecontFloat, .floatcont {
background-color: var(--base); background-color: var(--base);
border-radius:6px;
box-shadow: 0px 0px 20px rgba(0,0,0,0.25);
}
.rangecontFloat {
padding: 3px 8px 4px 8px; padding: 3px 8px 4px 8px;
border-radius:5px; }
border-width:1px; .floatcont {
padding:7px;
/*box-shadow: 0px 8px 40px rgba(0,0,0,0.35);*/
} }
.mbox input { .mbox input {
@@ -987,11 +1019,12 @@ input[type="checkbox"]:checked + label:before { content: "\2713"; }
z-index: 10; z-index: 10;
background-color: var(--base); background-color: var(--base);
/*border: 1px solid;*/ /*border: 1px solid;*/
border-radius:6px;
min-width : 3em; min-width : 3em;
min-height: 2em; min-height: 2em;
top: 150px; top: 150px;
left: 150px; left: 150px;
box-shadow: 0px 8px 40px rgba(0,0,0,0.2); box-shadow: 0px 4px 30px rgba(0,0,0,0.25);
} }
.wdisabled { .wdisabled {
@@ -1005,32 +1038,41 @@ input[type="checkbox"]:checked + label:before { content: "\2713"; }
.window .whead .window .whead
{ {
font-size: 1.3em; border-top-width: 1px;
color: #ffffff; border-top-color: var(--brdrLgt);
background: linear-gradient(to bottom, #595959 0%,#626262 3%,#575757 7%,#3c3c3c 90%,#3a3a3a 97%,#2e2e2e 100%); border-bottom-width: 1px;
border-bottom-color:var(--brdrDrk);
height:30px;
font-size: 1.15em;
background: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, rgba(0,0,0,0.25) 100%);
/*background: linear-gradient(to bottom, #2b2b2b 0%, #282828 50%, #262626 100%);*/
/*background: linear-gradient(to bottom, #595959 0%,#626262 3%,#575757 7%,#3c3c3c 90%,#3a3a3a 97%,#2e2e2e 100%);*/
/*background: linear-gradient(to bottom, #59574e 0%,#626055 3%,#59574f 7%,#403f3a 90%,#41403b 97%,#383734 100%);*/ /*background: linear-gradient(to bottom, #59574e 0%,#626055 3%,#59574f 7%,#403f3a 90%,#41403b 97%,#383734 100%);*/
background-size: auto 100%; border-top-left-radius:6px;
border-top-right-radius:6px;
} }
.window .whead .wname .window .whead .wname
{ {
display: inline-block; display: inline-block;
padding: 0.3em 0.5em; padding: 0.3em 0.5em;
text-shadow: 0 -1px 0 rgba(0,0,0,0.45);
font-weight: bold; font-weight: bold;
} }
.window .whead .cross .window .whead .cross
{ {
width:0.8em;
height:0.8em;
display:inline-block;
background-size: cover;
font-size: 1.3em;
margin: 0.3em;
position:absolute; right:0;
/*float : right;*/
cursor: pointer; cursor: pointer;
display:inline-block;
background-image: var(--icon_cross);
background-size: 10px 10px;
background-repeat: no-repeat;
background-position: center;
width:30px;
height:30px;
font-size: 1.3em;
position:absolute; right:0;
} }
@@ -1075,6 +1117,7 @@ input[type="checkbox"]:checked + label:before { content: "\2713"; }
height:512px;*/ height:512px;*/
/*background-color: rgba(0,0,0,0.1);*/ /*background-color: rgba(0,0,0,0.1);*/
text-shadow:none; text-shadow:none;
/* keep it because of SVG */
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAAXNSR0IB2cksfwAAAAZQTFRF////yMjIXOIDQgAAABJJREFUeJxjYPjPgBXhEB7uAABycQ/xMT/uAgAAAABJRU5ErkJggg==); background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAAXNSR0IB2cksfwAAAAZQTFRF////yMjIXOIDQgAAABJJREFUeJxjYPjPgBXhEB7uAABycQ/xMT/uAgAAAABJRU5ErkJggg==);
} }
@@ -1208,13 +1251,7 @@ input[type="checkbox"]:checked + label:before { content: "\2713"; }
margin-right: 1.2em; margin-right: 1.2em;
} }
.floatcont
{
padding:0.5em;
background-color:var(--base);
border-width: 1px;
/*box-shadow: 0px 8px 40px rgba(0,0,0,0.35);*/
}
/* cyrillic-ext */ /* cyrillic-ext */
@font-face { @font-face {
font-display: swap; font-display: swap;