<input type="button" value="Convert WECO to OMA" onclick="convert()" />
<div id="results"></div>
JavaScript
function convert() {
//start for right and left eye (currently using start like a base, try the difference however the radius ends up being too large)
var startr = parseInt('0A62', 16);
var startl = parseInt('1A6E', 16);
//data
var right = "FDF6EDE5DEDADADBD9D7DADBE2E6E5E9ECEEF0F3F5F5F5F3F1EFEFE9E8E6E5E2E0E2E5EBEFF5FB01070D141B21262C32363B3B3C3D3C3936312B251F181008FFF6EDE4DCD3CBC8C4C2C0C2C1C5CACCD3DAE0E5ECF3FAFF040B0F1312120F0A0502FEFCF7F5F4F5F7FA00020810151A21262B30353A3F41403F3B342E261C1208";
var left = "02FAF0E8E3DDDAD8D7D6D9DADEE0E4E7EBEDF0F2F5F5F6F5F2EFECEAE8E4E3E1E0E3E6EAEFF6FB01090E16191D232A3032373D3B3D3C3A34322E27201A1209FFF5EAE2DAD2C9C4C1C1C2C2C2C3C8CED5D9DFE6ECF3F8FE050C11151515120F0803FEFAF7F5F5F6F6FAFE03070E131A20262B3034393A40423F39372F271E180D";
//break strings into 2 byte chunks and set up array to hold their decimal values
var stringarrayr = right.match(/.{1,2}/g);
var stringdecr = [];
var stringarrayl = left.match(/.{1,2}/g);
var stringdecl = [];
//set up radius value arrays
var radiusr = [];
var radiusl = [];
//convert string from hex to dec
for (var x in stringarrayr) {
stringdecr.push(parseInt(stringarrayr[x], 16));
}
for (var x in stringarrayl) {
stringdecl.push(parseInt(stringarrayl[x], 16));
}
//add differential to starting point STILL NEED TO KNOW WHEN TO ADD VS SUBTRACT
for (var x in stringdecr) {
var temp = stringdecr[x];
temp = (temp > 128)? temp-256: temp;
radiusr.push(startr + temp);
}
for (var x in stringdecl) {
var temp = stringdecl[x];
temp = (temp > 128)? temp-256: temp;
radiusl.push(startl + temp);
}
//string for display
var disp = "";
//convert into OMA format
for (var x in radiusr) {
if (x % 10 == 0) {
disp = disp.substring(0, disp.length - 1);
disp += "</br>R=" + radiusr[x] + ";";
} else {
if...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.