Skip to content

Instantly share code, notes, and snippets.

@tokapeb
Created July 27, 2012 10:25
Show Gist options
  • Select an option

  • Save tokapeb/3187318 to your computer and use it in GitHub Desktop.

Select an option

Save tokapeb/3187318 to your computer and use it in GitHub Desktop.
.
.
.
<link rel="stylesheet" type="text/css" href="jcsdl/jcsdl.min.css" />
<link rel="stylesheet" type="text/css" href="over.css" />
<script type="text/javascript" src="jcsdl/jcsdl.definition.js"></script>
<script type="text/javascript" src="jcsdl/jcsdl.min.js"></script>
<script type="text/javascript">
$(function() {
var $currentStream = $();
JCSDL.onLoad(function() {
$('#jcsdl-edit').jcsdlGui({
save : function(code) {
// add new item if none loaded)
if ($currentStream.length == 0) {
var $item = $('#streams-list li:first').clone();
$item.find('h4').html('New stream');
$item.find('.jcsdl-source').val(code);
$item.appendTo('#streams-list');
} else {
// save the output to the selected stream
$currentStream.find('.jcsdl-source').val(code);
}
// display the output
$('#jcsdl-edit-output').val(code);
// hide the editor and show the list
$('#jcsdl-edit').hide();
$('#streams-list').show();
},
cancel : function() {
this.$container.fadeOut(this.config.animationSpeed, function() {
$('#streams-list').show();
});
}
});
});
$('#streams-list').on('click', '.edit', function(ev) {
ev.preventDefault();
ev.target.blur();
$currentStream = $(this).closest('li');
var code = $currentStream.find('.jcsdl-source').val();
$('#jcsdl-edit').jcsdlGui('loadJCSDL', code);
// clear the output as well
$('#jcsdl-edit-output').val('');
// hide the list and show the editor
$('#streams-list').hide();
$('#jcsdl-edit').show();
});
$('#streams-list').on('click', '.source', function(ev) {
ev.preventDefault();
ev.target.blur();
var code = $(this).closest('li').find('.jcsdl-source').val();
$('#jcsdl-edit-output').val(code);
});
var editor = new JCSDLGui('#jcsdl', {
save : function(code) {
alert(code);
}
});
});
</script>
</head>
<body>
<div id="logo"></div>
<div id="jcsdl-edit"></div>
<!-- EDIT STREAMS TAB -->
<ul id="streams-list">
<li>
<h4>Example stream</h4>
<div class="options">
<a href="#" class="edit">Edit</a>
<a href="#" class="source">View JCSDL Source</a>
</div>
<textarea class="jcsdl-source" style="display: none;">// JCSDL_MASTER b2cbf3e5da9068718b52596c45567bd7 AND
// JCSDL_VERSION 1.0
// JCSDL_START 76a8c9ec58cccc5f820bfda389841cc6 imdb.content,contains_any,27-6
imdb.content contains_any "Batman"
// JCSDL_END
// JCSDL_MASTER_END</textarea>
</li>
</ul>
<h3>JCSDL Output:</h3>
<textarea id="jcsdl-edit-output" disabled="true" style="width: 90%; margin: 20px auto; display: block; height: 200px;"></textarea>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment