Skip to content

Commit 78030bb

Browse files
committed
version 0.7.5 -- see changelog
1 parent d90efea commit 78030bb

File tree

5 files changed

+106
-103
lines changed

5 files changed

+106
-103
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
### IMPROVED ###
66
* ImgCache.getCachedFileURL: error callback is now optional (#79)
77
* Cache directory is no more backed up in iCloud (iOS) (#73)
8+
* Added ability to override the hash method through ImgCache.overridables.hash, SHA-1 currently being the default. It's possible to plug in a faster alternative but be careful of possible collisions (#81)
9+
* The log method used throughout ImgCache is now defined as an overridable option: ImgCache.overridables.log -- this replaces the previous 'customLogger' optional method (read Backward Compability Warning below)
10+
* Fixed some JSLint issues
11+
12+
### BC WARNING ###
13+
* ImgCache.options.customLogger has been changed to ImgCache.overridables.log
814

915
## 0.7.4 ##
1016

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ Options
175175
See ImgCache.options at the top of the source file for the list of options.
176176
Options can be overridden from your own script, no need to modify the library!
177177

178+
Overridable methods
179+
-------------------
180+
* The hash method used by default in ImgCache is SHA-1. It was chosen for its near absence of collision. Though it might slow things down if you have a large number of files to cache (see #81). You can plug-in your own method by overriding ImgCache.overridables.hash.
181+
* If logging is enabled, ImgCache output some log entries in the console by default. You can override ImgCache.overridables.log in order to change this behaviour.
182+
178183
Unit tests
179184
----------
180185
Open index.html and click 'Start unit tests' to launch unit tests.

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imgcache.js",
3-
"version": "0.7.4",
3+
"version": "0.7.5",
44
"homepage": "https://github.com/chrisben/imgcache.js",
55
"authors": [
66
{

index.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
var logger = function (str, level) {
1616
var levelClass = '';
17-
if (level == LOG_LEVEL_INFO) { levelClass = 'info' } ;
18-
if (level == LOG_LEVEL_WARNING) { levelClass = 'warn' };
19-
if (level == LOG_LEVEL_ERROR) { levelClass = 'error' };
17+
if (level == LOG_LEVEL_INFO) { levelClass = 'info' } ;
18+
if (level == LOG_LEVEL_WARNING) { levelClass = 'warn' };
19+
if (level == LOG_LEVEL_ERROR) { levelClass = 'error' };
2020
$('#log').append($('<li></li>').addClass(levelClass).text(str));
2121
};
2222

@@ -35,7 +35,7 @@
3535
var testedMethods = {};
3636

3737
ImgCache.options.debug = true;
38-
ImgCache.options.customLogger = logger;
38+
ImgCache.overridables.log = logger;
3939
ImgCache.options.cacheClearSize = 10;
4040
var default_options = ImgCache.options;
4141

@@ -108,7 +108,7 @@
108108
name: 'getCachedFile',
109109
test: function (ok, nok) {
110110
// expected result: failure
111-
ImgCache.getCachedFile($test_img.attr('src'), function (src, file_entry) { if (file_entry) { nok(); } else { ok(); } });
111+
ImgCache.getCachedFile($test_img.attr('src'), function (src, file_entry) { if (file_entry) { nok(); } else { ok(); } });
112112
}
113113
},
114114
{
@@ -128,7 +128,7 @@
128128
test: function (ok, nok) {
129129
var img_src = getBackgroundImageUrl($test_div);
130130
if (img_src) {
131-
ImgCache.isCached(img_src, function (src, res) { if (res) { ok(); } else { nok(); } });
131+
ImgCache.isCached(img_src, function (src, res) { if (res) { ok(); } else { nok(); } });
132132
} else {
133133
nok();
134134
}
@@ -147,7 +147,7 @@
147147
nok();
148148
}
149149
});
150-
} else {
150+
} else {
151151
nok();
152152
}
153153
}
@@ -314,7 +314,7 @@
314314

315315
var countTestedMethods = 0;
316316
for (var key in testedMethods) {
317-
if (testedMethods.hasOwnProperty(key)) { countTestedMethods++ };
317+
if (testedMethods.hasOwnProperty(key)) { countTestedMethods++ };
318318
}
319319

320320
var coverage = 'API coverage: ' + countTestedMethods + '/' + countTotalMethods;
@@ -323,7 +323,7 @@
323323
for (var i = 0; i < testableMethods.length; i++) {
324324
var method = testableMethods[i];
325325
if (!testedMethods.hasOwnProperty(method)) {
326-
if (untestedMethods.length > 0) {
326+
if (untestedMethods.length > 0) {
327327
untestedMethods += ' / ';
328328
}
329329
untestedMethods += method;

0 commit comments

Comments
 (0)