| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <!DOCTYPE html><html>	<head>		<title>Choose a File</title>	</head>	<body>		<h2>I'm supposed to be an invisible iframe... (you shouldn't see this)</h2>		<script src="https://www.dropbox.com/static/api/2/dropins.js"></script>		<script src="https://js.live.net/v7.2/OneDrive.js"></script>		<script src="tokens.js"></script>		<script>		var queries = Object.fromEntries(window.location.search.substring(1).split("&").map(i => i.split("=")).map(i => i.map(i => i && decodeURIComponent(i))));				var fileTypes = queries.exts ? queries.exts.split(",") : [];				function finish(message, name, data) {			window.parent.postMessage({webretro: {timestamp: parseInt(queries.timestamp), message: message, name: name, data: data}}, "*");		}				function xhr(loc, success, error) {			var xhr = new XMLHttpRequest();			xhr.open("GET", loc, true);			xhr.responseType = "arraybuffer";			xhr.onload = function() {				success(this.response);			}			xhr.onerror = function(e) {				if (error) error(e);			}			xhr.send();		}				// Pass on data from Google Drive picker		window.addEventListener("message", function(e) {			if (e.origin == window.location.origin && e.data.webretro) finish(e.data.webretro.message, e.data.webretro.name, e.data.webretro.data);		}, false);				if (queries.type == "drive") {			// Google Drive						var dwidth = window.screen.width - 320;			var dheight = window.screen.height - 240;			var dleft = 160;			var dtop = 120;			window.open("drive.html?exts=" + fileTypes.join(","), "Choose a File", "left=" + dleft + ",top=" + dtop + ",width=" + dwidth + ",height=" + dheight);		} else if (queries.type == "dropbox") {			// Dropbox						Dropbox.appKey = dropboxAppKey;			Dropbox.choose({				success: function(files) {					var file = files[0];					xhr(file.link, function(data) {						finish("success", file.name, data);					}, function() {						finish("error");					});				},				cancel: function() {					finish("cancelled");				},				linkType: "direct",				multiselect: false,				folderselect: false			});		} else if (queries.type == "onedrive") {			// OneDrive						OneDrive.open({				clientId: onedriveClientId,				action: "download",				multiSelect: false,				advanced: {					filter: fileTypes.join(",")				},				success: function(response) {					var name = response.value[0].name;					var link = response.value[0]["@microsoft.graph.downloadUrl"];					xhr(link, function(data) {						finish("success", name, data);					}, function() {						finish("error");					});				},				cancel: function() {					finish("cancelled");				},				error: function(error) {					finish("error");				}			});		}		</script>	</body></html>
 |