jscalc 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c92977cab56be7f09072339c350aec97e6f12fd5
4
- data.tar.gz: 55f5e050978e27239aac5292c882881435133f49
3
+ metadata.gz: 843f30f4ddd3d5b10ea78ba3a3b07f1471fa7e31
4
+ data.tar.gz: 7ba909b01d93d59d08b5630c2c503db6597bf9b6
5
5
  SHA512:
6
- metadata.gz: afa8789ec1a3be419ac44deacaff67b81235b2936a9115da0cf8545b318f862bb733988a90ae9926341f4cf3604de07563038f8530aaddb36f215f4af3cb6f3c
7
- data.tar.gz: f19827dd232baeaefe4c5265eae7d83702fc4d3289f72dcdd3c046d8cf20708a8d96e4c06cda561463d6c7bb0fa7571dda3229ac3b36d5eb0b2ea92964b8e094
6
+ metadata.gz: 88bd31ef8becd20308dbb329dc02c39c714b6e11139330da17bfb6210c03965444af5f1d91738634e08b6bc3be98507284c0ae6b132701046928ea75d27daa11
7
+ data.tar.gz: ab2f3fdecf6f05beb3b1e78e4692d5727967bd37f2ef895b650205825b386b1f09acea6a552e38246a8838db946355bcc4dc8b32353a452825838c3d921564e8
data/lib/jscalc.rb ADDED
@@ -0,0 +1 @@
1
+ require 'jscalc/engine'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscalc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - tomgdow
@@ -16,11 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - app/assets/javascripts/myCalculator_v3.js
20
- - app/assets/javascripts/jscalc/index.js
21
- - app/assets/stylesheets/myCalculator_v3.css
22
- - app/assets/stylesheets/jscalc/index.css
23
- - lib/jscalc/engine.rb
19
+ - lib/jscalc.rb
24
20
  homepage: http://rubygems.org/gems/jscalc
25
21
  licenses:
26
22
  - MIT
File without changes
@@ -1,183 +0,0 @@
1
- var pane = document.getElementById('calcPanel');
2
-
3
- $(dragDiv);
4
-
5
- //Functions
6
- function dragDiv() {
7
- $('#myCalculator').draggable();
8
- }
9
-
10
- function btn_plus_fn () {
11
-
12
- if(pane.value.slice(-1) !="+" && pane.value.slice(-1) !="-" && pane.value.slice(-1) !="*" && pane.value.slice(-1) !="/" && pane.value.slice(-1) !="%")
13
- {
14
- pane.value += '+';
15
-
16
- }
17
- } //Buttons (0-9)
18
-
19
- function btn_subtract_fn () {
20
-
21
- if(pane.value.slice(-1) !="+" && pane.value.slice(-1) !="-" && pane.value.slice(-1) !="*" && pane.value.slice(-1) !="/" && pane.value.slice(-1) !="%")
22
- {
23
- pane.value += '-';
24
-
25
- }
26
- }
27
-
28
- function btn_multiply_fn () {
29
-
30
- if(pane.value.slice(-1) !="+" && pane.value.slice(-1) !="-" && pane.value.slice(-1) !="*" && pane.value.slice(-1) !="/" && pane.value.slice(-1) !="%")
31
- {
32
- pane.value += '*';
33
-
34
- }
35
- }
36
-
37
- function btn_divide_fn () {
38
-
39
- if(pane.value.slice(-1) !="+" && pane.value.slice(-1) !="-" && pane.value.slice(-1) !="*" && pane.value.slice(-1) !="/" && pane.value.slice(-1) !="%")
40
- {
41
- pane.value += '/';
42
-
43
- }
44
- }
45
-
46
- function btn_modulus_fn () {
47
-
48
- if(pane.value.slice(-1) !="+" && pane.value.slice(-1) !="-" && pane.value.slice(-1) !="*" && pane.value.slice(-1) !="/" && pane.value.slice(-1) !="%")
49
- {
50
- pane.value += '%';
51
-
52
- }
53
- }
54
-
55
- function btn_decimal_fn () {
56
-
57
- //if(pane.value.charAt(pane.value.length - 1) !=".")
58
- if(pane.value.slice(- 1) !=".")
59
- {
60
- pane.value += '.';
61
-
62
- }
63
- }
64
-
65
- function btn_cancelError_fn () {
66
-
67
- pane.value = pane.value.substring(0, pane.value.length - 1);
68
-
69
- }
70
-
71
- var evalAlt = function (fn) {
72
- return new Function('return ' + fn)();
73
- };//An Alternative to eval
74
-
75
- function btn_equals_fn () {
76
-
77
- pane.value = evalAlt(pane.value);
78
- } // Evaluate the String
79
-
80
- function btn_cancel_fn () {
81
-
82
- pane.value = "";
83
- }
84
-
85
- function elementGenerate(myId, myClass,myContent, myElement) {
86
- var myElement = document.createElement(myElement);
87
- myElement.setAttribute("id", myId);
88
- myElement.setAttribute("class", myClass);
89
- //childNodes[0].nodeValue
90
- myElement.innerHTML = myContent;
91
- return myElement;
92
- }
93
-
94
- //Generate Button Elements and Add to DOM
95
-
96
- //Row One
97
- for(i=1; i<=3; i++) {
98
-
99
- document.getElementById('calcRowOne').appendChild(elementGenerate(i,'mybtn', i, "button"))
100
- };// (0-3)
101
-
102
- document.getElementById('calcRowOne').appendChild(elementGenerate('btnMultiply','mybtn', '&times;', "button"));//multiply
103
-
104
- //Row Two
105
- for(i=4; i<=6; i++) {
106
-
107
- document.getElementById('calcRowTwo').appendChild(elementGenerate(i,'mybtn', i, "button"))
108
- };//(4-6)
109
-
110
- document.getElementById('calcRowTwo').appendChild(elementGenerate('btnDivide','mybtn', '&#247;', "button"));//Divide
111
-
112
- //Row Three
113
- for(i=7; i<=9; i++) {
114
-
115
- document.getElementById('calcRowThree').appendChild(elementGenerate(i,'mybtn', i, "button"))
116
- };//(7-9)
117
-
118
- document.getElementById('calcRowThree').appendChild(elementGenerate('btnSubtract','mybtn', '&#8211;', "button"));//Subtract
119
-
120
- //Row Four
121
- document.getElementById('calcRowFour').appendChild(elementGenerate('0','mybtn', '0', "button"));//
122
- document.getElementById('calcRowFour').appendChild(elementGenerate('btnDecPoint','mybtn', '&period;', "button"));
123
- document.getElementById('calcRowFour').appendChild(elementGenerate('btnPlus','mybtnAlt', '+', "button"));
124
-
125
- //Row Five
126
- document.getElementById('calcRowFive').appendChild(elementGenerate('(','mybtn', '(', "button"));//
127
- document.getElementById('calcRowFive').appendChild(elementGenerate(')','mybtn', ')', "button"));
128
- document.getElementById('calcRowFive').appendChild(elementGenerate('btnModulus','mybtn', 'mod', "button"));
129
- document.getElementById('calcRowFive').appendChild(elementGenerate('btnCancelError','mybtn', 'Ce', "button"));
130
-
131
- //Row Six
132
- document.getElementById('calcRowSix').appendChild(elementGenerate('btnCancel','mybtnAlt', 'C', "button"));
133
- document.getElementById('calcRowSix').appendChild(elementGenerate('btnEquals','mybtnAlt', '=', "button"));
134
-
135
-
136
- //EventHandlers and EventListeners
137
- for(i=0; i<=9; i++) {
138
-
139
- document.getElementById(i).addEventListener("click", function () {pane.value += this.id}, false)
140
-
141
- }//Buttons (0-9)
142
-
143
- document.getElementById('(').addEventListener("click", function () { pane.value += this.id}, false);
144
- document.getElementById(')').addEventListener("click", function () { pane.value += this.id}, false);
145
-
146
- document.getElementById('btnPlus').onclick = function () { btn_plus_fn()};
147
- document.getElementById('btnMultiply').onclick = function () { btn_multiply_fn()};
148
- document.getElementById('btnDivide').onclick = function () { btn_divide_fn()};
149
- document.getElementById('btnSubtract').onclick = function () { btn_subtract_fn()};
150
- document.getElementById('btnEquals').onclick = function () { btn_equals_fn()};
151
- document.getElementById('btnDecPoint').onclick = function () { btn_decimal_fn()};
152
-
153
-
154
- document.getElementById('btnCancel').addEventListener("click", function () {btn_cancel_fn()}, false);
155
- document.getElementById('btnCancelError').addEventListener("click", function () {btn_cancelError_fn()}, false);
156
- document.getElementById('btnModulus').addEventListener("click", function () {btn_modulus_fn()}, false);
157
-
158
-
159
- //Lucjen
160
-
161
- document.addEventListener('keypress',function (e) {
162
- if (13 == e.keyCode) {
163
- btn_equals_fn()
164
- }
165
- });
166
-
167
- //Keep These
168
-
169
- /*function btn_equals_fn () {
170
-
171
- document.getElementById('calcPanel').value = eval(pane.value.replace(/[^-()\d+.]/g, ''));
172
- }*/
173
-
174
- /*function btn_equals_fn () {
175
-
176
- document.getElementById('calcPanel').value = evalAlt(pane.value);
177
- }*/
178
-
179
- /*function btn_equals_fn () {
180
-
181
- document.getElementById('calcPanel').value = evalAlt(pane.value.replace(/[^-()\d/*+.]/g, ''));
182
- }*/
183
-
File without changes
@@ -1,42 +0,0 @@
1
- h1 {
2
- font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
3
- font-style: italic;
4
- font-weight: bold;
5
- margin-left: 10px;
6
- }
7
-
8
- h2 {
9
- font-family: verdana, arial, helvetica, sans-serif;
10
- margin-left: 50px;
11
- font-weight: bold;
12
- }
13
-
14
- .mybtn {
15
- font-size: 20px;
16
- height: 55px;
17
- width: 55px;
18
- margin: 1px;
19
- }
20
- .mybtnAlt {
21
- font-size: 20px;
22
- height: 55px;
23
- width: 115px;
24
- }
25
- #calcPanel {
26
- font-size: 20px;
27
- margin-top: 10px;
28
- margin-bottom: 5px;
29
- margin-left: 10px;
30
- height: 50px;
31
- width: 230px;
32
- }
33
- #myCalculator {
34
- margin-top: 30px;
35
- margin-left: 100px;
36
- width: 26%;
37
- background-color: #9CD2EA;
38
- }
39
- #buttonsWrapper {
40
- padding-left: 15px;
41
- padding-bottom: 15px;
42
- }
data/lib/jscalc/engine.rb DELETED
@@ -1,4 +0,0 @@
1
- module Jscalc
2
- class Engine < ::Rails::Engine
3
- end
4
- end