2013-03-24 14:54:26 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Pagedown editor</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<!-- Bootstrap -->
|
|
|
|
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
|
|
|
|
<link href="css/main.css" rel="stylesheet" media="screen">
|
|
|
|
<script type="text/javascript" src="js/jquery.js"></script>
|
2013-03-24 17:46:48 +00:00
|
|
|
<script type="text/javascript" src="js/bootstrap.js"></script>
|
2013-03-24 14:54:26 +00:00
|
|
|
<script type="text/javascript" src="js/Markdown.Converter.js"></script>
|
|
|
|
<script type="text/javascript" src="js/Markdown.Sanitizer.js"></script>
|
|
|
|
<script type="text/javascript" src="js/Markdown.Editor.js"></script>
|
|
|
|
<script type="text/javascript" src="js/main.js"></script>
|
2013-03-24 17:46:48 +00:00
|
|
|
<script type="text/javascript">
|
|
|
|
var CLIENT_ID = '241271498917-jpto9lls9fqnem1e4h6ppds9uob8rpvu.apps.googleusercontent.com';
|
|
|
|
var SCOPES = 'https://www.googleapis.com/auth/drive.install';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the client library is loaded to start the auth flow.
|
|
|
|
*/
|
|
|
|
function handleClientLoad() {
|
|
|
|
window.setTimeout(checkAuth, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the current user has authorized the application.
|
|
|
|
*/
|
|
|
|
function checkAuth() {
|
|
|
|
gapi.auth.authorize({ 'client_id' : CLIENT_ID, 'scope' : SCOPES,
|
|
|
|
'immediate' : true }, handleAuthResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when authorization server replies.
|
|
|
|
*
|
|
|
|
* @param {Object} authResult Authorization result.
|
|
|
|
*/
|
|
|
|
function handleAuthResult(authResult) {
|
|
|
|
if (authResult && !authResult.error) {
|
|
|
|
$("#drive-link").hide();
|
|
|
|
} else {
|
|
|
|
$("#drive-link").click(function() {
|
|
|
|
gapi.auth.authorize({ 'client_id' : CLIENT_ID,
|
|
|
|
'scope' : SCOPES, 'immediate' : false }, handleAuthResult);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//alert(authResult);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the file upload.
|
|
|
|
*
|
|
|
|
* @param {Object} evt Arguments from the file selector.
|
|
|
|
*/
|
|
|
|
function uploadFile(evt) {
|
|
|
|
gapi.client.load('drive', 'v2', function() {
|
|
|
|
var file = evt.target.files[0];
|
|
|
|
insertFile(file);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert new file.
|
|
|
|
*
|
|
|
|
* @param {File} fileData File object to read data from.
|
|
|
|
* @param {Function} callback Function to call when the request is complete.
|
|
|
|
*/
|
|
|
|
function insertFile(fileData, callback) {
|
|
|
|
var request = gapi.client.request({
|
|
|
|
'path' : '/upload/drive/v2/files',
|
|
|
|
'method' : 'POST',
|
2013-03-24 19:08:31 +00:00
|
|
|
'params' : { 'uploadType' : 'media' },
|
|
|
|
'headers' : { 'Content-Type' : 'text/plain' },
|
|
|
|
'body' : fileData });
|
2013-03-24 17:46:48 +00:00
|
|
|
if (!callback) {
|
|
|
|
callback = function(file) {
|
|
|
|
console.log(file)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
request.execute(callback);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
|
2013-03-24 16:31:35 +00:00
|
|
|
<script>
|
|
|
|
(function(i, s, o, g, r, a, m) {
|
|
|
|
i['GoogleAnalyticsObject'] = r;
|
|
|
|
i[r] = i[r] || function() {
|
|
|
|
(i[r].q = i[r].q || []).push(arguments)
|
|
|
|
}, i[r].l = 1 * new Date();
|
|
|
|
a = s.createElement(o), m = s.getElementsByTagName(o)[0];
|
|
|
|
a.async = 1;
|
|
|
|
a.src = g;
|
|
|
|
m.parentNode.insertBefore(a, m)
|
|
|
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js',
|
|
|
|
'ga');
|
|
|
|
|
|
|
|
ga('create', 'UA-39556145-1', 'github.com');
|
|
|
|
ga('send', 'pageview');
|
|
|
|
</script>
|
2013-03-24 14:54:26 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
2013-03-24 17:46:48 +00:00
|
|
|
<div id="navbar" class="navbar navbar-fixed-top">
|
|
|
|
<div class="navbar-inner">
|
|
|
|
<a id="wmd-button-bar" class="nav"></a>
|
|
|
|
<ul class="nav pull-right">
|
|
|
|
<li class="divider-vertical"></li>
|
|
|
|
<li id="menu" class="dropdown"><a class="dropdown-toggle"
|
|
|
|
data-toggle="dropdown" href="#"><img src="img/stackedit-16.png"/> Menu</a>
|
|
|
|
<ul class="dropdown-menu">
|
|
|
|
<li><a id="drive-link" href="javascript:void(0);">Link with Google Drive</a></li>
|
|
|
|
</ul></li>
|
|
|
|
</ul>
|
|
|
|
<a class="brand pull-right" id="info-filename"></a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2013-03-24 14:54:26 +00:00
|
|
|
<textarea id="wmd-input"></textarea>
|
|
|
|
<div id="wmd-preview" class="well"></div>
|
|
|
|
</body>
|
2013-03-24 17:59:23 +00:00
|
|
|
</html>
|