srexi / purecounterjs

A simple yet configurable native javascript counter which you can count on.
MIT License
125 stars 47 forks source link

Allow user customize #14, Add feature repeat #21 and file size counter #23 #26

Closed rzlnhd closed 2 years ago

rzlnhd commented 2 years ago

Hi sir. Recently I saw some issue and edit the code. Here is my work.

  1. Allow user to set the configuration by changing to constructor Function. Fix issue #14 So, this will make PureCounter needs to initialize manualy using keyword new PureCounter() (Just like making new Object/Class). The PureCounter class accept configuration as an Object for the parameter.
  2. Add feature to repeat counting for certain time. Fix issue #21 Insert the delay time (as seconds) for recount as using data-purecounter-repeat or repeat. The repeat configuration just accept boolean:false or number.
  3. Add feature to count as filesize. Fix issue #23 I also modify the convertToCurrencySystem method to add this feature, because it's same method. Check convertNumber function for more details. Set filesizing or data-purecounter-filesizing to true to activate this config.
  4. Simplify configuration. Well. I think it's too much configuration. So, I simplify some config. Here the details:
    • separator and separatorsymbol now changes to just separator that can accept boolean|char|string. If the value is char|string, that config will automaticaly active and use that value as symbol. If the value is 'true', use comma , by default.
    • currency and currencysymbol now changes to just currency that can accept boolean|char|string. If the value is char|string, that config will automatically active and use that value as currency symbol.
    • repeat config can accept boolean (only false) or number as seconds.
  5. I've no idea to fix this issue #24 . I just edit the webpack config to export this as umd type Library. I didn't test the result yet.

I've check the vanilla and non-vanilla build and all works pretty good. Well, by add some feature it also increasing the size. But the size for vanilla build is still bellow 5kb.

By the way, sorry for my bad English.😅 Hope you like it.

rzlnhd commented 2 years ago

Here is the Testing Page.

srexi commented 2 years ago

@rzlnhd What an amazing job! I will inspect the code tomorrow and make sure everything is up to par. I really appreciate the effort put in mate! :)

rzlnhd commented 2 years ago

Sure... But, I think i forget to add the repeat test on the Test page...