1 |
<canvas id="myChart" width="400" height="400"></canvas> |
1 2 3 4 |
// Any of the following formats may be used var ctx = document.getElementById("myChart"); var ctx = document.getElementById("myChart").getContext("2d"); var ctx = $("#myChart"); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<canvas id="myChart" width="400" height="400"></canvas> <script> var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'bar', data: { labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], datasets: [{ label: '# of Votes', data: [12, 19, 3, 5, 2, 3] }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] } } }); </script> |
“Responsive FileManager is a free open-source file manager and image manager made with jQuery, CSS3, PHP and HTML5 that offers a nice and elegant way to upload and insert files, images and videos.
You can use it as external plugin for TinyMCE, CKEditor and CLEditor or as a stand-alone file manager to manage and select files.”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
tinymce.init({ selector: "textarea",theme: "modern",width: 680,height: 300, plugins: [ "advlist autolink link image lists charmap print preview hr anchor pagebreak", "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking", "table contextmenu directionality emoticons paste textcolor responsivefilemanager code" ], toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect", toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor | print preview code ", image_advtab: true , external_filemanager_path:"/filemanager/", filemanager_title:"Responsive Filemanager" , external_plugins: { "filemanager" : "/filemanager/plugin.min.js"} }); |
GoldenLayout is a web based docker layout engine that aids in creating flexible user interfaces by enabling panels to be docked on the screen.
MediaStreamRecorder.js is a cross-browser implementation to record audio & video streams via WebRTC. The lib allows you to submit/upload recorded blobs in realtime to your server.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<script src="https://cdn.webrtc-experiment.com/MediaStreamRecorder.js"> </script> <script> var mediaConstraints = { audio: true, video: true }; navigator.getUserMedia(mediaConstraints, onMediaSuccess, onMediaError); function onMediaSuccess(stream) { var multiStreamRecorder = new MultiStreamRecorder(stream); multiStreamRecorder.video = yourVideoElement; // to get maximum accuracy multiStreamRecorder.audioChannels = 1; multiStreamRecorder.ondataavailable = function (blobs) { // blobs.audio // blobs.video }; multiStreamRecorder.start(3 * 1000); } function onMediaError(e) { console.error('media error', e); } </script> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php foreach(array('video', 'audio') as $type) { if (isset($_FILES["${type}-blob"])) { $fileName = $_POST["${type}-filename"]; $uploadDirectory = "uploads/$fileName"; if (!move_uploaded_file($_FILES["${type}-blob"]["tmp_name"], $uploadDirectory)) { echo("problem moving uploaded file"); } echo($uploadDirectory); } } ?> |
I am currently developing a drag and drop interface for a course builder. Courses are split into lessons and lessons into slides. While switching between slides, I wanted to have a small thumbnail representing the current slide content.
One option would have been to use something like PhantomJS / CasperJS. A headless browser , to take a screenshot of the slide. I have done that in the past and it works perfectly.
This time, I decided to go with another solution, that allows me to convert html to a canvas element.
The project is called html2canvas (GitHub).
“This script allows you to take screenshots of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.”
1 2 3 4 5 |
html2canvas(document.body, { onrendered: function(canvas) { document.body.appendChild(canvas); } }); |
I have a slide container (#slideContainer), that holds the active slide for editing and a thumb navigation to switch between slides (.slide.thumb).
1 2 3 4 5 6 7 8 9 10 11 12 |
var current = $(".slide.thumb.active"); html2canvas($("#slideContainer").get(0), { onrendered: function(canvas) { var dataURL = canvas.toDataURL(); current.css({"background" :"url("+dataURL+")", "background-size":"contain", "background-position": "center", "background-repeat":"no-repeat"}); } }); |
When switching between slides, I am doing a snapshot of the current slideContainer and add it as a new background image to the thumb navigation item for that slide. This is done with canvas.toDataURL() and by embedding the resulting image using a data: url.
Works perfectly. html2canvas has no full css support, so the output will not always match 100%, but its close enough to get a glimpse of what is stored per slide ;)
html2canvas
PhantomJS
CasperJS
An HTML to Markdown converter written in JavaScript.
1 2 |
var toMarkdown = require('to-markdown'); toMarkdown('<h1>Hello world!</h1>'); |
1 2 3 4 |
$("a[href='#top']").click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); return false; }); |
Background Blur plugin is a cross browser jQuery plugin for blurring images.
1 2 3 4 5 6 7 |
$('#some-element').backgroundBlur({ imageURL : 'http://URL-of-the-image', blurAmount : 50, imageClass : 'bg-blur' duration: 1000, // If the image needs to be faded in, how long that should take endOpacity : 1 // Specify the final opacity that the image will have }); |
Vivaldi is a new web-browser with Chromium at its core and a complete new interface based on current web-technologies.
“Vivaldi is a freeware web browser developed by Vivaldi Technologies, a company founded by Opera Software co-founder and former CEO Jon Stephenson von Tetzchner and Tatsuki Tomita.”
FTPbucket is a PHP script that enables you to sync your BitBucket or GitHub repository with any web-server.
It works with Git and Mercurial.