[ScientificCalculator]update ScientificCalculator(tizen_2.1) tizen_2.1 2.1b_release
authorgs86.lee <gs86.lee@samsung.com>
Tue, 23 Apr 2013 08:48:23 +0000 (17:48 +0900)
committergs86.lee <gs86.lee@samsung.com>
Tue, 23 Apr 2013 09:39:40 +0000 (18:39 +0900)
Change-Id: I4314354c275072597225c86c939e0759040801cc

Gruntfile.js [new file with mode: 0755]
LICENSE.Apache-2.0 [moved from LICENSE.APLv2.0 with 100% similarity]
NOTICE [moved from NOTICE.APLv2.0 with 100% similarity]
config.xml
css/calc.css
css/calc_portrait.css
index.html
js/calc.js
lazy.html [new file with mode: 0755]
signature1.xml [changed mode: 0644->0755]

diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100755 (executable)
index 0000000..bee4c55
--- /dev/null
@@ -0,0 +1,164 @@
+module.exports = function (grunt) {
+
+  grunt.loadNpmTasks('grunt-contrib-clean');
+  grunt.loadNpmTasks('grunt-contrib-uglify');
+  grunt.loadNpmTasks('grunt-contrib-copy');
+  grunt.loadNpmTasks('grunt-contrib-cssmin');
+  grunt.loadTasks('tools/grunt-tasks');
+
+  grunt.initConfig({
+    packageInfo: grunt.file.readJSON('package.json'),
+
+    clean: ['build'],
+
+    // minify and concat JS
+    uglify: {
+      dist: {
+        files: {
+          'build/js/calc.js': ['js/calc.js'],
+          'build/js/help.js': ['js/help.js'],
+          'build/js/iscroll.js': ['js/iscroll.js'],
+          'build/js/jquery-1.7.2.min.js': ['js/jquery-1.7.2.min.js'],
+          'build/js/license.js': ['js/license.js'],
+          'build/js/localizer.js': ['js/localizer.js'],
+          'build/js/peg-0.6.2.min.js': ['js/peg-0.6.2.min.js']
+        }
+      }
+    },
+
+    // minify and concat CSS
+    cssmin: {
+      dist: {
+        files: {
+          'build/css/calc.css': ['css/calc.css'],
+          'build/css/calc_portrait.css': ['css/calc_portrait.css'],
+          'build/css/jquery.jscrollpane.css': ['css/jquery.jscrollpane.css']
+        }
+      }
+    },
+
+    // copy assets and the index.html file to build/;
+    // NB we rewrite index.html during copy to point at the
+    // minified/concated js file all.js and minified/concated CSS file
+    // all.css
+    copy: {
+      dist: {
+        files: [
+          { expand: true, cwd: '.', src: ['config.xml'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['README.txt'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['icon**.png'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['images/**'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['audio/**'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['fonts/**'], dest: 'build/' },
+          { expand: true, cwd: '.', src: ['**.html'], dest: 'build/' }
+        ],
+        options: {
+          // this rewrites the <script> tag in the index.html file
+          // to point at the minified/concated js file all.js;
+          // and the stylesheet tags to point at all.css;
+          // it additionally strips out as much space and as many newlines
+          // as possible from HTML files (NB this may be dangerous if
+          // files are space-sensitive, but most HTML shouldn't be)
+          processContent: function (content) {
+            if (content.match(/DOCTYPE/)) {
+          //     // JS
+          //     content = content.replace(/test\.js/, '!!!all.js!!!');
+          //     content = content.replace(/<script src="[^\!]+?"><\/script>\n/g, '');
+
+              // CSS
+          //     content = content.replace(/test\.css/, '!!!all.css!!!');
+          //     content = content.replace(/<link rel="stylesheet" href="[^\!]+?">\n/g, '');
+
+              // fix JS and CSS resources
+          //     content = content.replace(/!!!/g, '');
+
+              // whitespace reduction
+              content = content.replace(/[ ]{2,}/g, ' ');
+              content = content.replace(/\n{2,}/g, '\n');
+            }
+
+            return content;
+          },
+
+          // if you have other resources which you don't want to have
+          // treated as text, add them here
+          processContentExclude: ['images/*', 'fonts/*', 'audio/*', '*.jpg', '*.png', 'README.txt']
+        }
+      }
+    },
+
+    // make wgt package in build/ directory
+    package: {
+      appName: '<%= packageInfo.name %>',
+      version: '<%= packageInfo.version %>',
+      files: 'build/**',
+      stripPrefix: 'build/',
+      outDir: 'build',
+      suffix: '.wgt',
+      addGitCommitId: false
+    },
+
+    sdb: {
+      prepare: {
+        action: 'push',
+        localFiles: './tools/grunt-tasks/tizen-app.sh',
+        remoteDestDir: '/home/developer/',
+        chmod: '+x',
+        overwrite: true
+      },
+
+      pushwgt: {
+        action: 'push',
+        localFiles: {
+          pattern: 'build/*.wgt',
+          filter: 'latest'
+        },
+        remoteDestDir: '/home/developer/'
+      },
+
+      stop: {
+        action: 'stop',
+        remoteScript: '/home/developer/tizen-app.sh'
+      },
+
+      uninstall: {
+        action: 'uninstall',
+        remoteScript: '/home/developer/tizen-app.sh'
+      },
+
+      install: {
+        action: 'install',
+        remoteFiles: {
+          pattern: '/home/developer/*.wgt',
+          filter: 'latest'
+        },
+        remoteScript: '/home/developer/tizen-app.sh'
+      },
+
+      debug: {
+        action: 'debug',
+        remoteScript: '/home/developer/tizen-app.sh',
+        localPort: '8888',
+        openBrowser: 'google-chrome %URL%'
+      }//,
+
+      //start: {
+        //action: 'start',
+        //remoteScript: '/home/developer/tizen-app.sh'
+      //}
+    }
+  });
+
+  grunt.registerTask('dist', ['clean', 'cssmin:dist', 'uglify:dist', 'copy:dist']);
+
+  grunt.registerTask('pkg', 'Create package; call with pkg:STR to append STR to package name', function (identifier) {
+    grunt.task.run('dist');
+
+    var packageTask = (identifier ? 'package:' + identifier : 'package');
+    grunt.task.run(packageTask);
+  });
+
+  grunt.registerTask('reinstall', ['pkg', 'sdb:prepare', 'sdb:pushwgt', 'sdb:stop', 'sdb:uninstall', 'sdb:install', 'sdb:debug']);
+  grunt.registerTask('restart', ['sdb:stop', 'sdb:start']);
+  grunt.registerTask('default', 'dist');
+};
similarity index 100%
rename from LICENSE.APLv2.0
rename to LICENSE.Apache-2.0
similarity index 100%
rename from NOTICE.APLv2.0
rename to NOTICE
index 4db3f4d..8837d12 100755 (executable)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="https://github.com/01org/webapps-scientific-calculator" version="1.0.0" viewmodes="fullscreen">
-       <tizen:application id="UaW22rtxQw" required_version="1.0" />
-       <content src="index.html" />
-       <icon src="icon_128.png" />
-       <name>ScientificCalculator</name>
-    <tizen:setting screen-orientation="portrait" />
+<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/Scientific" version="1.0.0" viewmodes="fullscreen">
+    <tizen:application id="zvgtj2hnLF.Scientific" package="zvgtj2hnLF" required_version="2.1"/>
+    <content src="index.html"/>
+    <icon src="icon_128.png"/>
+    <name>Scientific</name>
+    <tizen:setting screen-orientation="portrait" context-menu="disable"/>
 </widget>
index 3356ea5..5a9fb06 100755 (executable)
@@ -1924,21 +1924,21 @@ sub {
     cursor: default;
 }
 
-.helpdialog .inner .contents bl {
+.helpdialog .inner .contents .black {
     color: #000000;
     font-family: "OpenSans-Light";
     font-size: 26pt;
     line-height: 72px;
 }
 
-.helpdialog .inner .contents wh {
+.helpdialog .inner .contents .white {
     color: #ebebe9;
     font-family: "OpenSans-Light";
     font-size: 36px;
     line-height: 72px;
 }
 
-.helpdialog .inner .contents wh2 {
+.helpdialog .inner .contents .white2 {
     color: #ebebe9;
     font-family: "OpenSans-Light";
     font-size: 36px;
@@ -2007,3 +2007,7 @@ sub {
 #home_help:active {
     opacity: 1;
 }
+
+button[disabled] {
+    opacity: 0.5;
+}
\ No newline at end of file
index 8d44f24..7e1db83 100755 (executable)
@@ -669,7 +669,7 @@ sub {
     right:16px;
     top:20px;
     font-family: "OpenSans-Semibold";
-    font-size: 84px;
+    font-size: 44px;
     text-align: right;
 }
 
@@ -744,7 +744,7 @@ sub {
     float: right;
     color: #000000;
     font-family: "OpenSans-Regular";
-    font-size: 36px;
+    font-size: 25px;
     right:16px;
     top:5px;
     text-align: right;
@@ -788,7 +788,7 @@ sub {
     float: right;
     color: #000000;
     font-family: "OpenSans-Semibold";
-    font-size: 56px;
+    font-size: 50px;
     right:16px;
     top:10px;
 }
@@ -1860,21 +1860,21 @@ sub {
     cursor: default;
 }
 
-.helpdialog .inner .contents bl {
+.helpdialog .inner .contents .black {
     color: #000000;
     font-family: "OpenSans-Light";
     font-size: 26pt;
     line-height: 98px;
 }
 
-.helpdialog .inner .contents wh {
+.helpdialog .inner .contents .white {
     color: #ebebe9;
     font-family: "OpenSans-Light";
     font-size: 36px;
     line-height: 98px;
 }
 
-.helpdialog .inner .contents wh2 {
+.helpdialog .inner .contents .white2 {
     color: #ebebe9;
     font-family: "OpenSans-Light";
     font-size: 36px;
@@ -1943,3 +1943,7 @@ sub {
 #home_help:active {
     opacity: 1;
 }
+
+button[disabled] {
+    opacity: 0.5;
+}
\ No newline at end of file
index 73504e3..2b07b7d 100755 (executable)
  *
 -->
 <html>
-<head>
-<meta id="viewport_meta" name="viewport" content="" />
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>Scientific Calculator</title>
-<link rel="stylesheet" id="stylesheet" type="text/css"
-       href="css/calc_portrait.css" />
-<script type="text/javascript">
-               var viewport_meta = document.getElementById('viewport_meta');
-               var w = screen.availWidth;
-               var h = screen.availHeight;
-               viewport_meta.setAttribute('content', 'width=' + w + ', height=' + h + ',user-scalable=no');
-       </script>
-</head>
-<body>
-       <div id="background">
-               <div id="calculationpane">
-                       <div id="LCD_Upper" style="display: none">
-                               <div id="wrapper">
-                                       <div id="scroller">
-                                               <div class="scroll-pane" id="calculationhistory"></div>
-                                       </div>
-                               </div>
-                               <div id="historyverticalline"></div>
-                               <button class="historybuttonclose" id="closehistorybutton"
-                                       onclick="Calculator.closeHistory()"></button>
-                       </div>
-                       <div id="LCD_Lower">
-                               <div id="upperpane">
-                                       <div id="closebutton">
-                                               <button class="buttonclose" id="buttonclosecurrentformula"
-                                                       onclick="Calculator.setCurrentFormula('')"></button>
-                                       </div>
-                                       <div id="currentformula"></div>
-                               </div>
-                               <div id="horizontaldivider"></div>
-                               <div id="lowerpane">
-                                       <div id="closebutton">
-                                               <button class="buttonclose" id="buttonclosemainentry"
-                                                       onclick="Calculator.setMainEntry('')"></button>
-                                       </div>
-                                       <div id="mainentry"></div>
-                                       <button class="historybutton" id="openhistorybutton"
-                                               onclick="Calculator.openHistory()"></button>
-                               </div>
-                       </div>
-                       <div id="keyboard">
-                               <div id="keyboardleft">
-                                       <div id="leftmostpane">
-                                               <div id="statetransition">
-                                                       <div id="degradswitch" class="switchleftactive">
-                                                               <div class="buttontogglebackgroundB" id="buttondeg"
-                                                                       onclick="Calculator.transitionToDegrees();">DEG</div>
-                                                               <div class="buttontogglebackgroundA" id="buttonrad"
-                                                                       onclick="Calculator.transitionToRadians();">RAD</div>
-                                                       </div>
-                                                       <div id="traghypswitch" class="switchleftactive">
-                                                               <div class="buttontogglebackgroundB" id="buttontrig"
-                                                                       onclick="Calculator.transitionToTrigonometricFunctions()">TRIG</div>
-                                                               <div class="buttontogglebackgroundA" id="buttonhyp"
-                                                                       onclick="Calculator.transitionToHyperbolicFunctions()">HYP</div>
-                                                       </div>
-                                               </div>
-                                               <div id="trigonometric">
-                                                       <button class="buttonblackshort" id="buttonsin">sin</button>
-                                                       <button class="buttonblackshort" id="buttoncos">cos</button>
-                                                       <button class="buttonblackshort" id="buttontan">tan</button>
-                                                       <button class="buttonblackshort" id="buttonarcsin">
-                                                               sin<sup>-1</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonarccos">
-                                                               cos<sup>-1</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonarctan">
-                                                               tan<sup>-1</sup>
-                                                       </button>
-                                               </div>
-                                               <div id="hyperbolic">
-                                                       <button class="buttonblackshort" id="buttonsinh">sinh</button>
-                                                       <button class="buttonblackshort" id="buttoncosh">cosh</button>
-                                                       <button class="buttonblackshort" id="buttontanh">tanh</button>
-                                                       <button class="buttonblackshort" id="buttonasinh">
-                                                               sinh<sup>-1</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonacosh">
-                                                               cosh<sup>-1</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonatanh">
-                                                               tanh<sup>-1</sup>
-                                                       </button>
-                                               </div>
-                                               <div id="expandlog">
-                                                       <button class="buttonblackshort" id="buttonlog">log</button>
-                                                       <button class="buttonblackshort" id="buttonlog2">
-                                                               log<sub>2</sub>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonln">ln</button>
-                                                       <button class="buttonblackshort" id="button10x"
-                                                               data-operator="10<sup>^</sup>">
-                                                               10<sup>x</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="button2x"
-                                                               data-operator="2<sup>^</sup>">
-                                                               2<sup>x</sup>
-                                                       </button>
-                                                       <button class="buttonblackshort" id="buttonex"
-                                                               data-operator="e<sup>^</sup>">
-                                                               e<sup>x</sup>
-                                                       </button>
-                                               </div>
-                                       </div>
-                                       <div div id="centerleftpane">
-                                               <div id="powerandroot">
-                                                       <button class="buttonyellow" id="buttonsquare"
-                                                               data-operator="<sup>2</sup>">
-                                                               x<sup>2</sup>
-                                                       </button>
-                                                       <button class="buttonyellow" id="buttonsquareroot">&#8730;</button>
-                                               </div>
-                                               <div id="nthpowerandnthroot">
-                                                       <button class="buttonyellow" id="buttonnthpower"
-                                                               data-operator="<sup>^</sup>">
-                                                               y<sup>x</sup>
-                                                       </button>
-                                                       <button class="buttonyellow" id="buttonnthroot"
-                                                               data-operator="<sup>n</sup>&#8730;">
-                                                               <sup>x</sup>&#8730;y
-                                                       </button>
-                                               </div>
-                                       </div>
-                               </div>
-                               <div id="keyboardsplitter"></div>
-                               <div id="keyboardright">
-                                       <div id="centerrightpane">
-                                               <button class="buttonpurple" id="buttonmemorylist"
-                                                       onclick="Calculator.onButtonMemoryListClick()">
-                                                       <div class="buttonlefttext">M</div>
-                                                       <img class="buttonrighticon" src="images/ico_mem_list.png"></img>
-                                               </button>
-                                               <button class="buttonpurple" id="buttonmemorize"
-                                                       onclick="Calculator.onButtonMainEntryToMemoryClick()">
-                                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                                       <div class="buttonrighttext" id="buttonmemorizetext"></div>
-                                               </button>
-                                               <button class="buttonblack" id="buttonleftparenthesis">(</button>
-                                               <button class="buttonblack" id="buttonrightparenthesis">)</button>
-                                               <button class="buttonblack" id="buttonfactorial" data-operator="!">x!</button>
-                                               <button class="buttonblack" id="buttoninverse"
-                                                       data-operator="<sup>-1</sup>">
-                                                       x<sup>-1</sup>
-                                               </button>
-                                               <button class="buttonblack" id="buttonpi">&pi;</button>
-                                               <button class="buttonblack" id="buttonpercentage">%</button>
-                                       </div>
-                                       <div id="rightpane">
-                                               <button class="buttonred" id="buttonclear">C</button>
-                                               <button class="buttonblue" id="buttondivide">&#247;</button>
-                                               <button class="buttonblue" id="buttonmultiply">&#215;</button>
-                                               <button class="buttonwhite" id="button7">7</button>
-                                               <button class="buttonwhite" id="button8">8</button>
-                                               <button class="buttonwhite" id="button9">9</button>
-                                               <button class="buttonwhite" id="button4">4</button>
-                                               <button class="buttonwhite" id="button5">5</button>
-                                               <button class="buttonwhite" id="button6">6</button>
-                                               <button class="buttonwhite" id="button1">1</button>
-                                               <button class="buttonwhite" id="button2">2</button>
-                                               <button class="buttonwhite" id="button3">3</button>
-                                               <button class="buttonwhite" id="button0">0</button>
-                                               <button class="buttonblue" id="buttondot">.</button>
-                                               <button class="buttonblue" id="buttonplusminus">+/&#8722;</button>
-                                       </div>
-                                       <div id="rightmostpane">
-                                               <button class="buttonred" id="buttondelete">
-                                                       <img class="buttondeleteicon" src="images/ico_back.png"
-                                                               alt="backspace" height="26" width="40" />
-                                               </button>
-                                               <button class="buttonblue" id="buttonsubtract" data-operator="-">&#8722;</button>
-                                               <button class="buttonblue" id="buttonadd">+</button>
-                                               <button class="buttonblueequal" id="buttonequal">=</button>
-                                       </div>
-                               </div>
-                       </div>
-                       <div id="licensebtnl">i</div>
-                       <div id="home_help" class="helplaunch">?</div>
-               </div>
-       </div>
-
-       <div id=memorypage style="display: none;">
-               <div id="memorypagelcd">
-                       <div id="mpclosebutton">
-                               <button class="buttonclose" id="mplcdbuttonclose"
-                                       onclick="Calculator.setMainEntry('')"></button>
-                       </div>
-                       <div id="mpmainentry"></div>
-                       <button class="historybutton" id="mpopenhistorybutton"
-                               onclick="Calculator.openHistory()"></button>
-               </div>
-
-               <div id="memorypane">
-                       <div class="memoryentrypane" id="M1pane" data-entryname="M1">
-                               <button class="buttonmemory" id="buttonM1"
-                                       onclick="Calculator.onButtonMemoryClick('M1')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M1</div>
-                               </button>
-                               <div class="memorypane" id="M1pane">
-                                       <div class="memory" id="M1">
-                                               <div id="M1text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M1description"></div>
-                                               <input class="memorydescriptioninput" id="M1descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M1')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM1edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M1')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM1close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M1')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M2pane" data-entryname="M2">
-                               <button class="buttonmemory" id="buttonM2"
-                                       onclick="Calculator.onButtonMemoryClick('M2')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M2</div>
-                               </button>
-                               <div class="memorypane" id="M2pane">
-                                       <div class="memory" id="M2">
-                                               <div id="M2text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M2description"></div>
-                                               <input class="memorydescriptioninput" id="M2descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M2')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM2edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M2')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM2close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M2')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M3pane" data-entryname="M3">
-                               <button class="buttonmemory" id="buttonM3"
-                                       onclick="Calculator.onButtonMemoryClick('M3')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M3</div>
-                               </button>
-                               <div class="memorypane" id="M3pane">
-                                       <div class="memory" id="M3">
-                                               <div id="M3text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M3description"></div>
-                                               <input class="memorydescriptioninput" id="M3descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M3')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM3edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M3')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM3close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M3')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M4pane" data-entryname="M4">
-                               <button class="buttonmemory" id="buttonM4"
-                                       onclick="Calculator.onButtonMemoryClick('M4')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M4</div>
-                               </button>
-                               <div class="memorypane" id="M4pane">
-                                       <div class="memory" id="M4">
-                                               <div id="M4text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M4description"></div>
-                                               <input class="memorydescriptioninput" id="M4descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M4')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM4edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M4')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM4close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M4')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M5pane" data-entryname="M5">
-                               <button class="buttonmemory" id="buttonM5"
-                                       onclick="Calculator.onButtonMemoryClick('M5')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M5</div>
-                               </button>
-                               <div class="memorypane" id="M5pane">
-                                       <div class="memory" id="M5">
-                                               <div id="M5text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M5description"></div>
-                                               <input class="memorydescriptioninput" id="M5descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M5')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM5edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M5')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM5close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M5')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M6pane" data-entryname="M6">
-                               <button class="buttonmemory" id="buttonM6"
-                                       onclick="Calculator.onButtonMemoryClick('M6')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M6</div>
-                               </button>
-                               <div class="memorypane" id="M6pane">
-                                       <div class="memory" id="M6">
-                                               <div id="M6text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M6description"></div>
-                                               <input class="memorydescriptioninput" id="M6descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.saveMemoryDescription('M6')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM6edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M6')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM6close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M6')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M7pane" data-entryname="M7">
-                               <button class="buttonmemory" id="buttonM7"
-                                       onclick="Calculator.onButtonMemoryClick('M7')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M7</div>
-                               </button>
-                               <div class="memorypane" id="M7pane">
-                                       <div class="memory" id="M7">
-                                               <div id="M7text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M7description"></div>
-                                               <input class="memorydescriptioninput" id="M7descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M7')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM7edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M7')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM7close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M7')"></button>
-                               </div>
-                       </div>
-                       <div class="memoryentrypane" id="M8pane" data-entryname="M8">
-                               <button class="buttonmemory" id="buttonM8"
-                                       onclick="Calculator.onButtonMemoryClick('M8')">
-                                       <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
-                                       <div class="buttonrighttext" id="buttonmemorizetext">M8</div>
-                               </button>
-                               <div class="memorypane" id="M8pane">
-                                       <div class="memory" id="M8">
-                                               <div id="M8text" class="memorytext"></div>
-                                       </div>
-                                       <div class="memorydescription">
-                                               <div class="memorydescriptiontext" id="M8description"></div>
-                                               <input class="memorydescriptioninput" id="M8descriptioninput"
-                                                       type=text name=username size=21
-                                                       onfocusout="Calculator.saveMemoryDescription('M8')" />
-                                       </div>
-                                       <button class="buttonmemoryedit" id="buttonM8edit"
-                                               onclick="Calculator.onButtonMemoryEditClick('M8')"></button>
-                                       <button class="buttonmemoryclose" id="buttonM8close"
-                                               onclick="Calculator.onButtonMemoryCloseClick('M8')"></button>
-                               </div>
-                       </div>
-                       <button class="dialogAbuttonPurple" id="memoryclearall"
-                               onclick="Calculator.onButtonMemoryClearAll()">Clear All</button>
-                       <button class="dialogAbuttonBlack" id="memoryClose"
-                               onclick="Calculator.onButtonMemoryClose()">Close</button>
-               </div>
-       </div>
-
-       <div id="clearconfirmationdialog" style="visibility: hidden;">
-               <div class="dialogbackground"></div>
-               <div id="clearconfirmationdialogbg">
-                       <div id="dialogheading">Clear All Memory slots</div>
-                       <div id="dialogcontent">
-                               <div id="dialogcontenttext">All memory slots will be cleared.</div>
-                               <button class="dialogBpurplebutton" id="dialogokbutton"
-                                       onclick="Calculator.clearAllMemorySlots()">OK</button>
-                               <button class="dialogBblackbutton" id="dialogcancelbutton"
-                                       onclick="Calculator.cancelClearAllDialog()">Cancel</button>
-                       </div>
-               </div>
-       </div>
-
-       <div id="memorynoteeditor" style="display: none">
-               <div id="mnememorypane" class="memoryentrypane">
-                       <img id="mnebuttondownarrow" class="buttonlefticon"
-                               src="images/ico_arrow_white.png"></img>
-                       <div id="mnebutton"></div>
-                       <div id="mnetext" class="memorytext"></div>
-                       <div id="mnedescription"></div>
-                       <input id="mnedescriptioninput" type=text name=username size=21 />
-                       <div id="mnedescriptiondelete"></div>
-               </div>
-               <button class="dialogAbuttonPurple" id="mnesave">Save</button>
-               <button class="dialogAbuttonBlack" id="mnecancel">Cancel</button>
-       </div>
-       <div id="grammar-wrapper">
-               <textarea class="code" id="grammar" disabled>
-            start
-              = additive
-
-            additive
-              = left:(multiplicative [%]?) right:( [+-] multiplicative [%]?)*
-                {
-                    var ret = (left[1] == "%") ? left[0] / 100 : left[0];
-                    var i;
-                    var prec = 0;
-
-                    if(isNaN(ret) || !isFinite(ret) )
-                        return ret
-
-                    var tmp = ret;
-                    while (tmp % 1 != 0){
-                            tmp = tmp * 10;
-                            prec++;
-                        }
-                    for (i = 0; i < right.length; ++i) {
-                        var num = (right[i][2] == "%") ? ret * right[i][1] / 100 : right[i][1];
-
-                        tmp = num;
-                        var prec1 = 0;
-
-                        while (tmp % 1 != 0){
-                            tmp = tmp * 10;
-                            prec1++;
-                        }
-                        prec = prec > prec1 ? prec: prec1;
-
-                        if (right[i][0] == "+") {
-                            ret = ret + num;
-                        } else if (right[i][0] == "-") {
-                            ret = ret - num;
-                        }
-
-                    }
-                    return (prec > 0 && right.length > 0) ? parseFloat(ret.toFixed(prec)) : ret;
-                }
-
-            multiplicative
-              = left:signedexpression right:( [&#215;&#247;] signedexpression [%]? / trigonometric [%]? / hyperbolic [%]? / numberlog [%]? / squareroot [%]?)*
-                {
-                    var ret = left;
-                    var i;
-                    var prec = 0;
-
-                            if(isNaN(ret) || !isFinite(ret))
-                               return ret
-
-                    var tmp = ret;
-                    while (tmp % 1 != 0){
-                            tmp = tmp * 10;
-                            prec++;
-                        }
-
-                    for (i = 0; i < right.length; ++i) {
-                        var num = (right[i][2] == "%") ? right[i][1] / 100 : right[i][1];
-
-                        tmp = num;
-                        var prec1 = 0;
-                        while (tmp % 1 != 0){
-                            tmp = tmp * 10;
-                            prec1++;
-                        }
-
-                        if (right[i][0] == "&#215;") {
-                            ret = ret * num;
-                            prec += prec1;
-                        } else if (right[i][0] == "&#247;") {
-                            ret = ret / num;
-                            prec -= prec1;
-                        }else{
-                            ret = ret * right[i][0];
-                        }
-                    }
-                    return (prec > 0 && right.length > 0) ? parseFloat(ret.toFixed(prec)) : ret;
-                }
-            signedexpression
-              = sign:[-]? expression:expression
-                {
-                    var ret = expression;
-
-                    if (sign) {
-                        ret = -ret;
-                    }
-
-                    return ret;
-                }
-
-            expression
-              = expandlog
-              / powerandroot
-              / trigonometric
-              / hyperbolic
-              / factorial
-              / numberpi
-              / inverse
-              / primary
-
-            expandlog
-              = log10
-              / log2
-              / ln
-              / tentox
-              / twotox
-              / etox
-
-            numberlog
-              = log10
-              / log2
-              / ln
-
-            log10
-              = "log" operand:signedexpression
-                {
-                    return Math.log(operand) / Math.LN10;
-                }
-
-            log2
-              = "log<sub>2</sub>" operand:signedexpression
-                {
-                    return Math.log(operand) / Math.LN2;
-                }
-
-            ln
-              = "ln" operand:signedexpression
-                {
-                    return Math.log(operand);
-                }
-
-            tentox
-              = "10<sup>x</sup>" operand:signedexpression
-                {
-                    return Math.pow(10, operand);
-                }
-
-            twotox
-              = "2<sup>x</sup>" operand:signedexpression
-                {
-                    return Math.pow(2, operand);
-                }
-
-            etox
-              = "e<sup>x</sup>" operand:signedexpression
-                {
-                    return Math.pow(Math.E, operand);
-                }
-
-            powerandroot
-              = squareroot
-              / nthroot
-              / square
-              / nthpower
-
-            squareroot
-              = "&#8730;" radicand:signedexpression
-                {
-                    return Math.sqrt(radicand);
-                }
-
-            nthroot
-              = index:primary "<sup>n</sup>&#8730;" radicand:signedexpression
-                {
-                    var ret = Number.NaN;
-
-                    if (parseInt(index) === index && index > 0) { /* The nth root is only defined for positive integer indices. */
-                        if (index % 2 && radicand < 0) { /* For odd indices, consider the sign of the radicand. */
-                            ret = -Math.pow(-radicand, 1 / index);
-                        } else {
-                            ret = Math.pow(radicand, 1 / index);
-                        }
-                    }
-
-                    return ret;
-                }
-
-            square
-              = operand:primary "<sup>2</sup>"
-                {
-                    return Math.pow(operand, 2);
-                }
-
-            nthpower
-              = operand:primary "<sup>^</sup>" exponent:signedexpression
-                {
-                    return Math.pow(operand, exponent);
-                }
-
-            trigonometric
-              = sin
-              / cos
-              / tan
-              / arcsin
-              / arccos
-              / arctan
-
-            sin
-              = "sin" operand:signedexpression
-                {
-                    res = Math.sin(operand / Calculator.angleDivisor);
-                    return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
-                }
-            cos
-              = "cos" operand:signedexpression
-                {
-                    res = Math.cos(operand / Calculator.angleDivisor);
-                    return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
-                }
-            tan
-              = "tan" operand:signedexpression
-                {
-                    res = Math.tan(operand / Calculator.angleDivisor);
-                    return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
-                }
-            arcsin
-              = "sin<sup>-1</sup>" operand:signedexpression
-                {
-                    return Math.asin(operand) * Calculator.angleDivisor;
-                }
-            arccos
-              = "cos<sup>-1</sup>" operand:signedexpression
-                {
-                    return Math.acos(operand) * Calculator.angleDivisor;
-                }
-            arctan
-              = "tan<sup>-1</sup>" operand:signedexpression
-                {
-                    return Math.atan(operand) * Calculator.angleDivisor;
-                }
-
-            hyperbolic
-              = sinh
-              / cosh
-              / tanh
-              / asinh
-              / acosh
-              / atanh
-
-            sinh
-              = "sinh" operand:signedexpression
-                {
-                    var e = Math.E;
-
-                    return (Math.pow(e, operand) - Math.pow(e, -operand)) / 2;
-                }
-
-            cosh
-              = "cosh" operand:signedexpression
-                {
-                    var e = Math.E;
-
-                    return (Math.pow(e, operand) + Math.pow(e, -operand)) / 2;
-                }
-
-            tanh
-              = "tanh" operand:signedexpression
-                {
-                    var e = Math.E;
-
-                    return (Math.pow(e, operand) - Math.pow(e, -operand)) / (Math.pow(e, operand) + Math.pow(e, -operand));
-                }
-
-            asinh
-              = "sinh<sup>-1</sup>" operand:signedexpression
-                {
-                    return Math.log(operand + Math.sqrt(1 + Math.pow(operand, 2)));
-                }
-
-            acosh
-              = "cosh<sup>-1</sup>" operand:signedexpression
-                {
-                    return 2 * Math.log(Math.sqrt((operand + 1) / 2) + Math.sqrt((operand - 1) /2 ));
-                }
-
-            atanh
-              = "tanh<sup>-1</sup>" operand:signedexpression
-                {
-                    return (Math.log(1 + operand) - Math.log(1 - operand)) / 2;
-                }
-
-            factorial
-              = operand:primary "!"
-                {
-                    var ret = Number.NaN;
-
-                    if (parseInt(operand) === operand && operand >= 0) { /* Factorial is only defined for positive integers and zero. */
-                        ret = 1;
-
-                        for (var i = 2; i <= operand; i++) {
-                            ret *= i
-                        }
-                    }
-
-                    return ret;
-                }
-            inverse
-              = operand:primary "<sup>-1</sup>"
-                {
-                    return 1 / operand;
-                }
-
-            primary
-              = pi
-              / number
-              / "(" additive:additive ")"
-                {
-                    return additive;
-                }
-
-            numberpi
-              = operand:primary "&pi;"
-              {
-                return operand*Math.PI;
-              }
-
-            pi
-              = "&pi;"
-                {
-                    return Math.PI;
-                }
-
-            number
-              = wholepart:[0-9]+fractionalpart:([.][0-9]+)?
-                {
-                    var ret;
-
-                    if (fractionalpart) {
-                        ret = parseFloat(wholepart.join("") + "." + fractionalpart[1].join(""));
-                    } else {
-                        ret = parseInt(wholepart.join(""));
-                    }
-
-                    return ret;
-                }
-            </textarea>
-       </div>
-       <div id="help_dialog" class="helpdialog">
-               <div class="inner">
-                       <div id="help_close" class="close">x</div>
-                       <div id="help_contents" class="contents">
-                               <div class="column1">
-                                       <ul>
-                                               <li><b>General usage</b><br> Tap buttons in the order
-                                                       you would write them on paper to perform a calculation, then tap
-                                                       = to get the result.</li>
-                                               <br clear="all">
-                                               <li><b>History</b><br> <img
-                                                       src="images/bt_history_exp_port.png" align="left" /> Tap to see a
-                                                       scrollable history of recent results.<br clear="all"> <img
-                                                       src="images/bt_history_contr_port.png" align="left" /> Tap to
-                                                       restore the calculator.</li>
-                                               <br clear="all">
-                                               <li><b>Memory insert</b><br>
-                                                       <div class="buttonpurple" style="float: left;">
-                                                               <center>
-                                                                       <img src="images/ico_arrow_black.png" />
-                                                                       <bl>M1</bl>
-                                                               </center>
-                                                       </div> Tap to store the current result in the indicated memory slot.</li>
-                                       </ul>
-                                       <br clear="all">
-                               </div>
-                               <div class="column2">
-                                       <ul>
-                                               <li><b>Memory</b><br>
-                                                       <div class="buttonpurple" style="float: left;">
-                                                               <center>
-                                                                       <wh>M</wh>
-                                                                       <img src="images/ico_mem_list.png" />
-                                                               </center>
-                                                       </div> Tap the M button to display the current memory contents. <br
-                                                       clear="all">
-                                                       <div class="buttonpurple" style="float: left;">
-                                                               <center>
-                                                                       <img src="images/ico_arrow_white.png" />
-                                                                       <wh>M5</wh>
-                                                               </center>
-                                                       </div> Tap to insert the contents of that slot into your calculation. <br
-                                                       clear="all">
-                                                       <div class="exampleclose" style="float: left;"></div> Tap to
-                                                       clear the slot. <br clear="all">
-                                                       <div class="exampleedit" style="float: left;"></div> Tap to
-                                                       modify a slot’s contents. <br clear="all">
-                                                       <div class="dialogAbuttonPurple"
-                                                               style="position: relative; float: left;">
-                                                               <center>
-                                                                       <wh2>Clear All</wh2>
-                                                               </center>
-                                                       </div> Tap to erase every slot. <br clear="all">
-                                                       <div class="dialogAbuttonBlack"
-                                                               style="position: relative; float: left;">
-                                                               <center>
-                                                                       <wh2>Close</wh2>
-                                                               </center>
-                                                       </div> Tap to restore the calculator. <br clear="all"></li>
-                                       </ul>
-                               </div>
-                       </div>
-               </div>
-       </div>
-       <div id="licensepage" style="display: none">
-               <div id="licensetext">
-                       <div id="licensescroll"></div>
-               </div>
-               <div id="licensebtnq" class="licensebtn">Back</div>
-       </div>
-</body>
-
-<!-- external library js files -->
-<script src="js/jquery-1.7.2.min.js"></script>
-<script src="js/localizer.js"></script>
-<script src="js/iscroll.js"></script>
-<script src="js/peg-0.6.2.min.js"></script>
-
-<!-- internal js file -->
-<script src="js/license.js"></script>
-<script src="js/help.js"></script>
-<script src="js/calc.js"></script>
+    <head>
+               <meta id="viewport_meta" name="viewport" content="" />
+               <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+               <title>Scientific Calculator</title>
+               <link rel="stylesheet" id="stylesheet" type="text/css"
+                       href="css/calc_portrait.css" />
+               <script type="text/javascript">
+                               var viewport_meta = document.getElementById('viewport_meta');
+                               var w = screen.availWidth;
+                               var h = screen.availHeight;
+                               viewport_meta.setAttribute('content', 'width=' + w + ', height=' + h + ',user-scalable=no');
+                       </script>
+               </head>
+    <body>
+        <div id="background">
+            <div id="calculationpane">
+                <div id="LCD_Upper" style="display: none">
+                    <div id="wrapper">
+                        <div id="scroller">
+                            <div class="scroll-pane" id="calculationhistory"></div>
+                        </div>
+                    </div>
+                    <div id="historyverticalline"></div>
+                    <button class="historybuttonclose" id="closehistorybutton" onclick="Calculator.closeHistory()"></button>
+                </div>
+                <div id="LCD_Lower">
+                    <div id="upperpane">
+                        <div id="closebutton">
+                            <button class="buttonclose" id="buttonclosecurrentformula" onclick="Calculator.setCurrentFormula('')"></button>
+                        </div>
+                        <div id="currentformula"></div>
+                    </div>
+                    <div id="horizontaldivider"></div>
+                    <div id="lowerpane">
+                        <div id="closebutton">
+                            <button class="buttonclose" id="buttonclosemainentry" onclick="Calculator.setMainEntry('')"></button>
+                        </div>
+                        <div id="mainentry"></div>
+                        <button class="historybutton" id="openhistorybutton" onclick="Calculator.openHistory()"></button>
+                    </div>
+                </div>
+                <div id="keyboard">
+                    <div id="keyboardleft">
+                        <div id="leftmostpane">
+                            <div id="statetransition">
+                                <div id="degradswitch" class="switchleftactive">
+                                     <div class="buttontogglebackgroundB" id="buttondeg" onclick="Calculator.transitionToDegrees();">DEG</div>
+                                     <div class="buttontogglebackgroundA" id="buttonrad" onclick="Calculator.transitionToRadians();">RAD</div>
+                                </div>
+                                 <div id="traghypswitch" class="switchleftactive">
+                                     <div class="buttontogglebackgroundB" id="buttontrig" onclick="Calculator.transitionToTrigonometricFunctions()">TRIG</div>
+                                     <div class="buttontogglebackgroundA" id="buttonhyp" onclick="Calculator.transitionToHyperbolicFunctions()">HYP</div>
+                                </div>
+                            </div>
+                            <div id="trigonometric">
+                                <button class="buttonblackshort" id="buttonsin">sin</button>
+                                <button class="buttonblackshort" id="buttoncos">cos</button>
+                                <button class="buttonblackshort" id="buttontan">tan</button>
+                                <button class="buttonblackshort" id="buttonarcsin">sin<sup>-1</sup></button>
+                                <button class="buttonblackshort" id="buttonarccos">cos<sup>-1</sup></button>
+                                <button class="buttonblackshort" id="buttonarctan">tan<sup>-1</sup></button>
+                            </div>
+                            <div id="hyperbolic">
+                                <button class="buttonblackshort" id="buttonsinh">sinh</button>
+                                <button class="buttonblackshort" id="buttoncosh">cosh</button>
+                                <button class="buttonblackshort" id="buttontanh">tanh</button>
+                                <button class="buttonblackshort" id="buttonasinh">sinh<sup>-1</sup></button>
+                                <button class="buttonblackshort" id="buttonacosh">cosh<sup>-1</sup></button>
+                                <button class="buttonblackshort" id="buttonatanh">tanh<sup>-1</sup></button>
+                            </div>
+                            <div id="expandlog">
+                                <button class="buttonblackshort" id="buttonlog">log</button>
+                                <button class="buttonblackshort" id="buttonlog2">log<sub>2</sub></button>
+                                <button class="buttonblackshort" id="buttonln">ln</button>
+                                <button class="buttonblackshort" id="button10x" data-operator="10<sup>^</sup>">10<sup>x</sup></button>
+                                <button class="buttonblackshort" id="button2x" data-operator="2<sup>^</sup>">2<sup>x</sup></button>
+                                <button class="buttonblackshort" id="buttonex" data-operator="e<sup>^</sup>">e<sup>x</sup></button>
+                            </div>
+                        </div>
+                        <div id="centerleftpane">
+                            <div id="powerandroot">
+                                <button class="buttonyellow" id="buttonsquare" data-operator="<sup>2</sup>">x<sup>2</sup></button>
+                                <button class="buttonyellow" id="buttonsquareroot">&#8730;</button>
+                            </div>
+                            <div id="nthpowerandnthroot">
+                                <button class="buttonyellow" id="buttonnthpower" data-operator="<sup>^</sup>">y<sup>x</sup></button>
+                                <button class="buttonyellow" id="buttonnthroot" data-operator="<sup>n</sup>&#8730;"><sup>x</sup>&#8730;y</button>
+                            </div>
+                        </div>
+                    </div>
+                    <div id="keyboardsplitter"></div>
+                    <div id="keyboardright">
+                        <div id="centerrightpane">
+                            <button class="buttonpurple" id="buttonmemorylist" onclick="Calculator.onButtonMemoryListClick()">
+                                <div class="buttonlefttext">M</div>
+                                <img class="buttonrighticon" src="images/ico_mem_list.png"></img>
+                            </button>
+                            <button class="buttonpurple" id="buttonmemorize" onclick="Calculator.onButtonMainEntryToMemoryClick()">
+                                <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                                <div class="buttonrighttext" id="buttonmemorizetext"></div>
+                            </button>
+                            <button class="buttonblack" id="buttonleftparenthesis">(</button>
+                            <button class="buttonblack" id="buttonrightparenthesis">)</button>
+                            <button class="buttonblack" id="buttonfactorial" data-operator="!">x!</button>
+                            <button class="buttonblack" id="buttoninverse" data-operator="<sup>-1</sup>">x<sup>-1</sup></button>
+                            <button class="buttonblack" id="buttonpi">&pi;</button>
+                            <button class="buttonblack" id="buttonpercentage">%</button>
+                        </div>
+                        <div id="rightpane">
+                            <button class="buttonred" id="buttonclear">C</button>
+                            <button class="buttonblue" id="buttondivide">&#247;</button>
+                            <button class="buttonblue" id="buttonmultiply">&#215;</button>
+                            <button class="buttonwhite" id="button7">7</button>
+                            <button class="buttonwhite" id="button8">8</button>
+                            <button class="buttonwhite" id="button9">9</button>
+                            <button class="buttonwhite" id="button4">4</button>
+                            <button class="buttonwhite" id="button5">5</button>
+                            <button class="buttonwhite" id="button6">6</button>
+                            <button class="buttonwhite" id="button1">1</button>
+                            <button class="buttonwhite" id="button2">2</button>
+                            <button class="buttonwhite" id="button3">3</button>
+                            <button class="buttonwhite" id="button0">0</button>
+                            <button class="buttonblue" id="buttondot">.</button>
+                            <button class="buttonblue" id="buttonplusminus">+/&#8722;</button>
+                        </div>
+                        <div id="rightmostpane">
+                            <button class="buttonred" id="buttondelete"><img class="buttondeleteicon" src="images/ico_back.png" alt="backspace" height="26" width="40"/></button>
+                            <button class="buttonblue" id="buttonsubtract" data-operator="-">&#8722;</button>
+                            <button class="buttonblue" id="buttonadd">+</button>
+                            <button class="buttonblueequal" id="buttonequal">=</button>
+                        </div>
+                    </div>
+                </div>
+                <div id="licensebtnl"> i </div>
+                <div id="home_help" class="helplaunch"> ? </div>
+            </div>
+         </div>
+    </body>
+
+    <!-- external library js files -->
+    <script src="js/jquery-1.7.2.min.js"></script>
+
+    <!-- internal js file -->
+    <script src="js/calc.js"></script>
 </html>
 
index 3afcef2..5557644 100755 (executable)
@@ -13,13 +13,10 @@ $(function() {
     "use strict";
 
     Calculator = new function() {
-        license_init("license", "background");
-        help_init("home_help", "help_");
-        //
-        // Data
-        //
-        this.parser = PEG.buildParser(document.getElementById("grammar").innerText);
 
+
+        this.localizer = null;
+        this.parser = "";
         this.currentKey = "";
 
         /**
@@ -724,9 +721,6 @@ $(function() {
             document.getElementById("mnedescriptioninput").value = "";
         });
 
-        this.localizer = new Localizer();
-        this.localizer.localizeHtmlElements();
-
         /**
          * register for the orientation event changes
          */
@@ -765,14 +759,81 @@ $(function() {
         };
     };
 
-    Calculator.createScrollbars();
+    $("button").prop("disabled",true);
     Calculator.registerOrientationChange();
-    Calculator.initButtons();
-    Calculator.setMainEntry("");
-    Calculator.setCurrentFormula("");
-    Calculator.transitionToDegrees();
-    Calculator.transitionToTrigonometricFunctions();
-    Calculator.equalPressed = false;
-    Calculator.populateMemoryPaneFromLocalStorage();
-    Calculator.populateHistoryPaneFromLocalStorage();
+
+    window.addEventListener('pageshow', function () {
+        $.ajax("lazy.html").then(function(result){
+            // inject rest of js files
+            // and run Calculator init code that depends on them
+
+            var lazyScripts = [
+                {
+                    script: "js/peg-0.6.2.min.js",
+                    success: function(resolve) {
+                        Calculator.parser = PEG.buildParser(document.getElementById("grammar").innerText);
+                    }
+                },
+                {
+                    script: "js/license.js",
+                    success: function(resolve) {
+                        license_init("license", "background");
+                    }
+                },
+                {
+                    script: "js/help.js",
+                    success: function(resolve) {
+                        help_init("home_help", "help_");
+                    }
+                },
+                {
+                    script: "js/localizer.js",
+                    success: function(resolve) {
+                        Calculator.localizer = new Localizer();
+                        Calculator.localizer.localizeHtmlElements();
+                    }
+                },
+                {
+                    script: "js/iscroll.js",
+                    success: function(resolve) {
+                        Calculator.createScrollbars();
+                    }
+                }
+            ];
+            var promises = [];
+
+            // complete body
+            $("body").append(result);
+
+            function makeSuccessScript(success, resolve) {
+                return function() {
+                    success();
+                    resolve();
+                };
+            }
+
+            // inject js files
+            for (var index=0; index<lazyScripts.length; index++) {
+                var jqTag = document.createElement("script");
+                var dfd = $.Deferred();
+                promises.push(dfd.promise());
+                jqTag.onload=makeSuccessScript(lazyScripts[index].success, dfd.resolve);
+                jqTag.setAttribute("src",lazyScripts[index].script);
+                document.body.appendChild(jqTag);
+            }
+
+            // once all js files have been loaded and initialised/etc, do the rest
+            $.when.apply(null, promises).then(function() {
+                Calculator.initButtons();
+                Calculator.setMainEntry("");
+                Calculator.setCurrentFormula("");
+                Calculator.transitionToDegrees();
+                Calculator.transitionToTrigonometricFunctions();
+                Calculator.equalPressed = false;
+                Calculator.populateMemoryPaneFromLocalStorage();
+                Calculator.populateHistoryPaneFromLocalStorage();
+                $("button").prop("disabled",false);
+            });
+        });
+    }, false);
 });
diff --git a/lazy.html b/lazy.html
new file mode 100755 (executable)
index 0000000..8874293
--- /dev/null
+++ b/lazy.html
@@ -0,0 +1,609 @@
+         <div id=memorypage style="display: none;">
+            <div id="memorypagelcd">
+                <div id="mpclosebutton">
+                    <button class="buttonclose" id="mplcdbuttonclose" onclick="Calculator.setMainEntry('')"></button>
+                </div>
+                <div id="mpmainentry"></div>
+                <button class="historybutton" id="mpopenhistorybutton" onclick="Calculator.openHistory()"></button>
+            </div>
+
+            <div id="memorypane">
+                <div class="memoryentrypane" id="M1pane" data-entryname="M1">
+                    <button class="buttonmemory" id="buttonM1" onclick="Calculator.onButtonMemoryClick('M1')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M1</div>
+                    </button>
+                    <div class="memorypane" id="M1pane">
+                        <div class="memory" id="M1">
+                            <div id="M1text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M1description"></div>
+                            <input class="memorydescriptioninput" id="M1descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M1')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM1edit" onclick="Calculator.onButtonMemoryEditClick('M1')"></button>
+                        <button class="buttonmemoryclose" id="buttonM1close" onclick="Calculator.onButtonMemoryCloseClick('M1')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M2pane" data-entryname="M2">
+                    <button class="buttonmemory" id="buttonM2" onclick="Calculator.onButtonMemoryClick('M2')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M2</div>
+                    </button>
+                    <div class="memorypane" id="M2pane">
+                        <div class="memory" id="M2">
+                            <div id="M2text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M2description"></div>
+                            <input class="memorydescriptioninput" id="M2descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M2')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM2edit" onclick="Calculator.onButtonMemoryEditClick('M2')"></button>
+                        <button class="buttonmemoryclose" id="buttonM2close" onclick="Calculator.onButtonMemoryCloseClick('M2')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M3pane" data-entryname="M3">
+                    <button class="buttonmemory" id="buttonM3" onclick="Calculator.onButtonMemoryClick('M3')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M3</div>
+                    </button>
+                    <div class="memorypane" id="M3pane">
+                        <div class="memory" id="M3">
+                            <div id="M3text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M3description"></div>
+                            <input class="memorydescriptioninput" id="M3descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M3')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM3edit" onclick="Calculator.onButtonMemoryEditClick('M3')"></button>
+                        <button class="buttonmemoryclose" id="buttonM3close" onclick="Calculator.onButtonMemoryCloseClick('M3')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M4pane" data-entryname="M4">
+                    <button class="buttonmemory" id="buttonM4" onclick="Calculator.onButtonMemoryClick('M4')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M4</div>
+                    </button>
+                    <div class="memorypane" id="M4pane">
+                        <div class="memory" id="M4">
+                            <div id="M4text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M4description"></div>
+                            <input class="memorydescriptioninput" id="M4descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M4')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM4edit" onclick="Calculator.onButtonMemoryEditClick('M4')"></button>
+                        <button class="buttonmemoryclose" id="buttonM4close" onclick="Calculator.onButtonMemoryCloseClick('M4')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M5pane" data-entryname="M5">
+                    <button class="buttonmemory" id="buttonM5" onclick="Calculator.onButtonMemoryClick('M5')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M5</div>
+                    </button>
+                    <div class="memorypane" id="M5pane">
+                        <div class="memory" id="M5">
+                            <div id="M5text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M5description"></div>
+                            <input class="memorydescriptioninput" id="M5descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M5')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM5edit" onclick="Calculator.onButtonMemoryEditClick('M5')"></button>
+                        <button class="buttonmemoryclose" id="buttonM5close" onclick="Calculator.onButtonMemoryCloseClick('M5')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M6pane" data-entryname="M6">
+                    <button class="buttonmemory" id="buttonM6" onclick="Calculator.onButtonMemoryClick('M6')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M6</div>
+                    </button>
+                    <div class="memorypane" id="M6pane">
+                        <div class="memory" id="M6">
+                            <div id="M6text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M6description"></div>
+                            <input class="memorydescriptioninput" id="M6descriptioninput" type=text name=username size=21 onfocusout="Calculator.saveMemoryDescription('M6')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM6edit" onclick="Calculator.onButtonMemoryEditClick('M6')"></button>
+                        <button class="buttonmemoryclose" id="buttonM6close" onclick="Calculator.onButtonMemoryCloseClick('M6')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M7pane" data-entryname="M7">
+                    <button class="buttonmemory" id="buttonM7" onclick="Calculator.onButtonMemoryClick('M7')">
+                            <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                            <div class="buttonrighttext" id="buttonmemorizetext">M7</div>
+                    </button>
+                    <div class="memorypane" id="M7pane">
+                        <div class="memory" id="M7">
+                            <div id="M7text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M7description"></div>
+                            <input class="memorydescriptioninput" id="M7descriptioninput" type=text name=username size=21 onfocusout="Calculator.onMemoryDescriptionInputFocusOut('M7')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM7edit" onclick="Calculator.onButtonMemoryEditClick('M7')"></button>
+                        <button class="buttonmemoryclose" id="buttonM7close" onclick="Calculator.onButtonMemoryCloseClick('M7')"></button>
+                    </div>
+                </div>
+                <div class="memoryentrypane" id="M8pane" data-entryname="M8">
+                    <button class="buttonmemory" id="buttonM8" onclick="Calculator.onButtonMemoryClick('M8')">
+                        <img class="buttonlefticon" src="images/ico_arrow_black.png"></img>
+                        <div class="buttonrighttext" id="buttonmemorizetext">M8</div>
+                    </button>
+                    <div class="memorypane" id="M8pane">
+                        <div class="memory" id="M8">
+                            <div id="M8text" class="memorytext"></div>
+                        </div>
+                        <div class="memorydescription">
+                            <div class="memorydescriptiontext" id="M8description"></div>
+                            <input class="memorydescriptioninput" id="M8descriptioninput" type=text name=username size=21 onfocusout="Calculator.saveMemoryDescription('M8')"/>
+                        </div>
+                        <button class="buttonmemoryedit" id="buttonM8edit" onclick="Calculator.onButtonMemoryEditClick('M8')"></button>
+                        <button class="buttonmemoryclose" id="buttonM8close" onclick="Calculator.onButtonMemoryCloseClick('M8')"></button>
+                    </div>
+                </div>
+                <button class="dialogAbuttonPurple" id="memoryclearall" onclick="Calculator.onButtonMemoryClearAll()">Clear All</button>
+                <button class="dialogAbuttonBlack" id="memoryClose" onclick="Calculator.onButtonMemoryClose()">Close</button>
+            </div>
+        </div>
+
+        <div id="clearconfirmationdialog" style="visibility: hidden;">
+            <div class="dialogbackground"></div>
+            <div id="clearconfirmationdialogbg">
+                <div id="dialogheading">Clear All Memory slots</div>
+                <div id="dialogcontent">
+                    <div id="dialogcontenttext">All memory slots will be cleared.</div>
+                    <button class="dialogBpurplebutton" id="dialogokbutton" onclick="Calculator.clearAllMemorySlots()">OK</button>
+                     <button class="dialogBblackbutton" id="dialogcancelbutton" onclick="Calculator.cancelClearAllDialog()">Cancel</button>
+                </div>
+            </div>
+        </div>
+
+        <div id="memorynoteeditor" style="display: none">
+            <div id="mnememorypane" class="memoryentrypane">
+                <img id="mnebuttondownarrow" class="buttonlefticon" src="images/ico_arrow_white.png"></img>
+                <div id="mnebutton"></div>
+                <div id="mnetext" class="memorytext"></div>
+                <div id="mnedescription"></div>
+                <input id="mnedescriptioninput" type=text name=username size=21/>
+                <div id="mnedescriptiondelete"></div>
+            </div>
+            <button class="dialogAbuttonPurple" id="mnesave">Save</button>
+            <button class="dialogAbuttonBlack"id="mnecancel">Cancel</button>
+        </div>
+        <div id="grammar-wrapper">
+            <textarea class="code" id="grammar" disabled>
+                start
+                  = additive
+
+                           additive
+                             = left:(multiplicative [%]?) right:( [+-] multiplicative [%]?)*
+                               {
+                                   var ret = (left[1] == "%") ? left[0] / 100 : left[0];
+                                   var i;
+                                   var prec = 0;
+
+                                   if(isNaN(ret) || !isFinite(ret) )
+                                       throw new Error("malformed number");
+
+                                   var tmp = ret;
+                                   while (tmp % 1 != 0 && prec < 20 ){
+                                           tmp = tmp * 10;
+                                           prec++;
+                                       }
+                                   for (i = 0; i < right.length; ++i) {
+                                       var num = (right[i][2] == "%") ? ret * right[i][1] / 100 : right[i][1];
+                                       if(isNaN(num) || !isFinite(num) )
+                                           throw new Error("malformed number");
+
+                                       tmp = num;
+                                       var prec1 = 0;
+
+                                       while (tmp % 1 != 0 && prec1 < 20){
+                                           tmp = tmp * 10;
+                                           prec1++;
+                                       }
+                                       prec = prec > prec1 ? prec: prec1;
+
+                                       if (right[i][0] == "+") {
+                                           ret = ret + num;
+                                       } else if (right[i][0] == "-") {
+                                           ret = ret - num;
+                                       }
+
+                                   }
+                                   return (prec <=20 && prec > 0 && right.length > 0) ? parseFloat(ret.toFixed(prec)) : ret;
+                               }
+
+                           multiplicative
+                             = left:signedexpression right:( [&#215;&#247;] signedexpression [%]? / trigonometric [%]? / hyperbolic [%]? / numberlog [%]? / squareroot [%]?)*
+                               {
+                                   var ret = left;
+                                   var i;
+                                   var prec = 0;
+
+                                   if(isNaN(ret) || !isFinite(ret))
+                                       throw new Error("malformed number");
+
+                                   var tmp = ret;
+                                   while (tmp % 1 != 0 && prec <20){
+                                           tmp = tmp * 10;
+                                           prec++;
+                                       }
+
+                                   for (i = 0; i < right.length; ++i) {
+                                       var num = (right[i][2] == "%") ? right[i][1] / 100 : right[i][1];
+                                       if(isNaN(num) || !isFinite(num) )
+                                           throw new Error("malformed number");
+
+                                       tmp = num;
+                                       var prec1 = 0;
+                                       while (tmp % 1 != 0 && prec < 20){
+                                           tmp = tmp * 10;
+                                           prec1++;
+                                       }
+
+                                       if (right[i][0] == "&#215;") {
+                                           ret = ret * num;
+                                           prec += prec1;
+                                       } else if (right[i][0] == "&#247;") {
+                                           ret = ret / num;
+                                           prec -= prec1;
+                                       }else{
+                                           ret = ret * right[i][0];
+                                       }
+                                   }
+                                   return (prec <= 20 && prec > 0 && right.length > 0) ? parseFloat(ret.toFixed(prec)) : ret;
+                               }
+                signedexpression
+                  = sign:[-]? expression:expression
+                    {
+                        var ret = expression;
+
+                        if (sign) {
+                            ret = -ret;
+                        }
+
+                        return ret;
+                    }
+
+                expression
+                  = expandlog
+                  / powerandroot
+                  / trigonometric
+                  / hyperbolic
+                  / factorial
+                  / numberpi
+                  / inverse
+                  / primary
+
+                expandlog
+                  = log10
+                  / log2
+                  / ln
+                  / tentox
+                  / twotox
+                  / etox
+
+                numberlog
+                  = log10
+                  / log2
+                  / ln
+
+                log10
+                  = "log" operand:signedexpression
+                    {
+                        return Math.log(operand) / Math.LN10;
+                    }
+
+                log2
+                  = "log<sub>2</sub>" operand:signedexpression
+                    {
+                        return Math.log(operand) / Math.LN2;
+                    }
+
+                ln
+                  = "ln" operand:signedexpression
+                    {
+                        return Math.log(operand);
+                    }
+
+                tentox
+                  = "10<sup>x</sup>" operand:signedexpression
+                    {
+                        return Math.pow(10, operand);
+                    }
+
+                twotox
+                  = "2<sup>x</sup>" operand:signedexpression
+                    {
+                        return Math.pow(2, operand);
+                    }
+
+                etox
+                  = "e<sup>x</sup>" operand:signedexpression
+                    {
+                        return Math.pow(Math.E, operand);
+                    }
+
+                powerandroot
+                  = squareroot
+                  / nthroot
+                  / square
+                  / nthpower
+
+                squareroot
+                  = "&#8730;" radicand:signedexpression
+                    {
+                        return Math.sqrt(radicand);
+                    }
+
+                nthroot
+                  = index:primary "<sup>n</sup>&#8730;" radicand:signedexpression
+                    {
+                        var ret = Number.NaN;
+
+                        if (parseInt(index) === index && index > 0) { /* The nth root is only defined for positive integer indices. */
+                            if (index % 2 && radicand < 0) { /* For odd indices, consider the sign of the radicand. */
+                                ret = -Math.pow(-radicand, 1 / index);
+                            } else {
+                                ret = Math.pow(radicand, 1 / index);
+                            }
+                        }
+
+                        return ret;
+                    }
+
+                square
+                  = operand:primary "<sup>2</sup>"
+                    {
+                        return Math.pow(operand, 2);
+                    }
+
+                nthpower
+                  = operand:primary "<sup>^</sup>" exponent:signedexpression
+                    {
+                        return Math.pow(operand, exponent);
+                    }
+
+                trigonometric
+                  = sin
+                  / cos
+                  / tan
+                  / arcsin
+                  / arccos
+                  / arctan
+
+                sin
+                  = "sin" operand:signedexpression
+                    {
+                        res = Math.sin(operand / Calculator.angleDivisor);
+                        return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
+                    }
+                cos
+                  = "cos" operand:signedexpression
+                    {
+                        res = Math.cos(operand / Calculator.angleDivisor);
+                        return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
+                    }
+                tan
+                  = "tan" operand:signedexpression
+                    {
+                        res = Math.tan(operand / Calculator.angleDivisor);
+                        return Math.round(res * Calculator.trigPrecision) / Calculator.trigPrecision;
+                    }
+                arcsin
+                  = "sin<sup>-1</sup>" operand:signedexpression
+                    {
+                        return Math.asin(operand) * Calculator.angleDivisor;
+                    }
+                arccos
+                  = "cos<sup>-1</sup>" operand:signedexpression
+                    {
+                        return Math.acos(operand) * Calculator.angleDivisor;
+                    }
+                arctan
+                  = "tan<sup>-1</sup>" operand:signedexpression
+                    {
+                        return Math.atan(operand) * Calculator.angleDivisor;
+                    }
+
+                hyperbolic
+                  = sinh
+                  / cosh
+                  / tanh
+                  / asinh
+                  / acosh
+                  / atanh
+
+                sinh
+                  = "sinh" operand:signedexpression
+                    {
+                        var e = Math.E;
+
+                        return (Math.pow(e, operand) - Math.pow(e, -operand)) / 2;
+                    }
+
+                cosh
+                  = "cosh" operand:signedexpression
+                    {
+                        var e = Math.E;
+
+                        return (Math.pow(e, operand) + Math.pow(e, -operand)) / 2;
+                    }
+
+                tanh
+                  = "tanh" operand:signedexpression
+                    {
+                        var e = Math.E;
+
+                        return (Math.pow(e, operand) - Math.pow(e, -operand)) / (Math.pow(e, operand) + Math.pow(e, -operand));
+                    }
+
+                asinh
+                  = "sinh<sup>-1</sup>" operand:signedexpression
+                    {
+                        return Math.log(operand + Math.sqrt(1 + Math.pow(operand, 2)));
+                    }
+
+                acosh
+                  = "cosh<sup>-1</sup>" operand:signedexpression
+                    {
+                        return 2 * Math.log(Math.sqrt((operand + 1) / 2) + Math.sqrt((operand - 1) /2 ));
+                    }
+
+                atanh
+                  = "tanh<sup>-1</sup>" operand:signedexpression
+                    {
+                        return (Math.log(1 + operand) - Math.log(1 - operand)) / 2;
+                    }
+
+                factorial
+                  = operand:primary "!"
+                    {
+                        var ret = Number.NaN;
+
+                        if (parseInt(operand) === operand && operand >= 0) { /* Factorial is only defined for positive integers and zero. */
+                            ret = 1;
+
+                            for (var i = 2; i <= operand; i++) {
+                                ret *= i
+                            }
+                        }
+
+                        return ret;
+                    }
+                inverse
+                  = operand:primary "<sup>-1</sup>"
+                    {
+                        return 1 / operand;
+                    }
+
+                primary
+                  = pi
+                  / number
+                  / "(" additive:additive ")"
+                    {
+                        return additive;
+                    }
+
+                numberpi
+                  = operand:primary "&pi;"
+                  {
+                    return operand*Math.PI;
+                  }
+
+                pi
+                  = "&pi;"
+                    {
+                        return Math.PI;
+                    }
+
+                   number
+                     = wholepart:[0-9]+fractionalpart:([.][0-9]+)?scienpart:([eE][\+\-]?[0-9]+)?
+                       {
+                           var ret;
+
+                           var nstr = wholepart.join("");
+                           if(fractionalpart) {
+                               nstr += "." + fractionalpart[1].join("");
+                           }
+                           if(scienpart) {
+                               nstr += "e";
+                               if(scienpart[1] == '+' || scienpart[1] == '-') {
+                                   nstr += scienpart[1];
+                               }
+                               nstr += scienpart[2].join("");
+                           }
+
+                           if(fractionalpart) {
+                               ret = parseFloat(nstr);
+                           }
+                           else {
+                               ret = parseInt(nstr);
+                           }
+
+                           return ret;
+                       }
+            </textarea>
+        </div>
+        <div id="help_dialog" class="helpdialog">
+            <div class="inner">
+                <div id="help_close" class="close"> x </div>
+                <div id="help_contents" class="contents">
+                    <div class="column1">
+                        <ul>
+                            <li>
+                                <b>General usage</b><br/>
+                                Tap buttons in the order you would write them on paper
+                                to perform a calculation, then tap = to get the result.
+                            </li><br clear="all"/><li>
+                                <b>History</b><br/>
+                                <img src="images/bt_history_exp_port.png" align="left"/>
+                                Tap to see a scrollable history of recent results.<br clear="all"/>
+                                <img src="images/bt_history_contr_port.png" align="left"/>
+                                Tap to restore the calculator.
+                            </li><br clear="all"/><li>
+                                <b>Memory insert</b><br/>
+                                <div class="buttonpurple" style="float: left;">
+                                    <center>
+                                        <img src="images/ico_arrow_black.png"/><span class="black">M1</span>
+                                    </center>
+                                </div>
+                                Tap to store the current result in the indicated memory slot.
+                            </li>
+                        </ul>
+                        <br clear="all"/>
+                    </div>
+                    <div class="column2">
+                        <ul>
+                            <li>
+                                <b>Memory</b><br/>
+                                <div class="buttonpurple" style="float: left;">
+                                    <center>
+                                        <span class="white">M</span><img src="images/ico_mem_list.png"/>
+                                    </center>
+                                </div>
+                                Tap the M button to display the current memory contents.
+                                <br clear="all"/>
+                                <div class="buttonpurple" style="float: left;">
+                                    <center>
+                                        <img src="images/ico_arrow_white.png"/><span class="white">M5</span>
+                                    </center>
+                                </div>
+                                Tap to insert the contents of that slot into your calculation.
+                                <br clear="all"/>
+                                <div class="exampleclose" style="float: left;"></div>
+                                Tap to clear the slot.
+                                <br clear="all"/>
+                                <div class="exampleedit" style="float: left;"></div>
+                                Tap to modify a slot’s contents.
+                                <br clear="all"/>
+                                <div class="dialogAbuttonPurple" style="position: relative; float: left;">
+                                    <center>
+                                        <span class="white2">Clear All</span>
+                                    </center>
+                                </div>
+                                Tap to erase every slot.
+                                <br clear="all"/>
+                                <div class="dialogAbuttonBlack" style="position: relative; float: left;">
+                                    <center>
+                                        <span class="white2">Close</span>
+                                    </center>
+                                </div>
+                                Tap to restore the calculator.
+                                <br clear="all"/>
+                            </li>
+                        </ul>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div id="licensepage" style="display: none">
+            <div id="licensetext">
+                <div id="licensescroll"></div>
+            </div>
+            <div id="licensebtnq" class="licensebtn">Back</div>
+        </div>
old mode 100644 (file)
new mode 100755 (executable)