Question

I'm using jquery DynaCloud with wordCount to create a dynamic tagcloud. I have specific terms to include in the cloud (though the frequency is different for each user), and some of the terms are multiple word, or have special characters ("&", "'", " ", etc.) as part of the term.

I break the terms with specific html blocks:

<pre><span class="tag">this isn't the last tag</span></pre>

as an example.

The way wordCount works (as far as I can tell) is to accept only specific characters and to split on the spaces between words.

I've been trying to edit the script to allow all characters (including special), and only break on the <span class=tag>.

However, it doesn't seem that any changes I make have any effect.

Any idea how to alter this code to get everything between the tags and break on the tag?

//accept Latin-1 basic + Latin-1 extended characters
testChar: function(c) {
    return((c >=   0 && c <= 500)
        || (c >= 128 && c <= 151)
        || (c >= 160 && c <= 164)
        || (c >=  48 && c <=  57)
        || (c >= 224 && c <= 246)
        || (c >= 249 && c <= 255));
},

//split words
splitWords: function(words) {
    var w = new Array(), str = '';
    for(var i = 0, j = words.length; i < j; i++) {
        c = words.charCodeAt(i);
        if(this.testChar(c)) str += words.substring(i, i + 1);
        else {
            w.push(str);
            str = '';
        }
    }
}
Was it helpful?

Solution

I got this eventually. I had been trying to use encoded characters similar to what the original author of the script used (so c>=0 && c<=500). but I was over thinking the problem.

this can all be done with just plain chacters, so edited it to say

<pre>
    testChar: function(c) {
        return((c >= 97 && c <= 122)
            || (c >= 128 && c <= 151)
            || (c >= 160 && c <= 164)
            || (c >= 48 && c <= 57)
            || (c >= 224 && c <= 246)
            || (c >= 249 && c <= 255)
            || (c = "'" || " " || "&"));
    },

</pre>

and now all the characters I need show up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top