2012-12-06

Online code editor

So, today I was trying to figure out what type of resolutions that were used on android devices. And I ran into the following list:



1   2560*1600
2   1366*768
3   1280*800
4   1280*768
5   1024*768
6   1024*600
7   960*640
8   960*540
9   854*480
10  800*600
11  800*480
12  800*400
13  640*360
14  640*240
15  480*320
16  400*240
17  320*240
And as usual I needed to do something with this list, such as counting out the aspect ratio for those resolutions into something similar to 4:3 or 16:9 or whatever the end result would be. For a long time I've been looking into some quick way to do this without having to create a project, creating files, building html web page with included JS etc. And today I found it by googling for "online code browser" and spending time in actually evaluating the results.


The end result was a webpage called JSBin, where it is possible to just mash down some js-script and then run it automatically.

No code hinting (unfortunately) but it gets the job down and, the end result was this super nice and clean code:

var input = ["1   2560*1600","2   1366*768","3   1280*800","4   1280*768","5   1024*768",
"6  1024*600","7   960*640","8   960*540","9   854*480","10  800*600","11  800*480",
"12  800*400","13  640*360","14  640*240","15  480*320","16  400*240","17  320*240"]

 for(var i=0; i < input.length; ++i) {
      var s = input[i].split(" ");
      for(var j=0; j < s.length; ++j) {
        if(j > 0 && s[j]) {
          console.log("resolution=" + s[j] + " - Ratio: " + s[j].split("*")[0] / s[j].split("*")[1]);
        }
      }      
    }

You can find the editor on jsbin.com and my super nice code should be available at http://jsbin.com/omiyik/22/edit. Now, assuming no one breaks it it should give you this output:

  • "resolution=2560*1600 - Ratio: 1.6"
  • "resolution=1366*768 - Ratio: 1.7786458333333333"
  • "resolution=1280*800 - Ratio: 1.6"
  • "resolution=1280*768 - Ratio: 1.6666666666666667"
  • "resolution=1024*768 - Ratio: 1.3333333333333333"
  • "resolution=1024*600 - Ratio: 1.7066666666666668"
  • "resolution=960*640 - Ratio: 1.5"
  • "resolution=960*540 - Ratio: 1.7777777777777777"
  • "resolution=854*480 - Ratio: 1.7791666666666666"
  • "resolution=800*600 - Ratio: 1.3333333333333333"
  • "resolution=800*480 - Ratio: 1.6666666666666667"
  • "resolution=800*400 - Ratio: 2"
  • "resolution=640*360 - Ratio: 1.7777777777777777"
  • "resolution=640*240 - Ratio: 2.6666666666666665"
  • "resolution=480*320 - Ratio: 1.5"
  • "resolution=400*240 - Ratio: 1.6666666666666667"
  • "resolution=320*240 - Ratio: 1.3333333333333333"

Inga kommentarer:

Skicka en kommentar