PageSourceSearch

https://wordtagcloud.com/static/scripts.js

js wordtagcloud.com collected 2026-10-02 01:00:04 UTC 34,302 bytes, 747 lines download raw bytes

1/*  Global variable section */
2
3
4const COUNT = 1000;
5 var regexes = {goog_delimters : /\s|\^|\n|\!|\@|\[|\]|\#|\$|\%|\&|\*|\?|\+|\=|\–|\_|\(|\)|\:|\;|\—|\,|\.|\]|\}|\{|”|\//};
6 
7var spinnerHTML = "<img id=\"spin\" src=\"https://abirqasem.github.io/pics_for_apps/spinner_clean.gif\"/>";
8var line="<hr style=\"width:75%;float:center; border: 1px solid gainsboro;border-color: #E8E8E8;\" />";
9var fdGlobal;
10var working_fd;
11
12var du_ger_dan_eng_fr=["af","alle","andet","andre","at","begge","da","de","den","denne","der","deres","det","dette","dig","din","dog","du","ej","eller","en","end","ene","eneste","enhver","et","fem",
13                         "fire","flere","fleste","for","fordi","forrige","fra","få","før","god","han","hans","har","hendes","her","hun","hvad","hvem","hver","hvilken","hvis","hvor","hvordan","hvorfor",
14                         "hvornår","i","ikke","ind","ingen","intet","jeg","jeres","kan","kom","kommer","lav","lidt","lille","man","mand","mange","med","meget","men","mens","mere","mig","ned","ni","nogen",
15                         "noget","ny","nyt","nær","næste","næsten","og","op","otte","over","på","se","seks","ses","som","stor","store","syv","ti","til","to","tre","ud","var","a","actualmente","acuerdo",
16                         "adelante","ademas","además","adrede","afirmó","agregó","ahi","ahora","ahí","al","algo","alguna","algunas","alguno","algunos","algún","alli","allí","alrededor","ambos","ampleamos",
17                         "antano","antaño","ante","anterior","antes","apenas","aproximadamente","aquel","aquella","aquellas","aquello","aquellos","aqui","aquél","aquélla","aquéllas","aquéllos","aquí",
18                         "arriba","arribaabajo","aseguró","asi","así","atras","aun","aunque","ayer","añadió","aún","b","bajo","bastante","bien","breve","buen","buena","buenas","bueno","buenos","c","cada",
19                         "casi","cerca","cierta","ciertas","cierto","ciertos","cinco","claro","comentó","como","con","conmigo","conocer","conseguimos","conseguir","considera","consideró","consigo","consigue",
20                         "consiguen","consigues","contigo","contra","cosas","creo","cual","cuales","cualquier","cuando","cuanta","cuantas","cuanto","cuantos","cuatro","cuenta","cuál","cuáles","cuándo","cuánta",
21                         "cuántas","cuánto","cuántos","cómo","d","da","dado","dan","dar","de","debajo","debe","deben","debido","decir","dejó","del","delante","demasiado","demás","dentro","deprisa","desde",
22                         "despacio","despues","después","detras","detrás","dia","dias","dice","dicen","dicho","dieron","diferente","diferentes","dijeron","dijo","dio","donde","dos","durante","día","días",
23                         "dónde","e","ejemplo","el","ella","ellas","ello","ellos","embargo","empleais","emplean","emplear","empleas","empleo","en","encima","encuentra","enfrente","enseguida","entonces",
24                         "entre","era","eramos","eran","eras","eres","es","esa","esas","ese","eso","esos","esta","estaba","estaban","estado","estados","estais","estamos","estan","estar","estará","estas",
25                         "este","esto","estos","estoy","estuvo","está","están","ex","excepto","existe","existen","explicó","expresó","f","fin","final","fue","fuera","fueron","fui","fuimos","g","general",
26                         "gran","grandes","gueno","h","ha","haber","habia","habla","hablan","habrá","había","habían","hace","haceis","hacemos","hacen","hacer","hacerlo","haces","hacia","haciendo","hago",
27                         "han","hasta","hay","haya","he","hecho","hemos","hicieron","hizo","horas","hoy","hubo","i","igual","incluso","indicó","informo","informó","intenta","intentais","intentamos",
28                         "intentan","intentar","intentas","intento","ir","j","junto","k","l","la","lado","largo","las","le","lejos","les","llegó","lleva","llevar","lo","los","luego","lugar","m","mal",
29                         "manera","manifestó","mas","mayor","me","mediante","medio","mejor","mencionó","menos","menudo","mi","mia","mias","mientras","mio","mios","mis","misma","mismas","mismo","mismos",
30                         "modo","momento","mucha","muchas","mucho","muchos","muy","más","mí","mía","mías","mío","míos","n","nada","nadie","ni","ninguna","ningunas","ninguno","ningunos","ningún","no",
31                         "nos","nosotras","nosotros","nuestra","nuestras","nuestro","nuestros","nueva","nuevas","nuevo","nuevos","nunca","o","ocho","os","otra","otras","otro","otros","p","pais","para",
32                         "parece","parte","partir","pasada","pasado","paìs","peor","pero","pesar","poca","pocas","poco","pocos","podeis","podemos","poder","podria","podriais","podriamos","podrian","podrias",
33                         "podrá","podrán","podría","podrían","poner","por","porque","posible","primer","primera","primero","primeros","principalmente","pronto","propia","propias","propio","propios",
34                         "proximo","próximo","próximos","pudo","pueda","puede","pueden","puedo","pues","q","qeu","que","quedó","queremos","quien","quienes","quiere","quiza","quizas","quizá","quizás","quién",
35                         "quiénes","qué","r","raras","realizado","realizar","realizó","repente","respecto","s","sabe","sabeis","sabemos","saben","saber","sabes","salvo","se","sea","sean","segun","segunda",
36                         "segundo","según","seis","ser","sera","será","serán","sería","señaló","si","sido","siempre","siendo","siete","sigue","siguiente","sin","sino","sobre","sois","sola","solamente",
37                         "solas","solo","solos","somos","son","soy","soyos","su","supuesto","sus","suya","suyas","suyo","sé","sí","sólo","t","tal","tambien","también","tampoco","tan","tanto","tarde","te",
38                         "temprano","tendrá","tendrán","teneis","tenemos","tener","tenga","tengo","tenido","tenía","tercera","ti","tiempo","tiene","tienen","toda","todas","todavia","todavía","todo","todos",
39                         "total","trabaja","trabajais","trabajamos","trabajan","trabajar","trabajas","trabajo","tras","trata","través","tres","tu","tus","tuvo","tuya","tuyas","tuyo","tuyos","tú","u","ultimo",
40                         "un","una","unas","uno","unos","usa","usais","usamos","usan","usar","usas","uso","usted","ustedes","v","va","vais","valor","vamos","van","varias","varios","vaya","veces","ver",
41                         "verdad","verdadera","verdadero","vez","vosotras","vosotros","voy","vuestra","vuestras","vuestro","vuestros","w","x","y","ya","yo","z","él","ésa","ésas","ése","ésos","ésta","éstas",
42                         "éste","éstos","última","últimas","último","últimos","Ernst","Ordnung","Schluss","a","ab","aber","ach","acht","achte","achten","achter","achtes","ag","alle","allein","allem","allen",
43                         "aller","allerdings","alles","allgemeinen","als","also","am","an","andere","anderen","andern","anders","au","auch","auf","aus","ausser","ausserdem","außer","außerdem","b","bald",
44                         "bei","beide","beiden","beim","beispiel","bekannt","bereits","besonders","besser","besten","bin","bis","bisher","bist","c","d","d.h","da","dabei","dadurch","dafür","dagegen","daher",
45                         "dahin","dahinter","damals","damit","danach","daneben","dank","dann","daran","darauf","daraus","darf","darfst","darin","darum","darunter","darüber","das","dasein","daselbst","dass",
46                         "dasselbe","davon","davor","dazu","dazwischen","daß","dein","deine","deinem","deiner","dem","dementsprechend","demgegenüber","demgemäss","demgemäß","demselben","demzufolge","den",
47                         "denen","denn","denselben","der","deren","derjenige","derjenigen","dermassen","dermaßen","derselbe","derselben","des","deshalb","desselben","dessen","deswegen","dich","die","diejenige",
48                         "diejenigen","dies","diese","dieselbe","dieselben","diesem","diesen","dieser","dieses","dir","doch","dort","drei","drin","dritte","dritten","dritter","drittes","du","durch","durchaus",
49                         "durfte","durften","dürfen","dürft","e","eben","ebenso","ehrlich","ei","ei,","eigen","eigene","eigenen","eigener","eigenes","ein","einander","eine","einem","einen","einer","eines","einige",
50                         "einigen","einiger","einiges","einmal","eins","elf","en","ende","endlich","entweder","er","erst","erste","ersten","erster","erstes","es","etwa","etwas","euch","euer","eure","f","folgende",
51                         "früher","fünf","fünfte","fünften","fünfter","fünftes","für","g","gab","ganz","ganze","ganzen","ganzer","ganzes","gar","gedurft","gegen","gegenüber","gehabt","gehen","geht","gek
51annt","gekonnt",
52                         "gemacht","gemocht","gemusst","genug","gerade","gern","gesagt","geschweige","gewesen","gewollt","geworden","gibt","ging","gleich","gott","gross","grosse","grossen","grosser","grosses","groß","große",
53                         "großen","großer","großes","gut","gute","guter","gutes","h","habe","haben","habt","hast","hat","hatte","hatten","hattest","hattet","heisst","her","heute","hier","hin","hinter","hoch","hätte","hätten",
54                         "i","ich","ihm","ihn","ihnen","ihr","ihre","ihrem","ihren","ihrer","ihres","im","immer","in","indem","infolgedessen","ins","irgend","ist","j","ja","jahr","jahre","jahren","je","jede","jedem","jeden",
55                         "jeder","jedermann","jedermanns","jedes","jedoch","jemand","jemandem","jemanden","jene","jenem","jenen","jener","jenes","jetzt","k","kam","kann","kannst","kaum","kein","keine","keinem","keinen","keiner",
56                         "kleine","kleinen","kleiner","kleines","kommen","kommt","konnte","konnten","kurz","können","könnt","könnte","l","lang","lange","leicht","leide","lieber","los","m","machen","macht","machte","mag","magst",
57                         "mahn","mal","man","manche","manchem","manchen","mancher","manches","mann","mehr","mein","meine","meinem","meinen","meiner","meines","mensch","menschen","mich","mir","mit","mittel","mochte","mochten","morgen",
58                         "muss","musst","musste","mussten","muß","mußt","möchte","mögen","möglich","mögt","müssen","müsst","müßt","n","na","nach","nachdem","nahm","natürlich","neben","nein","neue","neuen","neun","neunte","neunten",
59                         "neunter","neuntes","nicht","nichts","nie","niemand","niemandem","niemanden","noch","nun","nur","o","ob","oben","oder","offen","oft","ohne","p","q","r","recht","rechte","rechten","rechter","rechtes","richtig",
60                         "rund","s","sa","sache","sagt","sagte","sah","satt","schlecht","schon","sechs","sechste","sechsten","sechster","sechstes","sehr","sei","seid","seien","sein","seine","seinem","seinen","seiner","seines","seit",
61                         "seitdem","selbst","sich","sie","sieben","siebente","siebenten","siebenter","siebentes","sind","so","solang","solche","solchem","solchen","solcher","solches","soll","sollen","sollst","sollt","sollte","sollten",
62                         "sondern","sonst","soweit","sowie","später","startseite","statt","steht","suche","t","tag","tage","tagen","tat","teil","tel","tritt","trotzdem","tun","u","uhr","um","und","und?","uns","unser","unsere","unserer",
63                         "unter","v","vergangenen","viel","viele","vielem","vielen","vielleicht","vier","vierte","vierten","vierter","viertes","vom","von","vor","w","wahr?","wann","war","waren","wart","warum","was","wegen","weil","weit",
64                         "weiter","weitere","weiteren","weiteres","welche","welchem","welchen","welcher","welches","wem","wen","wenig","wenige","weniger","weniges","wenigstens","wenn","wer","werde","werden","werdet","weshalb","wessen",
65                         "wie","wieder","wieso","will","willst","wir","wird","wirklich","wirst","wissen","wo","wohl","wollen","wollt","wollte","wollten","worden","wurde","wurden","während","währenddem","währenddessen","wäre","würde",
66                         "würden","x","y","z","z.b","zehn","zehnte","zehnten","zehnter","zehntes","zeit","zu","zuerst","zugleich","zum","zunächst","zur","zurück","zusammen","zwanzig","zwar","zwei","zweite","zweiten","zweiter","zweites",
67                         "zwischen","zwölf","über","überhaupt","übrigens","af","alle","andet","andre","at"
68                         ,"begge","da","de","den","denne","der","deres","det","dette","dig","din","dog","du","ej","eller","en","end","ene","eneste","enhver","et","fem","fire","flere","fleste","for","fordi","forrige","fra","få","før","god","han",
69                         "hans","har","hendes","her","hun","hvad","hvem","hver","hvilken","hvis","hvor","hvordan","hvorfor","hvornår","i","ikke","ind","ingen","intet","jeg","jeres","kan","kom","kommer","lav","lidt","lille","man","mand","mange",
70                         "med","meget","men","mens","mere","mig","ned","ni","nogen","noget","ny","nyt","nær","næste","næsten","og","op","otte","over","på","se","seks","ses","som","stor","store","syv","ti","til","to","tre","ud","var","a","a's",
71                         "able","about","above","according","accordingly","across","actually","after","afterwards","again","against","ain't","all","allow","allows","almost","alone","along","already","also",                        "although",
72                         "always","am","among","amongst","an","and","another","any","anybody","anyhow","anyone","anything","anyway","anyways","anywhere","apart","a
72ppear","appreciate","appropriate","are","aren't","around","as","aside","ask",
73                         "asking","associated","at","available","away","awfully","b","be","became","because","become","becomes","becoming","been","before","beforehand","behind","being","believe","below","beside","besides","best","better","between",
74                         "beyond","both","brief","but","by","c","c'mon","c's","came","can","can't","cannot","cant","cause","causes","certain","certainly","changes","clearly","co","com","come","comes","concerning","consequently","consider","considering",
75                         "contain","containing","contains","corresponding","could","couldn't","course","currently","d","definitely","described","despite","did","didn't","different","do","does","doesn't","doing","don't","done","down","downwards","during",
76                         "e","each","edu","eg","eight","either","else","elsewhere","enough","entirely","especially","et","etc","even","ever","every","everybody","everyone","everything","everywhere","ex","exactly","example","except","f","far","few","fifth",
77                         "first","five","followed","following","follows","for","former","formerly","forth","four","from","further","furthermore","g","get","gets","getting","given","gives","go","goes","going","gone","got","gotten","greetings","h","had","hadn't",
78                         "happens","hardly","has","hasn't","have","haven't","having","he","he's","hello","help","hence","her","here","here's","hereafter","hereby","herein","hereupon","hers","herself","hi","him","himself","his","hither","hopefully","how","howbeit",
79                         "however","i","i'd","i'll","i'm","i've","ie","if","ignored","immediate","in","inasmuch","inc","indeed","indicate","indicated","indicates","inner","insofar","instead","into","inward","is","isn't","it","it'd","it'll","it's","its","itself","j",
80                         "just","k","keep","keeps","kept","know","known","knows","l","last","lately","later","latter","latterly","least","less","lest","let","let's","like","liked","likely","little","look","looking","looks","ltd","m","mainly","many","may","maybe","me",
81                         "mean","meanwhile","merely","might","more","moreover","most","mostly","much","must","my","myself","n","name","namely","nd","near","nearly","necessary","need","needs","neither","never","nevertheless","new","next","nine","no","nobody","non","none",
82                         "noone","nor","normally","not","nothing","novel","now","nowhere","o","obviously","of","off","often","oh","ok","okay","old","on","once","one","ones","only","onto","or","other","others","otherwise","ought","our","ours","ourselves","out","outside",
83                         "over","overall","own","p","particular","particularly","per","perhaps","placed","please","plus","possible","presumably","probably","provides","q","que","quite","qv","r","rather","rd","re","really","reasonably","regarding","regardless","regards",
84                         "relatively","respectively","right","s","said","same","saw","say","saying","says","second","secondly","see","seeing","seem","seemed","seeming","seems","seen","self","selves","sensible","sent","serious","seriously","seven","several","shall","she",
85                         "should","shouldn't","since","six","so","some","somebody","somehow","someone"
86                         ,"something","sometime","sometimes","somewhat","somewhere","soon","sorry","specified","specify","specifying","still","sub","such","sup","sure","t","t's","take","taken","tell","tends","th","than","thank","thanks","thanx","that","that's","thats","the",
87                         "their","theirs","them","themselves","then","thence","there","there's","thereafter","thereby","therefore","therein","theres","thereupon","these","they","they'd","they'll","they're","they've","think","third","this","thorough","thoroughly","those","though",
88                         "three","through","throughout","thru","thus","to","together","too","took","toward","towards","tried","tries","truly","try","trying","twice","two","u","un","under","unfortunately","unless","unlikely","until","unto","up","upon","us","use","used","useful",
89                         "uses","using","usually","uucp","v","value","various","very","via","viz","vs","w","want","wants","was","wasn't","way","we","we'd","we'll","
89we're","we've","welcome","well","went","were","weren't","what","what's","whatever","when","whence","whenever","where",
90                         "where's","whereafter","whereas","whereby","wherein","whereupon","wherever","whether","which","while","whither","who","who's","whoever","whole","whom","whose","why","will","willing","wish","with","within","without","won't","wonder","would","wouldn't","x","y",
91                         "yes","yet","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves","z","zero","a","abord","vous-mêmes","vu","vé","vôtre","vôtres","w","x","y","z","zut","à","â","ça","ès","étaient","étais","était","étant","été","être","ô","absolument",
92                         "afin","vont","vont","vos","votre",
93                         "vous","ah","ai","aie","ailleurs","ainsi","ait","allaient","allo","allons","allô","alors","anterieur","anterieure","anterieures","apres","après","as","assez","attendu","au","aucun"]
94
95 var t0=new Date().getTime();
96
97
98
99function spinAndStart()
100{
101    
102  $("#advanced").show()
103  $("#war1").html("");  
104
105   $('#star1').html("");
106  $("#cloud_area").hide();
107   $("#tagCloudBig").css("color", "black");
108  var spinnerHTML = "<img id=\"spin\" src=\"https://abirqasem.github.io/pics_for_apps/spinner_clean.gif\"/>";
109  document.getElementById("tagCloud").innerHTML="";
110  document.getElementById("tagCloudBig").innerHTML="Creating tag cloud....<br>"+spinnerHTML;
111  
112  var text= $("#mainInputTxt").val();
113  
114  
115    if (text.trim().split(" ").length !=1 || (text.indexOf ("http") < 0 && text.indexOf ("www.")<0 )) {
116    text = text.replace(/^[\r\n]+|\.|[\r\n]+$/g, ""); // leading and trailing cr
117    text = text.replace (/<div>|<\/div>/g,"");
118
119    fdGlobal = genFd(text);
120    showTC(getDefaultValues());
121
122 }
123 
124  
125 else if (text.indexOf(".pdf") >=0) {
126        
127    $.get("/extract_text_pdf?url="+text, function(data) {
128    fdGlobal = genFd(data);
129    showTC(getDefaultValues());
130     $("#main_buttons").removeClass("invisible");
131
132        })
133        
134    }
135    else if (text.indexOf("https://docs.google.com/")>=0) {
136        $.get("/extract_text_docs?url="+text, function(data) {
137        if(data!=="1z4w5h8829c2"){
138        fdGlobal = genFd(data);
139        showTC(getDefaultValues());
140        $("#main_buttons").removeClass("invisible");
141        }
142        else{
143            $("#tagCloudBig").html("Accessing the page or resource was not successful (Google Sheets not yet accessible).")   
144            $("#main_buttons").addClass("invisible");
145            $("#tagCloudBig").css("color", "red");
146            $("#advanced").hide();
147        }
148
149        })
150        
151        
152    }
153        
154        
155        
156    
157 
158else {
159
160   $.get("/extract_text?url="+text, function(data) {
161   
162     if(has_error(data)){
163        
164        $("#tagCloudBig").html("Accessing "+text+" was not successful (permission not granted)")   
165        $("#main_buttons").addClass("invisible");
166        $("#tagCloudBig").css("color", "red");
167        
168    }
169    else{     
170     fdGlobal = genFd(data);
171     showTC(getDefaultValues());
172      $("#main_buttons").removeClass("invisible");
173    }
174
175   })
176
177 }  
178    
179 
180function has_error(data){
181    var error;
182
183    if((+data &&( data.split("")[0]==="4" ||  data.split("")[0]==="5"))){
184    error=true
185
186        
187    }
188    else{
189    error=false
190    }
191    
192    return error;
193    
194}
195  
196   
197
198  
199  
200  // setting initial state of the advanced tab
201  
202 if(document.getElementById("advanced").childNodes.length!==0)
203 {
204  document.getElementById("words2remove").value="";       
205  document.getElementById("numWordTc").value="";
206 
207  document.getElementById("optradio2").checked=false;
208 }
209  
210  
211}
212
213
214
215
216
217function showTC(modifiers)
218{
219
220 
221  working_fd = {};
222  working_fd = fdGlobal;
223
224 
225  var numWords;
226  var filter=[];
227  var defaultNum=35;
228  
229  var color
230
231  /* Applying modifiers */ 
232  
233  filter = 'words2remove' in modifiers ? filter.concat(modifiers['words2remove']):filter;
234  filter =   ('allWords' in modifiers &&  !modifiers ['allWords']  ) ? filter.concat(filters()[0]):filter;
235
236//overflow = true;
237  working_fd=removeSelectedWords(filter,working_fd); 
238  
239//  color = ('color' in modifiers && modifiers['color'].length >0 ) ? modifiers['color']: "category 20b";
240  numWords = ('num' in modifiers && modifiers['num'] >0 ) ? modifiers['num']: COUNT;
241  color = ('color' in modifiers && modifiers['color'].length >0 ) ? modifiers['color']: "category20b";
242
243  if ('color' in modifiers && modifiers['color'] !== "schemeCategory20b") {ga('send', 'event', 'Default Color Palette change new', 'Select', 'Default Color Palette changed to: '+modifiers['color']);}
244
245  working_fd = working_fd.slice(0, numWords);
246  working_fd = 'long_word_length' in modifiers ? remove_long (working_fd,modifiers['long_word_length'] ):remove_long (working_fd,Number.MAX_SAFE_INTEGER );
247
248 
249 /* display the modified fd */ 
250 
251 
252  
253  if (Number(working_fd.length)===0){
254
255     $('#war1').css({ 'color': 'red', 'font-size': '100%' });
256        $("#war1").html("No words detected");   
257           $('#star1').html('*');
258        $("main_buttons").addClass("invisible")   ;
259  }
260  
261  else if (working_fd.length!==0 &&  working_fd.length<65){
262     $('#war1').css({ 'color': 'red', 'font-size': '100%' });
263        $("#war1").html("Fewer words affect cloud display");   
264           $('#star1').html('*');
265  }
266  else{
267      $("#war1").html("");   
268           $('#star1').html("");
269  
270  }
271  $(function() {
272     document.getElementById("result").innerHTML="";
273     document.getElementById("tagCloud").innerHTML="";
274    
275     var result=[]
276     
277    // 
278    
279
280    
281    
282
283     gen_d3(color);
284     gen_d3_download(color)
285    
286    });
287    
288    
289  $(typeAhead(working_fd));
290  
291
292  
293}
294
295
296/* Utilities */ 
297
298/* Value collectors from UI components */
299
300function getDefaultValues() {
301
302  return {num:COUNT,allWords:false, long_word_length:15,color:"schemeCategory20b"};
303
304}
305
306
307function collectValues () {
308        var words_to_remove= document.getElementById("words2remove").value.replace(/[.;,]/g,"").split(/\s/);
309        
310        var entry = Number(document.getElementById("numWordTc").value);
311        
312        var numWords = (isNaN(entry) || entry <0) ? -1 :entry;
313               
314        
315 
316        var all=document.getElementById("optradio2").checked;
317        
318         
319        var color = $('input[name=color_palettes]:checked').val() || "schemeCategory20b";
320        
321       
322        var req={words2remove:words_to_remove,num:numWords,allWords:all,color:color};
323
324
325        return req;
326        
327 
328}
329
330
331/* FD modifiers */
332
333
334function remove_long(data, max_len)
335{
336  var newData=[];
337  for (var i in data)
338  {
339   if (data[i]["text"].length<=max_len)
340   {
341     var newM={"text":data[i]["text"],"weight": data[i]["weight"]}
342     newData.push(newM);
343     
344     
345   }
346 
347  }
348 return newData;
349  
350}
351
352 function removeSelectedWords(ignore,allWords) //if allWords is in an array of maps like so [{text: "hello", weight: 15},{text: "some", weight: 10}]
353{
354  
355  var o = {}; // object prop checking > in array checking
356  var iCount = ignore.length;
357 
358  for (var i=0;i<iCount;i++){
359    o[ignore[i]] = true;
360  }
361  var allWordsCount = allWords.length; // count w/ duplicates
362  //Logger.log(allWordsCount);
363  var cleanWords = []; 
364  for (var i=0; i<allWordsCount; i++) {
365    var sWord = allWords[i]["text"];
366    if (!o[allWords[i]["text"]])
367    {
368      cleanWords.push({text: allWords[i]["text"],weight: allWords[i]["weight"]}); 
369      
370    }
371
372  }
373 
374 return cleanWords;
375
376}
377
378function filters()
379{
380    var arr=[];
381     arr.push(du_ger_dan_eng_fr);           
382     
383     
384     return arr;
385
386
387
388}
389
390
391/* Library type utilities, they can be useful to other application, ideally they should be libraries. We need our own client side JS library */ 
392
393
394
395
396function genFd(document)
397{
398 
399      
400      var words = (function()
401    {
402       
403       
404       document=document.replace(/[\W]/g," ");
405       document=document.replace(/[0-9]/g,""); // for now will drop words with any numbers
406        
407        
408        var sWords=document.toLowerCase().trim();
409        sWords = sWords.split(regexes["goog_delimters"]).sort(); 
410        var arr=[];
411        for (var i in sWords)
412        {
413          if (sWords[i].length>0)
414          {
415            arr.push(sWords[i])
416          }
417        
418        }
419
420        sWords=arr;
421        //sWords = sWords.split(/[\s\/]+/g).sort();
422        
423         
424        
425        var iWordsCount = sWords.length; // count w/ duplicates
426     
427        
428        var ignore =[];
429
430        var counts = {}; 
431        for (var i=0; i<iWordsCount; i++) {
432                var sWord = sWords[i];
433            
434                 
435                
436                counts[sWord] = counts[sWord] || 0;
437               
438                counts[sWord]++;
439
440        }
441    
442        var arr = []; // an array of objects to return
443        for (sWord in counts) {
444            arr.push({
445                text: sWord,
446                weight: counts[sWord]
447             
448    
449        });
450        
451        }
452        // sort array by descending frequency 
453        return arr.sort(function(a,b){
454            return (a.weight > b.weight) ? -1 : ((a.weight < b.weight) ? 1 : 0);
455        });
456    
457    }());
458
459    return words; 
460
461
462}
463
464
465function typeAhead(fdData) {
466
467    
468    var availableTags = [];
469    for (var i in fdData)
470    {
471      availableTags.push(fdData[i]["text"]);
472    
473    }
474    
475    
476    function split( val ) {
477      return val.split( /,\s*/ );
478    }
479    function extractLast( term ) {
480      return split( term ).pop();
481    }
482 
483    $( "#words2remove" )
484      // don't navigate away from the field on tab when selecting an item
485      .bind( "keydown", function( event ) {
486        if ( event.keyCode === $.ui.keyCode.TAB &&
487            $( this ).autocomplete( "instance" ).menu.active ) {
488          event.preventDefault();
489        }
490      })
491      .autocomplete({
492        minLength: 0,
493        source: function( request, response ) {
494          // delegate back to autocomplete, but extract the last term
495          response( $.ui.autocomplete.filter(
496            availableTags, extractLast( request.term ) ) );
497        },
498        focus: function() {
499          // prevent value inserted on focus
500          return false;
501        },
502        select: function( event, ui ) {
503          var terms = split( this.value );
504          // remove the current input
505          terms.pop();
506          // add the selected item
507          terms.push( ui.item.value );
508          // add placeholder to get the comma-and-space at the end
509          terms.push( "" );
510          this.value = terms.join( ", " );
511          return false;
512        }
513      });
514    
515  }
516  
517
518
519
520
521
522
523
524function get_colors(color_codes){
525   var colors;
526   
527   switch(color_codes) {
528    case "schemeCategory10":
529        colors=d3.scaleOrdinal(d3.schemeCategory10)
530        break;
531    case "schemeCategory20":
532         colors=d3.scaleOrdinal(d3.schemeCategory20)
533        break;
534     case "schemeCategory20b":
535         colors=d3.scaleOrdinal(d3.schemeCategory20b)
536        break;
537     case "schemeCategory20c":
538         colors=d3.scaleOrdinal(d3.schemeCategory20c)
539        break;    
540    default:
541        colors=d3.scaleOrdinal(d3.schemeCategory20b)
542}
543
544    return colors
545
546
547}
548
549function gen_d3_download(color_codes){
550
551    
552	/* D3  */
553     
554
555
556//	var width = 400;//change size to fit div
557//	var height = 620;
558	
559	var width = 500;//change size to fit div
560	var height = 620;
561
562   
563	var typeFace = 'Gorditas';
564	//var minFontSize = 15;
565	var minFontSize = 15;
566
567    
568    var colors = get_colors(color_codes)
569
570$("#tagCloudBig").html("");
571 var svg = d3.select("#tagCloudBig").append('svg')  //select new window or a di
572			.attr("id", "big_cloud")
573            .attr("viewBox", "0 0 500 620")            
574            .attr("preserveAspectRatio",  "xMaxYMax meet")
575            .attr('width', width)
576			.attr('height', height)
577			.append('g')
578			.attr('transform', 'translate('+width/2+', '+height/2+')');
579                    
580
581	function calculateCloud(word_set) {
582   		d3.layout.cloud()
583			.size([width, height])
584			.words(word_set)
585			.rotate(function() { return ~~(Math.random()*2) * 90;}) // 0 or 90deg
586			.font(typeFace)
587			.fontSize(function(d) { return d.size * minFontSize;  })//changed      
588			.on('end', drawCloud)
589			.start();            
590	}
591
592	function drawCloud(words) {
593        //losing words here
594		var vis = svg.selectAll('text').data(words);        
595		vis.enter().append('text')
596			.style('font-size', function(d) { return d.size + 'px'; })
597			.style('font-family', function(d) { return d.font; })
598			.style('fill', function(d, i) { return colors(i); })
599			.attr('text-anchor', 'middle')
600			.attr('transform', function(d) {
601			  return 'translate(' + [d.x, d.y] + ')rotate(' + d.rotate + ')';
602			})
603			.text(function(d) {  return d.text; }); 
604            
605       
606	}
607		
608      
609         var adjusted_fd=[]
610         adj_obj={}
611         for (var i=0;i<working_fd.length;i++){
612 
613          if (working_fd[0].weight > working_fd[working_fd.length - 1].weight) {
614          // Linearly map the original weight to a discrete scale from 1 to 10
615          weight = Math.round((working_fd[i].weight - working_fd[working_fd.length - 1].weight) /
616                              (working_fd[0].weight - working_fd[working_fd.length - 1].weight) * 9.0) + 1;
617          
618          adj_obj["text"]=working_fd[i]["text"]
619          adj_obj["weight"]=weight;
620          adjusted_fd.push(adj_obj)
621          adj_obj={};
622        }
623        
624     
625     }
626
627
628    var fd= make_fd_my_bitch(adjusted_fd,"text","weight","text","size");calculateCloud(fd)
629
630
631}
632
633
634  
635function gen_d3(color_codes){
636
637   var colors = get_colors(color_codes);
638	var width = 500;//change size to fit div
639	var height = 620;
640    
641   
642	var typeFace = 'Gorditas';
643	var minFontSize = 15;
644  
645$("#tagCloud").html("");
646
647 var svg = d3.select("#tagCloud").append('svg')  //select new window or a di
648			.attr("id", "small_cloud")
649            .attr('width', width)
650			.attr('height', height)
651			.append('g')
652			.attr('transform', 'translate('+width/2+', '+height/2+')');
653               
654
655	function calculateCloud(word_set) {
656	     d3.layout.cloud()
657			.size([width, height])
658			.words(word_set)
659			.rotate(function() { return ~~(Math.random()*2) * 90;}) // 0 or 90deg
660			.font(typeFace)
661			.fontSize(function(d) { return d.size * minFontSize;  })//changed      
662			.on('end', drawCloud)
663			.start();            
664	}
665
666	function drawCloud(words) {
667        //losing words here
668		var vis = svg.selectAll('text').data(words);        
669		vis.enter().append('text')
670			.style('font-size', function(d) { return d.size + 'px'; })
671			.style('font-family', function(d) { return d.font; })
672			.style('fill', function(d, i) { return colors(i); })
673           // .style('fill', function(d, i) { return colores_g[i]; })
674			.attr('text-anchor', 'middle')
675			.attr('transform', function(d) {
676			  return 'translate(' + [d.x, d.y] + ')rotate(' + d.rotate + ')';
677			})
678			.text(function(d) {  return d.text; }); 
679            
680       
681	}
682		
683
684  
685         var adjusted_fd=[]
686         adj_obj={}
687         for (var i=0;i<working_fd.length;i++){
688 
689          if (working_fd[0].weight > working_fd[working_fd.length - 1].weight) {
690          // Linearly map the original weight to a discrete scale from 1 to 10
691          weight = Math.round((working_fd[i].weight - working_fd[working_fd.length - 1].weight) /
692                              (working_fd[0].weight - working_fd[working_fd.length - 1].weight) * 9.0) + 1;
693          
694    
695          adj_obj["text"]=working_fd[i]["text"]
696          adj_obj["weight"]=weight;
697          adjusted_fd.push(adj_obj)
698          adj_obj={};
699          $("#main_buttons").removeClass("invisible");
700          $('#advanced').show()
701           $("#btn_area").show()
702          
703        }
704        else{
705         $("#tagCloud").html("");
706         // $("main_buttons").addClass("invisible") 
707
708         $("#btn_area").hide()
709         $("#advanced").html("")
710        // $('#main_buttons').addClass('invisible')
711        }
712        
713     
714     }
715    
716
717
718    var fd= make_fd_my_bitch(adjusted_fd,"text","weight","text","size");
719    calculateCloud(fd)
720
721$('#main_buttons').show()
722
723
724
725}
726
727
728
729
730function make_fd_my_bitch(source_fd,old_label1,old_label2,new_label1,new_label2){
731 var bitch_fd=[]
732 var temp={};
733
734 
735 for (var i=0; i<source_fd.length; i++){
736   temp[new_label1]=source_fd[i][old_label1];
737   temp[new_label2]=source_fd[i][old_label2]
738   bitch_fd.push(temp);
739   temp={}
740   
741 
742 }
743
744return bitch_fd;
745
746}
747

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.