sms-counter
sms-counter copied to clipboard
Change limit
I was wondering if it might be possible to add an option to add a character prefix limit, say I always want to append 15 characters before each message so it accounts for that in the totaling.
I assume you are using the jQuery plugin. Take a look at how the jQuery plugin is implemented:
CoffeeScript: https://github.com/danxexe/sms-counter/blob/master/sms_counter.js.coffee#L56-L65 JavaScript: https://github.com/danxexe/sms-counter/blob/master/sms_counter.js#L93-L109
If I understand it correctly, implementing what you want would be as simple as getting the result of SmsCounter.count(text).length and adding the length of your prefix before displaying it. You could do it by using your own keyup callback.
One way of implementing it in a generic way would be by making $.countSms receive an optional callback where you could change any of the values before displaying them.