toothpaste/static/insert.html
2017-04-26 22:57:46 +02:00

111 lines
4.9 KiB
HTML

<!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">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Toothpaste: Insert HERE</title>
<link rel="icon" type="image/png" href="//cdn.tooth.yt/paste.png">
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="/static/style.css" crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="fill">
<div id="head">
<div id="headline" >Insert your Code here!</div>
<span>
<div class="btn-group">
<button class="btn btn-mini dropdown-toggle" data-toggle="dropdown" data-bind="attr: {selectedTypeName: selectedTypeIndex}, text: selectedTypeName">Test</button>
<button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul id="typeList" data-bind="foreach: types" class="dropdown-menu">
<li><a href="#" data-bind="attr: {id: $data.id, aceMode: $data.classname, typeindex: $index}, text: $data.type">Test</a></li>
</ul>
</div>
<button type="button" class="btn btn-mini" id="pasteButton">Paste dat!</button>
</span>
</div>
<div id="editorContainer">
<pre id="editor" class="editor"></pre>
<input id="fontSizeSpinner" type="number" min="8" max="30" value="16" />
</div>
</div>
<script src="//cdn.tooth.yt/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");
editor.setShowPrintMargin(false);
editor.setFontSize(16);
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js" crossorigin="anonymous"></script>
<script src="/static/spinner.js"></script>
<script type="text/javascript">
var selectedTypeId;
$('input[type=number]').spinner();
$('#fontSizeSpinner > input').change(function(){
editor.setFontSize(parseInt($(this).val()));
});
$(function(){
viewModel.selectedTypeName = ko.observable();
viewModel.selectedTypeIndex = ko.observable();
viewModel.selectedTypeName(viewModel.types[0].type);
viewModel.selectedTypeIndex(0);
$("#pasteButton").on("click", function(){
$.ajax({
url: "./fritten",
type: "POST" ,
data: {
content: editor.getValue(),
type : viewModel.types[viewModel.selectedTypeIndex()].id
},
success: function(data){
console.log(data);
if(data.id !== null){
window.location = "./"+data.id+"/";
}
}
})
}) ;
$("#typeList").bind( "click" , function(element){
selectedType = viewModel.types[$(element.target).attr("typeindex")];
viewModel.selectedTypeName(selectedType.type);
viewModel.selectedTypeIndex($(element.target).attr("typeindex"));
editor.session.setMode("ace/mode/" + $(element.target).attr("aceMode"));
console.log($(element.target).attr("aceMode"));
});
ko.applyBindings(viewModel);
});
var viewModel = %JSONStuff%;
</script>
</body>
</html>