Created
November 1, 2011 20:27
-
-
Save clauswitt/1331802 to your computer and use it in GitHub Desktop.
Unique Filename generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define('utils/files/nameGenerator', function() { | |
| var count = 0; | |
| var lastId = 0; | |
| this.getName = function(ext) { | |
| var d = new Date; | |
| var f = d.getTime(); | |
| if(f == lastId) { | |
| count++; | |
| } else { | |
| count = 0; | |
| } | |
| lastId = f; | |
| if(count>0) { | |
| f += '_'+count; | |
| } | |
| if(typeof ext != 'undefined') { | |
| f += '.'+ext; | |
| } | |
| return f; | |
| }; | |
| return this; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment