Skip to content

Commit 6610810

Browse files
author
Andris Reinman
committed
replaced param order for listeners
1 parent ee1eb0b commit 6610810

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

jstorage.js

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
1-
(function(){
1+
/*
2+
* ----------------------------- JSTORAGE -------------------------------------
3+
* Simple local storage wrapper to save data on the browser side, supporting
4+
* all major browsers - IE6+, Firefox2+, Safari4+, Chrome4+ and Opera 10.5+
5+
*
6+
* Copyright (c) 2010 Andris Reinman, andris.reinman@gmail.com
7+
* Project homepage: www.jstorage.info
8+
*
9+
* Licensed under MIT-style license:
10+
*
11+
* Permission is hereby granted, free of charge, to any person obtaining a copy
12+
* of this software and associated documentation files (the "Software"), to deal
13+
* in the Software without restriction, including without limitation the rights
14+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15+
* copies of the Software, and to permit persons to whom the Software is
16+
* furnished to do so, subject to the following conditions:
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
27+
(function(){
228
var
329
/* jStorage version */
430
JSTORAGE_VERSION = "0.2.0",
@@ -338,7 +364,7 @@
338364
for(var i=0, len = keys.length; i<len; i++){
339365
if(_observers[keys[i]]){
340366
for(var j=0, jlen = _observers[keys[i]].length; j<jlen; j++){
341-
_observers[keys[i]][j](action, keys[i]);
367+
_observers[keys[i]][j](keys[i], action);
342368
}
343369
}
344370
}

jstorage.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,18 @@
8080
(function(i){
8181
del.observe("click", function(){
8282
$.jStorage.deleteKey(i);
83-
this.reDraw();
83+
JSOTRAGE_TEST.reDraw();
8484
});
8585
}).call(this,indx[i])
8686
row.insert(new Element("td").insert(del));
8787
$("tulemused").insert(row);
8888
}
8989
}
9090
}
91+
92+
$.jStorage.listenKeyChange("testkey", function(key, action){
93+
alert(key + " has been " + action);
94+
});
9195
</script>
9296
</head>
9397
<body>
@@ -135,6 +139,8 @@ <h1>jStorage - store data locally with JavaScript</h1>
135139
</tfoot>
136140
</table>
137141

142+
<p><b>NB!</b> using key name "testkey" should fire an alertbox in every opened window on the same domain</p>
143+
138144
<p>&copy; 2010 Andris Reinman, <a href="mailto:andris.reinman@gmail.com">andris.reinman@gmail.com</a><br /><a href="http://www.jstorage.info">jStorage</a> is licensed under <a href="http://www.jstorage.info/static/license.txt">MIT-styled license</a>, so basically you can do whatever you want to do with it.</p>
139145

140146
<script>

0 commit comments

Comments
 (0)