notes and other stuff

 

How to make a useful slider in 30 lines of javascript

I was looking a bit at yui slider packet, and it seems todo way too much. I am one of these crasy people that like to know how my code works and after look at yui code base, I decided it was too much for just a simple little slider.
 
Naturally js-frames are perfect if you just want something quick and dont think its fun to deal with cross browser issues. As I have come to know javascript better, I prefer to avoid all these frameworks.
I just want something that is easy to change/maintain/simple and doesnt have to many dependency.
 
So I decide to spend a little hour to create a simple slider that does what i want. It ended up just below 30 lines of javascript.
 
The HTML :

<div id="volumeBar" class="volumeBar">
<div id="volumeSlider" class="volumeSlider">

The Javascript:
 
 

  var volumeBar = document.getElementById('volumeBar'); 
 
     var slider = document.getElementById('volumeSlider'); 
 
     var getPosition = function(el) { 
       var curLeft = curTop = 0; 
       while(el) { 
         curLeft += el.offsetLeft; 
         curTop += el.offsetTop; 
         el = el.offsetParent; 
       } 
       return {left : curLeft, top : curTop}; 
     } 
 
     volumeBar.onmouseup = function(e) { 
       volumeBar.onmousemove = null; 
       var event = e || window.event; 
       var volLeft = getPosition(volumeBar).left; 
       var width = volumeBar.offsetWidth; 
       slider.style.width = (event.clientX - volLeft)/width * 100 + 'px'; 
     }; 
 
     volumeBar.onmousedown = function() { 
       var volLeft = getPosition(volumeBar).left; 
       var width = volumeBar.offsetWidth; 
       document.onmouseup = function() { 
         document.onmouseup = null; 
         volumeBar.onmousemove = null; 
       }; 
       volumeBar.onmousemove = function(e) { 
         var event = e || window.event; 
         slider.style.width = (event.clientX - volLeft)/width * 100 + 'px'; 
       }; 
       return false; 
     };


Filed under  //   javascript   slider  

Comments [0]

In delayed train,

I just wanna get home and sleep ...

Comments [1]

Goomradio.com and the mac

 

So i started at my new work, goomradio.com, a little internet radio station that seems to have the right connections, at least while i was there they manage to get kelly clarkson to visit company, to do a radio interview.

In other news i am getting forced to work on mac, well not directly forced, but well group pressure, i cant believe how hard its todo the switch from vista to mac, everythings is just so different, and not in the good way.

  • i am having a hard time switching between windows, windows that i know i left open just disappear.
  • bad support, quite a few programs doesnt seems to work as well as they do on windows, firefox, eclipse
  • modal window, that doesnt have the right z-index
  • userfriendly ? how do i create a new file, i need to go to console ... 
  • all cool programs seems to cost money
  • i got real problems with right and double clicking, and i hate the sound
  • the console is nice, but i hate the fact that i am force to use it

But well besides from that there is a cool few problems on the mac, vlc playlist handling is some much better on mac, textmate is pretty cool and skitch a nice little screenshot program. Gonna spend a month with it, if that doesnt work i am installing vista on it.

 

Comments [0]

Sony Releases New Stupid Piece Of Shit That Doesnt work

Comments [0]

8 tracks about fire/burning selected by me

  1. Light my fire - The Doors
  2. Beds Are Burning - Midnight Oil
  3. A View to a Kill - Duran Duran
  4. Play We Didn't Start The Fire - Billy Joel
  5. Ring Of Fire - Johnny Cash
  6. Burning Down the House - Talking Heads
  7. I'm On Fire - Bruce Springsteen
  8. Into The Fire - Thirteen Senses

I attempt to fit them all into a pre 2000 periode, and keep they genrewise close, could spend a few more iterations on it.

Comments [0]

Fences is a Seriously Awesome Desktop Icon Organizer

I have really been waiting for this day, I cant believe it took people so long to come up with a application to handle this. I recall the first attempt, to my knowledge, to addresse the problem of managing desktop icon: Fire up mspaint, find your background image, add boxes + group titles.

This is so cool

 
 

via Lifehacker on 2/5/09

Windows only: Desktop icon organizer Fences arranges your cluttered desktop icons into containers so you can clean up the mess into useful groups of shortcuts—or optionally hides them altogether.

Once installed, Fences will run through a couple of first-time beginner screens asking if you'd like to use one of the built-in layouts, and will attempt to auto-detect which icons should be placed inside each fence. You can modify any of the fences by simply moving or resizing them around the screen, and then use the Lock item on the desktop context menu to fix them into place when you are done.

The thumbnail on the left shows my cluttered test desktop before, and the one on the right shows the default organizer layout generated by Fences—much cleaner.


Right-clicking on the desktop gives you a couple of new options, including quick and easy access to the settings panel, where you can tweak the look & feel as much as you'd like.


The best feature is the ability to double-click on the desktop to toggle visibility of the icons—but you can optionally exclude certain fences, a very useful feature for hiding clutter while keeping application launching icons visible all the time.


After only a few hours of using this application, it's already a must-have for keeping my desktop clean and organized. If you aren't worried about eye-candy and just want to organize your icons, check out previously mentioned Iconoid, or you can hide your desktop icons with a keyboard shortcut instead.

Fences is a free download, works on Windows XP 32-bit and Windows 7 or Vista in both 32-bit or 64-bit versions.

Fences [Stardock]

Filed under  //   desktop   download   windows  

Comments [0]

Useless HTML Forms

I wish html forms could do more, they are just so static, and more less useless on a dynamic website.

Like imaging if you could do something like this :



<form action="/api/rest/createUser" onsubmit="jsonRequest(this.requestUrl)">


  <input type="submit" value="do magic"/>


  <select name="video">


    <option value="1">Video 1</option> 


    <option value="2">Video 2</option>


  </select>


</form> 


Where jsonRequest would do a asyc request, and the requestUrl would have the value of the action and all the parameters.

eg. if Video 1 was selected, the requestUrl would have the value on submit of :



/api/rest/createUser?video=1


That would make forms a bit more useful. Perhaps I should take a look at HTML5 and see if help is coming.

Filed under  //   form   html   javascript  

Comments [0]

‘Programmers Are Tiny Gods’

So very true, its a very fine balance, one step to the wrong side ...

 
 

via Daring Fireball by John Gruber on 1/29/09

Derek Powazek:

Like designers, if you give a programmer a problem with parameters, they’ll apply every bit of genius they have to solve it in the best possible way. If you tell them how to do it, you’ll suffer the wrath of an angry God.

Comments [0]

Free Firefox 3 ?

Why do people call it a "free upgrade!" its free already ... as far as i know.

I am just wondering if the ff3 version that i downloaded, wasnt free. In that case i want my money back, and then get the free version. Even though i wouldnt mind paying for ff3, or well a version that didnt leak so much perhaps.

 

 
 

via Mozilla Developer News by ss on 1/19/09

Earlier this month, Mozilla offered an update for all Firefox 2.0.0.20 users - a free upgrade to Firefox 3.0.5, the very latest and best browser from Mozilla offering more speed, requiring less memory, and providing the safest and easiest web browsing experience available.

Firefox 2 users last received a “major update” in December, prior to the final release of Firefox 2. As of this point, Mozilla will no longer be actively issuing security and stability updates to Firefox 2. Additionally, Firefox 2 will no longer have Phishing Protection as of January 20.

We strongly recommend that our users upgrade to Firefox 3.

If you’re running Firefox 2.0.0.20, you can select “Check for Updates” in the “Help” menu to receive an update right now. This is what the offer will look like:

Firefox 2 Major Update Window

If you don’t receive an offer for some reason, you can download Firefox 3 from http://getfirefox.com/.

Comments [0]

The worst intro ever, or perhaps the greatest

Since I joined joost, i feel like, i need to share some of the great content we got on joost.com. I found this show, a year ago or something, but it first hit me around 2 months ago that it got a really really bad intro ... bad in the good way

By the way just listen to the intro, no need to watch the video...

Comments [0]