Is there a function in Javascript / Jquery which will make hashtag from a string ? I'm looking for the answer for few minutes and i can't find it :/ Maybe there is some other way to make it ? I have Symfony 2.4 application.
I have my form data serialized to string, for example:
"cloud_adm_dictionary_type%5Bitems%5D%5B0%5D%5BdictName%5D=Otwartabbb&cloud_adm_dictionary_type%5Bitems%5D%5B0%5D%5BdictValue1%5D=fa-comments-o+text-muted&cloud_adm_dictionary_type%5Bitems%5D%5B0%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B1%5D%5BdictName%5D=Wycena&cloud_adm_dictionary_type%5Bitems%5D%5B1%5D%5BdictValue1%5D=fa-comments-o+text-muted&cloud_adm_dictionary_type%5Bitems%5D%5B1%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BdictName%5D=Negocjacje&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BdictValue1%5D=fa-comments-o+text-muted&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BisDefault%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B3%5D%5BdictName%5D=Wygrana&cloud_adm_dictionary_type%5Bitems%5D%5B3%5D%5BdictValue1%5D=fa-thumbs-o-up+text-primary&cloud_adm_dictionary_type%5Bitems%5D%5B3%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B4%5D%5BdictName%5D=Przegrana&cloud_adm_dictionary_type%5Bitems%5D%5B4%5D%5BdictValue1%5D=fa-thumbs-o-down+text-danger&cloud_adm_dictionary_type%5Bitems%5D%5B4%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5B_token%5D=3PBJr_pPjHhAIB95N7PUReP5asrXsGwCILAxZLyGTUg deal:738
cloud_adm_dictionary_type%5Bitems%5D%5B0%5D%5BdictName%5D=w%C5%82asnee&cloud_adm_dictionary_type%5Bitems%5D%5B0%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B1%5D%5BdictName%5D=proklienckii&cloud_adm_dictionary_type%5Bitems%5D%5B1%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BdictName%5D=telemarketing&cloud_adm_dictionary_type%5Bitems%5D%5B2%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B3%5D%5BdictName%5D=mailing&cloud_adm_dictionary_type%5Bitems%5D%5B3%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B4%5D%5BdictName%5D=www&cloud_adm_dictionary_type%5Bitems%5D%5B4%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B5%5D%5BdictName%5D=partner&cloud_adm_dictionary_type%5Bitems%5D%5B5%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B6%5D%5BdictName%5D=nowe+zrodlo&cloud_adm_dictionary_type%5Bitems%5D%5B6%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5Bitems%5D%5B7%5D%5BdictName%5D=Aaa&cloud_adm_dictionary_type%5Bitems%5D%5B7%5D%5BdictActive%5D=1&cloud_adm_dictionary_type%5B_token%5D=3PBJr_pPjHhAIB95N7PUReP5asrXsGwCILAxZLyGTUg"
And i want to make hashtag from that, something like i Don't know '462423dfdaak542634'. I need later to compare hashtags to see if the form was changed or not.
Here, you can use this simple hashing function:
function hashCode (str){
var hash = 0;
if (str.length == 0) return hash;
for (i = 0; i < str.length; i++) {
char = str.charCodeAt(i);
hash = ((hash<<5)-hash)+char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
See the DEMO here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With