Skip to content
Snippets Groups Projects
Commit 3c574688 authored by Constant VENNIN's avatar Constant VENNIN
Browse files

ciofjfdvzbjhzv

parents 1e1c3e6d 3b1fa8b1
No related branches found
No related tags found
No related merge requests found
app.html 0 → 100644
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Drypt</title>
<script src="./src/connection.js" defer></script>
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
<script src="./src/main.js" defer></script>
</head>
<body>
<button id="signout_button">Deconnexion</button>
</body>
</html>
\ No newline at end of file
...@@ -97,7 +97,7 @@ function listFiles() { ...@@ -97,7 +97,7 @@ function listFiles() {
for (var i = 0; i < files.length; i++) { for (var i = 0; i < files.length; i++) {
const file = files[i]; const file = files[i];
console.log(file); console.log(file);
appendPre(`<h1>` + file.name + ' (' + file.id + ')'+`</h1>`); appendPre(file.name + ' (' + file.id + ')');
} }
} else { } else {
appendPre('No files found.'); appendPre('No files found.');
......
...@@ -4,27 +4,48 @@ ...@@ -4,27 +4,48 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="./main.js" defer></script> <!--
<script type="module" src="./main.js" defer></script>
<script src="./google.js" defer></script> <script src="./google.js" defer></script>
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
-->
<script src="./src/connection.js" defer></script>
<script async defer src="https://apis.google.com/js/api.js" <script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()" onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()"> onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script> </script>
<title>Document</title> <script src="./src/welcome.js" defer></script>
<title>Drypt - Bienvenue</title>
</head> </head>
<body> <body>
<h1>Bienvenue sur Drypt !</h1>
<p>Drypt utilise l'API Google Drive pour interagir avec vos fichier. Veuillez vous connectez avec votre compte Google pour continuer</p>
<button id="signin_button">Sign in with Google</button>
<!--
<p>Drive API Quickstart</p> <p>Drive API Quickstart</p>
<!--Add buttons to initiate auth sequence and sign out-->
<button id="authorize_button" style="display: none;">Authorize</button> <button id="authorize_button" style="display: none;">Authorize</button>
<button id="signout_button" style="display: none;">Sign Out</button> <button id="signout_button" style="display: none;">Sign Out</button>
<pre id="content" style="white-space: pre-wrap;"></pre> <pre id="content" style="white-space: pre-wrap;"></pre>
<input type="file" name="inputfile"
id="inputfile">
<br>
</body> <pre id="output"></pre>
-->
</body> </body>
</html> </html>
\ No newline at end of file
console.log("test");
\ No newline at end of file
This diff is collapsed.
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"crypto": "^1.0.1",
"crypto-js": "^4.1.1",
"node": "^17.5.0",
"rc4-cipher": "^1.0.0" "rc4-cipher": "^1.0.0"
},
"type": "commonjs",
"devDependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.5",
"@babel/preset-env": "^7.16.11",
"polymer-cli": "^1.9.11"
} }
} }
{
"entrypoint": "index.html",
"shell": "app.js",
"npm": true
}
\ No newline at end of file
import { lineBreak } from 'acorn';
import $ from 'jquery';
export default class Router {
static titleElement;
static contentElement;
/**
* Tableau des routes/pages de l'application.
* @example `Router.routes = [{ path: '/', page: pizzaList, title: 'La carte' }]`
*/
static routes = [];
// propriété statique privée
static #menuElement;
/**
* Setter qui indique au Router la balise HTML contenant le menu de navigation.
* Écoute le clic sur chaque lien et déclenche la méthode navigate.
* @param element Élément HTML qui contient le menu principal
*/
static set menuElement(element) {
this.#menuElement = element;
//const links = this.#menuElement.querySelectorAll('a');
const $links = $('a', this.#menuElement);
$links.on('click', event => {
event.preventDefault();
this.navigate(event.currentTarget.getAttribute('href'));
});
}
/**
* Affiche la page correspondant à `path` dans le tableau `routes`
* @param {String} path URL de la page à afficher
* @param {Boolean} pushState active/désactive le pushState (ajout d'une entrée dans l'historique de navigation)
*/
static navigate(path, pushState = true) {
const route = this.routes.find(route => route.path === path);
if (route) {
// rendu du titre
$(this.titleElement).html(`<h1>${route.title}</h1>`);
// rendu de la page
$(this.contentElement).html(route.page.render());
// initialisation de la page
route.page.mount?.(this.contentElement);
// Activation/désactivation des liens du menu
const $previousMenuLink = $('.active', this.#menuElement),
$newMenuLink = $(`a[href="${path}"]`, this.#menuElement);
$previousMenuLink?.removeClass('active'); // on retire la classe "active" du précédent menu
$newMenuLink?.addClass('active'); // on ajoute la classe CSS "active" sur le nouveau lien
// History API : ajout d'une entrée dans l'historique du navigateur
// pour pouvoir utiliser les boutons précédent/suivant
if (pushState) {
window.history.pushState(null, null, path);
}
}
}
}
export default class Component {
tagName;
attribute;
children;
constructor(tagName, attribute, children) {
this.tagName = tagName;
this.attribute = attribute;
this.children = children;
}
render() {
let html = `<${this.tagName} ${this.renderAttributes()}`;
if (this.children) {
html += `>${this.renderChildren()}</${this.tagName}>`;
} else {
html += ' />';
}
return html;
}
renderAttributes() {
if (this.attribute) {
return `${this.attribute.name}="${this.attribute.value}"`;
}
return '';
}
renderChildren() {
if (this.children instanceof Array) {
return this.children.reduce(
(html, child) =>
html + (child instanceof Component ? child.render() : child),
''
);
}
return this.children || '';
}
}
// Client ID and API key from the Developer Console
const CLIENT_ID = '120302697004-onbjckkl8ol8eos9ohn60opqiebdft8g.apps.googleusercontent.com';
const API_KEY = 'AIzaSyDQbQyGrP9flTg0IvLqvdBnw9QItf_zthY';
// Array of API discovery doc URLs for APIs used by the quickstart
const DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"];
// Authorization scopes required by the API; multiple scopes can be
// included, separated by spaces.
const SCOPES = 'https://www.googleapis.com/auth/drive.metadata.readonly';
function handleClientLoad() {
gapi.load('client:auth2', initClient);
}
function initClient() {
gapi.client.init({
apiKey: API_KEY,
clientId: CLIENT_ID,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
}, function(error) {
appendPre(JSON.stringify(error, null, 2));
alert("Connection à l'API Google impossible");
});
}
/**
* Called when the signed in status changes, to update the UI
* appropriately. After a sign-in, the API is called.
*/
function updateSigninStatus(isSignedIn) {
}
\ No newline at end of file
const encrypt = (str, key="rc4@123") => {
return str && key ? rc4(str, key) : null;
}
const decrypt = (str, key="rc4@123") => {
return str && key ? rc4(str, key) : null;
}
const rc4 = (str, key) => {
let s = [], j = 0, x, result = '';
for (let i = 0; i < 256; i++) {
s[i] = i;
}
for (let i = 0; i < 256; i++) {
j = (j + s[i] + key.charCodeAt(i % key.length)) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
}
i = 0;
j = 0;
for (let y = 0; y < str.length; y++) {
i = (i + 1) % 256;
j = (j + s[i]) % 256;
x = s[i];
s[i] = s[j];
s[j] = x;
result += String.fromCharCode(str.charCodeAt(y) ^ s[(s[i] + s[j]) % 256]);
}
return result;
}
module.exports = { encrypt, decrypt };
\ No newline at end of file
var signOutButton = document.getElementById('signout_button');
signOutButton.addEventListener("click",signOut);
listFiles();
/**
* Sign out the user upon button click.
*/
function signOut(event) {
gapi.auth2.getAuthInstance().signOut();
location.href = "./index.html";
console.log("Signed Out");
}
/**
* Print files.
*/
function listFiles() {
gapi.client.drive.files.list({
'pageSize': 10,
'fields': "nextPageToken, files(id, name)"
}).then(function(response) {
appendPre('Files:');
var files = response.result.files;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
console.log(file.name + ' (' + file.id + ')');
}
} else {
console.log('No files found.');
}
});
}
/*let fileContent;
document.getElementById('inputfile')
.addEventListener('change', function() {
var fr=new FileReader();
fr.onload=function(){
fileContent = fr.result;
console.log(fileContent);
document.getElementById('output')
.textContent=fr.result;
}
fr.readAsText(this.files[0]);
})*/
/*const encryptedString = rc4.encrypt(fileContent,'key');
console.log(encryptedString);
const decryptedString = rc4.decrypt(encryptedString, 'key');
console.log(decryptedString);*/
\ No newline at end of file
var signInButton = document.getElementById('signin_button');
signInButton.addEventListener("click",signIn);
/**
* Sign in the user upon button click.
*/
function signIn(event) {
gapi.auth2.getAuthInstance().signIn();
location.href = "./app.html";
console.log("Signed In");
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment