Image brightness detection in client side script

This function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest) function getImageLightness(imageSrc,callback) { var img = document.createElement(“img”); img.src = imageSrc; img.style.display = “none”; document.body.appendChild(img); var colorSum = 0; img.onload = function() { // create canvas var canvas = document.createElement(“canvas”); … Read more

AngularJS: Understanding design pattern

Thanks to a huge amount of valuable sources I’ve got some general recommendations for implementing components in AngularJS apps: Controller Controller should be just an interlayer between model and view. Try to make it as thin as possible. It is highly recommended to avoid business logic in controller. It should be moved to model. Controller … Read more

What client-side web scripting languages are there other than JavaScript and VBScript?

The only languages I have ever seen supported by web browsers in <script> elements are: JavaScript / JScript (which is ubiquitous) Webassembly (which is less of a language than a different target other languages can be compiled to) is well supported today) VBScript (IE 10 and lower only) PerlScript (IE with a plugin from ActiveState … Read more

Can you get a public Facebook page’s feed using Graph API without asking a user to allow?

If you’re anything like me your clients won’t want a standard Facebook likebox plugin, they’ll want it all styled and customised their own way. You don’t need to spend all day going round the official documentation wondering if any of it applies to you for something simple like this, it’s quite easy. The confusion arises … Read more

Using local file for Web Audio API in Javascript

I had the same problem and I found this very simple solution. audio_file.onchange = function(){ var files = this.files; var file = URL.createObjectURL(files[0]); audio_player.src = file; audio_player.play(); }; <input id=”audio_file” type=”file” accept=”audio/*” /> <audio id=”audio_player” /> You can test here: http://jsfiddle.net/Tv8Cm/