Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #62 from PawelGorny/lifeClassic

LifeClassic - init
  • Loading branch information...
commit d47f4c150e6c2edb9a4a063dcdbf1d2a9d235d3b 2 parents 9a89621 + b316853
@timwindsor timwindsor authored
View
1  .gitignore
@@ -1,2 +1,3 @@
add
.DS_Store
+/nbproject/private/
View
208 LifeClassic/LICENSE
@@ -0,0 +1,208 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+
+This software contains icons from Myers Design Limited
+250 FREE PNGs for Your BB10 Apps: http://myersdesign.com/bb10-icons-2013/
+Licensed under the Creative Commons Attribution 3.0 Unported
+http://creativecommons.org/licenses/by/3.0/
View
17 LifeClassic/README.md
@@ -0,0 +1,17 @@
+Life Classic
+=======
+
+Simple implementation of classic "GAME OF LIFE". Uses BB10 UI and services (in-app payment). 'Built for BlackBerry' test passed.
+License:
+This code is released under an Apache Open Source license.
+
+Testing:
+To test, download the source code and compile it. The application is available for Blackberry OS and BlackBerry 10 in BlackBerry World..
+
+Privacy:
+As you can see if you check the source code, this app doesn't save or transmit any personal information; if by any strange chance I get any of your information (excluding, of course, your email address if you contact me with a question) I'll delete it, as I have no use for it. I don't want your personal information, I'm not Google.
+
+This software contains icons from Myers Design Limited
+250 FREE PNGs for Your BB10 Apps: http://myersdesign.com/bb10-icons-2013/
+Licensed under the Creative Commons Attribution 3.0 Unported
+http://creativecommons.org/licenses/by/3.0/
View
21 LifeClassic/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets"
+ xmlns:rim="http://www.blackberry.com/ns/widgets"
+ version="1.2.10.0" id="LifeClassic17a4f020e6f2fc7e7fbcaa9a6cf25e23">
+ <name>LifeClassic</name>
+ <description>Game of life (classic version)</description>
+ <content src="indexbb10.html"/>
+ <icon src="icon.png"/>
+<feature id="blackberry.app"/>
+<feature id="blackberry.payment" />
+<feature id="blackberry.invoke" version="1.0.0"/>
+<feature id="blackberry.identity" version="1.0.0"/>
+<feature id="blackberry.ui.dialog" />
+<feature id="blackberry.invoked" version="1.0.0" required="true" />
+<rim:orientation mode="portrait"/>
+<feature id="blackberry.app">
+ <param name="orientation" value="portrait" />
+</feature>
+<author rim:copyright="Pawel Gorny 2012" href="http://pawelgorny.com/">PGUI</author>
+
+</widget>
View
1  LifeClassic/css/BlackBerry-JQM-all-1.0.0.min.css
1 addition, 0 deletions not shown
View
40 LifeClassic/css/life.css
@@ -0,0 +1,40 @@
+body {
+ background-color: #FFFFFF;
+ color: #111111;
+ font-size: 12pt;
+ font-family: Tahoma, Arial;
+}
+
+.but{
+ width:90px;
+ height: 40px
+}
+
+table{
+ background-color: #ddccdd;
+ border-color: #600;
+ border-width: 1px 1px 1px 1px;
+ border-style: none;
+ border-collapse: collapse;
+}
+
+.myTd{
+ cursor:crosshair;
+ width: 46px;
+ height: 46px;
+ margin: 0;
+ border-color: #600;
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ text-align: center;
+ vertical-align: middle;
+
+}
+
+.rules{
+ display:none;
+ font-size: 9pt;
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+}
+
View
40 LifeClassic/css/lifebb10.css
@@ -0,0 +1,40 @@
+body {
+ background-color: #FFFFFF;
+ color: #111111;
+ font-size: 12pt;
+ font-family: Tahoma, Arial;
+}
+
+.but{
+ width:6em;
+ height: 4em;
+}
+
+table{
+ background-color: #ddccdd;
+ border-color: #600;
+ border-width: 1px 1px 1px 1px;
+ border-style: none;
+ border-collapse: collapse;
+}
+
+td{
+ cursor:crosshair;
+ width: 46px;
+ height: 46px;
+ margin: 0;
+ border-color: #600;
+ border-width: 1px 1px 1px 1px;
+ border-style: solid;
+ text-align: center;
+ vertical-align: middle;
+
+}
+
+.rules{
+ display:none;
+ font-size: 12pt;
+ border-width: 2px 2px 2px 2px;
+ border-style: solid;
+}
+
View
BIN  LifeClassic/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/009. Check mark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/012. Info.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/013. Dollar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/040. Settings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/059. Play.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  LifeClassic/img/207. Refresh2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
90 LifeClassic/indexbb10.html
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title></title>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<script>
+ var meta = document.createElement("meta");
+ meta.setAttribute('name', 'viewport');
+ meta.setAttribute('content', 'initial-scale='
+ + (1 / window.devicePixelRatio) + ',user-scalable=no');
+ document.getElementsByTagName('head')[0].appendChild(meta);
+</script>
+<script type="text/javascript" src="local:///chrome/webworks.js"></script>
+<script type="text/javascript" src="./js/BlackBerry-JQM-all-1.0.0.min.js"></script>
+<script type="text/javascript" src="./js/life.js"></script>
+<link rel="stylesheet" href="./css/BlackBerry-JQM-all-1.0.0.min.css" type="text/css" media="all" />
+<link rel="stylesheet" href="./css/life.css" type="text/css" media="all" />
+</head>
+
+<body>
+
+ <div data-role="page">
+ <div data-role="panel" id="top" data-dark-modal="true"
+ data-position="top" data-display="push" data-theme="a" class="">
+ <div data-role="applicationmenu">
+ <a data-role="action" href="#" onclick="showAbout();return false;">
+ <img src="img/012. Info.png" alt="" />
+ <p>Info</p>
+ </a> <a data-role="SettingsActionItem" href="#"
+ onclick="showSetting(true); return false;"> <img
+ src="img/040. Settings.png" alt="" />
+ <p>Settings</p>
+ </a>
+ </div>
+ </div>
+
+ <div data-role="footer" data-position="fixed">
+ <div id="tover" data-role="tab-overflow"></div>
+ <div data-role="actionbar">
+ <div id="o1" data-role="action" class="active" onclick="setTable();">
+ <img src="./img/207. Refresh2.png" alt="reload" />
+ <p>reset</p>
+ </div>
+ <div id="o2" data-role="action" class="active"
+ onclick="randomize();">
+ <img src="./img/009. Check mark.png" alt="randomize" />
+ <p>randomize</p>
+ </div>
+ <div id="o3" data-role="action" class="active" onclick="start();">
+ <img src="./img/059. Play.png" alt="play" />
+ <p>play</p>
+ </div>
+ <div id="o4" data-role="action" class="active" onclick="donate();">
+ <img src="./img/013. Dollar.png" alt="donate" />
+ <p>donate $0.99</p>
+ </div>
+ </div>
+ </div>
+
+ <div data-role="content">
+ <div id="ustawienia" style="display: none">
+ <label for="cols">number of columns:</label>
+ <input type="range" name="cols" id="cols" value="15" min="5" max="15" data-highlight="true"/>
+ <label for="rows">number of rows:</label>
+ <input type="range" name="rows" id="rows" value="12" min="5" max="20" data-highlight="true"/>
+
+ <br /> <input type="button" value="OK" onclick="showSetting(false);" />
+ </div>
+
+
+ <div id="tablica" style="display: block">
+ <span id="spanStable" style="display: none"></span>
+ <span
+ id="spanSN" style="display: block; font-size: 3em"> Steps: <span
+ id="stepNumber">0</span>
+ </span>
+ <div id="lifeTable" style="float: left"></div>
+ </div>
+
+
+ </div>
+ </div>
+
+ <script>
+ window.addEventListener("load", function(e) {
+ document.addEventListener("webworksready", bodyOnLoad)
+ }, false);
+ </script>
+</body>
+</html>
View
8 LifeClassic/js/BlackBerry-JQM-all-1.0.0.min.js
8 additions, 0 deletions not shown
View
351 LifeClassic/js/life.js
@@ -0,0 +1,351 @@
+var rows=0;
+var cols=0;
+var percent=75;
+var myTable=null;
+var work=false;
+var breakWork=false;
+var colorON='#22dd22';
+var colorOFF='#ddccdd';
+var stepNr=0;
+var delay=750;
+var randomLevel=0.5;
+var header="LifeClassic";
+
+function setTable()
+{
+ if (!setRowsCols())
+ return;
+ printTable();
+}
+
+function randomize()
+{
+ if (work)
+ return;
+ for (var c=0; c<cols; c++)
+ for (var r=0; r<rows; r++)
+ {
+ if (Math.random()>=randomLevel)
+ myTable[c][r]=1;
+ else myTable[c][r]=0;
+ paintCell(c,r,myTable[c][r]);
+ }
+}
+
+function setCell(col, row)
+{
+ if (work)
+ return;
+ var x=myTable[col][row];
+ if (x==1)
+ {
+ myTable[col][row]=0;
+ paintCell(col,row,0);
+ }
+ else
+ {
+ myTable[col][row]=1;
+ paintCell(col,row,1);
+ }
+}
+
+function paintCell(col,row,v)
+{
+ var cell=window.document.getElementById('c_'+col+'_'+row);
+ if (v==1)
+ {
+ cell.innerHTML=' ';
+ cell.style.backgroundColor=colorON;
+ }
+ else
+ {
+ cell.innerHTML=' ';
+ cell.style.backgroundColor=colorOFF;
+ }
+}
+
+function printTable()
+{
+ window.document.getElementById('lifeTable').innerHTML='';
+ window.document.getElementById('stepNumber').innerHTML=0;
+ window.document.getElementById('spanStable').style.display='none';
+ var t='<table>';
+ for (var r=0; r<rows; r++)
+ {
+ t+='<tr>';
+ for (var c=0; c<cols; c++)
+ {
+ t+='<td class="myTd" id="c_'+c+'_'+r+'" onclick="setCell('+c+','+r+')"></td>';
+ }
+ t+='</tr>';
+ }
+ t+='</table>';
+ window.document.getElementById('lifeTable').innerHTML=t;
+ myTable=new Array(cols);
+ for (i=0; i<cols; i++)
+ myTable[i]=new Array(rows);
+}
+
+function step()
+{
+ work=false;
+ if (breakWork)
+ return;
+ stepNr++;
+ //alert('step'+stepNr);
+ window.document.getElementById('stepNumber').innerHTML=stepNr;
+ //var myTableCopy=myTable.slice();
+ var myTableCopy=copyTable();
+ var alive=false;
+ var dead=false;
+ for(var c=0; c<cols; c++)
+ {
+ for(var r=0; r<rows; r++)
+ {
+ var neightbours=getNeightboursNr(myTableCopy, c,r);
+ //alert (neightbours);
+ var me=myTableCopy[c][r];
+ if (me==1 && (neightbours>3||neightbours<2))
+ {
+ paintCell(c,r,0);
+ myTable[c][r]=0;
+ dead=true;
+ }
+ else if (me!=1 && neightbours==3)
+ {
+ paintCell(c,r,1);
+ myTable[c][r]=1;
+ alive=true;
+ }
+ else if (me==1)
+ {
+ myTable[c][r]=1;
+ alive=true;
+ }
+ else {
+ myTable[c][r]=0;
+ dead=true;
+ }
+ }
+ }
+ if (dead&&!alive)
+ {
+ showAlertH('All the cells are dead! Population has died after '+stepNr+' generation(s)', 'GAME OVER');
+ workEnd();
+ return;
+ }
+ else work=true;
+ if (work)
+ {
+ if (isStable(myTableCopy))
+ {
+ window.document.getElementById('spanStable').innerHTML='You reached "static pattern"!';
+ window.document.getElementById('spanStable').style.display='block';
+ workEnd();
+ showAlertH('You have reached "the static pattern"! (congratulations?)', 'GAME OVER');
+ return;
+ }
+ myTableCopy=null;
+ setTimeout("step()", delay);
+ }
+}
+
+function copyTable()
+{
+ var myTableCopy=new Array(cols);
+ for (i=0; i<cols; i++)
+ myTableCopy[i]=new Array(rows);
+
+for (var i = 0; i< cols; i++)
+{
+ for (var j = 0; j<rows; j++)
+ {
+ myTableCopy[i][j]=myTable[i][j];
+ }
+}
+ return myTableCopy;
+}
+
+function isStable(newArray)
+{
+for (var i = 0; i< cols; i++)
+{
+ for (var j = 0; j<rows; j++)
+ {
+ if (newArray[i][j] != myTable[i][j]) {
+ return false;
+ }
+ }
+}
+return true;
+}
+
+function workEnd()
+{
+breakWork=true;
+work=false;
+myTable=null;
+}
+
+function start()
+{
+ if (work==false)
+ {
+ if(!isSomethingAlive())
+ {
+ showAlert('Please set some cells as "alive" or use "randomize" button!');
+ return;
+ }
+ work=true;
+ breakWork=false;
+ stepNr=0;
+ step();
+ }
+ else
+ {
+ workEnd();
+ }
+}
+
+function isSomethingAlive()
+{
+for (var i = 0; i< cols; i++)
+{
+ for (var j = 0; j<rows; j++)
+ {
+ if(myTable[i][j]==1)
+ return true;
+ }
+}
+return false;
+}
+
+function getNeightboursNr(t, col,row)
+{
+ var n=0;
+ if (col-1>=0)
+ {
+ if (row-1>=0 && t[col-1][row-1]==1)
+ n++;
+ if (t[col-1][row]==1)
+ n++;
+ if (row+1<rows && t[col-1][row+1]==1)
+ n++;
+ }
+ if (col+1<cols)
+ {
+ if (row-1>=0 && t[col+1][row-1]==1)
+ n++;
+ if (t[col+1][row]==1)
+ n++;
+ if (row+1<rows && t[col+1][row+1]==1)
+ n++;
+ }
+ if (row-1>=0 && t[col][row-1]==1)
+ n++;
+ if (row+1<rows && t[col][row+1]==1)
+ n++;
+ return n;
+}
+
+function setRowsCols()
+{
+ var x;
+ x=window.document.getElementById('rows').value;
+ if (x<=0 || x>20)
+ {
+ showAlert('Number of rows should be in <5,20>');
+ return false;
+ }
+ rows=x;
+ x=window.document.getElementById('cols').value;
+ if (x<=0 || x>30)
+ {
+ showAlert('Number of columns should be in <5,15>');
+ return false;
+ }
+ cols=x;
+ return true;
+}
+
+function showRules()
+{
+ var r=window.document.getElementById('rules');
+ if (r.style.display=='none')
+ r.style.display='block';
+ else r.style.display='none';
+}
+function showAlertH(txt, head){
+ try {
+ blackberry.ui.dialog.standardAskAsync(txt, blackberry.ui.dialog.D_OK, dialogCallBack, {title : head});
+ }catch (e) {
+ alert("Exception in 'Alert': " + e);
+ }
+}
+function showAlert(txt){
+ try {
+ blackberry.ui.dialog.standardAskAsync(txt, blackberry.ui.dialog.D_OK, dialogCallBack, {title : "! ! ! ! !"});
+ }catch (e) {
+ alert("Exception in 'Alert': " + e);
+ }
+}
+function dialogCallBack(selection){
+}
+
+var aboutText='<ul><li>Any live cell with fewer than two live neighbours dies, as if caused by under-population.</li><li>Any live cell with two or three live neighbours lives on to the next generation.</li><li>Any live cell with more than three live neighbours dies, as if by overcrowding.</li><li>Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.</li></ul><b>Please set dimensions of the grid, then tap the cells You want to set as a \'alive\' or use \'randomize\' button.</b>';
+
+
+function dialogAboutCallBack(selection){
+ $('#top').panel("close");
+}
+function showAbout(){
+ try {
+ blackberry.ui.dialog.standardAskAsync(aboutText, blackberry.ui.dialog.D_OK, dialogAboutCallBack, {title : header});
+ }catch (e) {
+ alert("Exception in 'About': " + e);
+ }
+}
+
+function bodyOnLoad(){
+ if(typeof blackberry != 'undefined'){
+ blackberry.event.addEventListener('swipedown', function(){
+ $('#top').panel("open");
+ });
+ }
+ setTable();
+}
+function showSetting(showSett){
+ if (showSett){
+ $('#top').panel("close");
+ $('#ustawienia').show('slow');
+ $('#tablica').hide('slow');
+ }else{
+ $('#tablica').show('slow');
+ $('#ustawienia').hide('slow');
+ setTable();
+ }
+}
+
+function donate(){
+ try {
+ blackberry.payment.purchase({
+ "digitalGoodID": "35983897",
+ "digitalGoodSKU": "lifeClassic099",
+ "digitalGoodName": "donate",
+ "purchaseAppName": "LifeClassic"
+
+ }, onPurchaseSuccess, onPurchaseError);
+ } catch (e) {
+ showAlert("Purchase exception" + e);
+ }
+}
+function onPurchaseSuccess(purchasedItem) {
+ var transId = purchasedItem.transactionID;
+ var sku = purchasedItem.digitalGoodSKU;
+ var dgId = purchasedItem.digitalGoodID;
+ showAlert("Thank you for the donation!");
+}
+
+function onPurchaseError(error) {
+ //showAlert("Error occurred: " + error.errorText + ", " + error.errorID);
+}
Please sign in to comment.
Something went wrong with that request. Please try again.