Stackedit/index.html
2013-03-24 19:20:01 +00:00

128 lines
3.9 KiB
HTML

<!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>
<script type="text/javascript" src="js/bootstrap.js"></script>
<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>
<script type="text/javascript">
var CLIENT_ID = '241271498917-jpto9lls9fqnem1e4h6ppds9uob8rpvu.apps.googleusercontent.com';
var SCOPES = 'https://www.googleapis.com/auth/drive.install';
var driveUpload = false;
/**
* 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();
gapi.client.load('drive', 'v2', function() {
driveUpload = true;
});
} 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) {
if(driveUpload) {
var request = gapi.client.request({
'path' : '/upload/drive/v2/files',
'method' : 'POST',
'params' : { 'uploadType' : 'media' },
'headers' : { 'Content-Type' : 'text/plain' },
'body' : fileData });
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>
<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>
</head>
<body>
<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>
<textarea id="wmd-input"></textarea>
<div id="wmd-preview" class="well"></div>
</body>
</html>