@@ -146,9 +146,14 @@ function google_link(name) {
146
146
' target="_blank">' + name + '</a>' ;
147
147
}
148
148
149
+ function set_prefix ( prefix ) {
150
+ $ ( '#id_left' ) . val ( prefix ) . focus ( ) ;
151
+ return false ;
152
+ }
153
+
149
154
function group_row ( prefix , keys ) {
150
155
var html = '<a class="quiet" href="#"' ;
151
- html += 'onclick="$ (\'#id_left\').val(\'' + prefix + '\'); return false ;"' ;
156
+ html += 'onclick="return set_prefix (\'' + prefix + '\');"' ;
152
157
html += '>' + prefix + ' ' ;
153
158
html += '<img src="/static/images/right9.png" alt=">"' ;
154
159
html += ' width="9" height="9">' ;
@@ -215,6 +220,9 @@ function split_group(groups, old_prefix) {
215
220
groups [ best_prefix ] . unshift ( key ) ;
216
221
}
217
222
}
223
+ if ( groups [ old_prefix ] . length == 0 ) {
224
+ delete groups [ old_prefix ] ;
225
+ }
218
226
}
219
227
220
228
function make_groups ( groups , max_count ) {
@@ -229,36 +237,36 @@ function make_groups(groups, max_count) {
229
237
}
230
238
}
231
239
// If the largest group is small enough, we're done.
232
- if ( best_count <= 8 ) break ;
240
+ if ( best_count <= 6 ) break ;
233
241
// Split the largest group into two groups.
234
242
split_group ( groups , best_prefix ) ;
235
243
}
236
244
}
237
245
238
246
function update_html ( ) {
247
+ $ . keys = [ ] ;
248
+ for ( var key in $ . domains ) $ . keys . push ( key ) ;
249
+ if ( $ . keys . length == 0 ) return show_hide ( ) ;
250
+ $ . keys . sort ( function ( a , b ) {
251
+ return $ . domains [ b ] . score - $ . domains [ a ] . score } ) ;
252
+ var top10_index = Math . min ( $ . keys . length - 1 , 10 ) ;
253
+ $ . ajax_search . top10 = $ . domains [ $ . keys [ top10_index ] ] . score ;
254
+ var groups = { } ;
255
+ groups [ $ . ajax_search . left ] = $ . keys ;
256
+ make_groups ( groups , 25 ) ;
257
+ var html = p_html ( groups ) ;
258
+ $ ( "#results_p" ) . html ( html ) ;
259
+ show_hide ( ) ;
260
+ }
261
+
262
+ function show_hide ( ) {
239
263
if ( $ . ajax_search . left + $ . ajax_search . right == '' ) {
240
264
$ ( "div#results_div" ) . hide ( ) ;
241
265
$ ( "div#results_loading" ) . hide ( ) ;
242
266
$ ( "div#results_empty" ) . hide ( ) ;
243
- $ ( "div#feedback" ) . hide ( ) ;
244
267
$ ( "div#welcome" ) . show ( ) ;
245
- return ;
246
- }
247
- var keys = [ ] ;
248
- for ( var key in $ . domains ) keys . push ( key ) ;
249
- keys . sort ( function ( a , b ) {
250
- return $ . domains [ b ] . score - $ . domains [ a ] . score } ) ;
251
- var results_count = keys . length ;
252
- if ( results_count ) {
253
- var top10_index = Math . min ( results_count - 1 , 10 ) ;
254
- $ . ajax_search . top10 = $ . domains [ keys [ top10_index ] ] . score ;
255
- }
256
- var groups = { } ;
257
- groups [ $ . ajax_search . left ] = keys ;
258
- make_groups ( groups , 25 ) ;
259
- var html = p_html ( groups ) ;
260
- $ ( "div#welcome" ) . hide ( ) ;
261
- if ( results_count == 0 ) {
268
+ } else if ( $ . keys . length == 0 ) {
269
+ $ ( "div#welcome" ) . hide ( ) ;
262
270
$ ( "div#results_div" ) . hide ( ) ;
263
271
if ( $ . ajax_search . start ) {
264
272
$ ( "#results_empty" ) . hide ( ) ;
@@ -268,16 +276,33 @@ function update_html() {
268
276
$ ( "#results_empty" ) . show ( ) ;
269
277
}
270
278
} else {
279
+ $ ( "div#welcome" ) . hide ( ) ;
271
280
$ ( "#results_empty" ) . hide ( ) ;
272
281
$ ( "#results_loading" ) . hide ( ) ;
273
- $ ( "#results_p" ) . html ( html ) ;
274
282
$ ( "#results_div" ) . show ( ) ;
275
- $ ( "div#feedback" ) . show ( ) ;
276
- if ( results_count <= DEFAULT_LIMIT / 2 && ! $ . ajax_search . start )
283
+ if ( $ . keys . length <= DEFAULT_LIMIT / 2 && ! $ . ajax_search . start )
277
284
$ ( "#results_few" ) . show ( ) ;
278
285
else
279
286
$ ( "#results_few" ) . hide ( ) ;
280
287
}
288
+ if ( $ . mode == 'basic' ) {
289
+ if ( $ . ajax_search . left || $ . ajax_search . right )
290
+ $ ( "div#feedback" ) . show ( ) ;
291
+ else
292
+ $ ( "div#feedback" ) . hide ( ) ;
293
+ $ ( "div#weights" ) . hide ( ) ;
294
+ $ ( "div#priority" ) . show ( ) ;
295
+ $ ( "div.three" ) . css ( "top" , 438 ) ;
296
+ $ ( "div.four" ) . css ( "top" , 510 ) ;
297
+ $ ( "div#left" ) . css ( "height" , 591 ) ;
298
+ } else {
299
+ $ ( "div#feedback" ) . hide ( ) ;
300
+ $ ( "div#priority" ) . hide ( ) ;
301
+ $ ( "div#weights" ) . show ( ) ;
302
+ $ ( "div.three" ) . css ( "top" , 606 ) ;
303
+ $ ( "div.four" ) . css ( "top" , 678 ) ;
304
+ $ ( "div#left" ) . css ( "height" , 663 ) ;
305
+ }
281
306
}
282
307
283
308
function array_unchanged ( a , b ) {
@@ -436,23 +461,19 @@ function update_if_changed(i) {
436
461
}
437
462
438
463
function show_weights ( ) {
439
- $ ( "div#priority" ) . hide ( ) ;
440
- $ ( "div#weights" ) . show ( ) ;
441
- $ ( "div.three" ) . css ( "top" , 606 ) ;
442
- $ ( "div.four" ) . css ( "top" , 678 ) ;
443
- $ ( "div#left" ) . css ( "height" , 759 ) ;
464
+ $ . mode = 'advanced' ;
465
+ show_hide ( ) ;
444
466
}
445
467
446
468
function show_priority ( ) {
447
- $ ( "div#weights" ) . hide ( ) ;
448
- $ ( "div#priority" ) . show ( ) ;
449
- $ ( "div.three" ) . css ( "top" , 438 ) ;
450
- $ ( "div.four" ) . css ( "top" , 510 ) ;
451
- $ ( "div#left" ) . css ( "height" , 591 ) ;
469
+ $ . mode = 'basic' ;
470
+ show_hide ( ) ;
452
471
}
453
472
454
473
function document_ready ( ) {
455
474
$ . domains = { } ;
475
+ $ . keys = [ ] ;
476
+ $ . mode = 'basic' ;
456
477
$ . weights = form_weights ( ) ;
457
478
$ . ajax_search = { } ;
458
479
$ . ajax_search . xhr = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ;
0 commit comments