-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
960 lines (858 loc) · 19.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
<!doctype html>
<html lang="us">
<head>
<meta charset="utf-8">
<title>Simulateur d'attribution de sièges aux élections proportionnelles utilisant la méthode de Hondt</title>
<link href="css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery-ui-1.10.4.custom.js"></script>
<script>
// features ideas:
// - importer des versions plus légères de jquery et jqueryui
// - afficher le tableau de divisions
// - ajouter des presets
// - trigger recalculs après change du slider moins souvent (parce que là ça rame)
// - corriger/réduire l'erreur d'arrondi pour maintenir le nombre de votes total fixe quelle que soit la situation (=> attibuer des votes à des listes 1 par 1)
// - implémenter d'autres méthodes d'attribution de sièges que celle de Hondt
// - import/export presets en JSON
// - i18n
var preset_european_parliament_2009_france_ile_de_france = {
name: "Résultats des élections Européennes 2009, circonscription Ile-de-France",
seats: 13,
votes: 2798120,
minimum_percent_required: 5,
lists : [
{
name: "Front national",
votes: 123199,
percent: 4.40,
seats: 0
},
{
name: "Cannabis sans frontières",
votes: 4015,
percent: 0.14,
seats: 0
},
{
name: "Pour une France et une Europe plus fraternelles",
votes: 6529,
percent: 0.23,
seats: 0
},
{
name: "L'Europe de Gibraltar à Jérusalem",
votes: 1197,
percent: 0.04,
seats: 0
},
{
name: "Communistes",
votes: 1050,
percent: 0.04,
seats: 0
},
{
name: "L'Europe c'est vous",
votes: 2792,
percent: 0.10,
seats: 0
},
{
name: "M. Patrick COSSERON DE VILLENOISY (LAUT)",
votes: 1317,
percent: 0.05,
seats: 0
},
{
name: "M. Alain MOURGUY (LAUT)",
votes: 755,
percent: 0.03,
seats: 0
},
{
name: "M. Jean-Marc GOVERNATORI (LAUT)",
votes: 83009,
percent: 2.97,
seats: 0
},
{
name: "Mme Elisabeth BARBAY (LAUT)",
votes: 3294,
percent: 0.12,
seats: 0
},
{
name: "M. Axel DE BOER (LAUT)",
votes: 4386,
percent: 0.16,
seats: 0
},
{
name: "M. Daniel COHN BENDIT (LVEC)",
votes: 583690,
percent: 20.86,
seats: 4
},
{
name: "M. Michel BARNIER (LMAJ)",
votes: 828172,
percent: 29.60,
seats: 5
},
{
name: "M. Jean-Pierre ENJALBERT (LDVD)",
votes: 68333,
percent: 2.44,
seats: 0
},
{
name: "M. Omar SLAOUTI (LEXG)",
votes: 97454,
percent: 3.48,
seats: 0
},
{
name: "Mme Annick DU ROSCOAT (LDVD)",
votes: 11700,
percent: 0.42,
seats: 0
},
{
name: "M. Jean-Pierre MERCIER (LEXG)",
votes: 20748,
percent: 0.74,
seats: 0
},
{
name: "M. Jean-Luc PASQUINET (LDVG)",
votes: 1015,
percent: 0.04,
seats: 0
},
{
name: "M. Dieudonné MBALA MBALA (LAUT)",
votes: 36374,
percent: 1.30,
seats: 0
},
{
name: "M. Alain DUCQ (LDVG)",
votes: 582,
percent: 0.02,
seats: 0
},
{
name: "M. Jérôme RIVIERE (LDVD)",
votes: 91814,
percent: 3.28,
seats: 0
},
{
name: "M. André LOCUSSOL (LAUT)",
votes: 1758,
percent: 0.06,
seats: 0
},
{
name: "Mme Françoise CASTANY (LAUT)",
votes: 28768,
percent: 1.03,
seats: 0
},
{
name: "M. Patrick LE HYARIC (LCOP)",
votes: 176862,
percent: 6.32,
seats: 1
},
{
name: "Mme Marianne RANKE-CORMIER (LAUT)",
votes: 1058,
percent: 0.04,
seats: 0
},
{
name: "M. Harlem DESIR (LSOC)",
votes: 379908,
percent: 13.58,
seats: 2
},
{
name: "Mme Marielle DE SARNEZ (LCMD)",
votes: 238341,
percent: 8.52,
seats: 1
},
],
};
var preset_european_parliament_2009_france_sud_est = {
name: "Résultats des élections Européennes 2009, circonscription Sud-Est",
seats: 13,
votes: 2939639,
minimum_percent_required: 5,
lists : [
{
name: "M. Jean-Luc BENNAHMIAS (LCMD)",
votes: 216630,
percent: 7.37,
seats: 1
},
{
name: "M. Jean-Marie LE PEN (LFN)",
votes: 249695,
percent: 8.49,
seats: 1
},
{
name: "M. Matthieu CHAUVIN (LAUT)",
votes: 4270,
percent: 0.15,
seats: 0
},
{
name: "M. Jérôme MEDEVILLE (LAUT)",
votes: 617,
percent: 0.02,
seats: 0
},
{
name: "Mme Nathalie ARTHAUD (LEXG)",
votes: 24727,
percent: 0.84,
seats: 0
},
{
name: "Mme Michèle VIANES (LDVD)",
votes: 58394,
percent: 1.99,
seats: 0
},
{
name: "Mme Michèle RIVASI (LVEC)",
votes: 537151,
percent: 18.27,
seats: 3
},
{
name: "M. Christian GARINO (LAUT)",
votes: 4286,
percent: 0.15,
seats: 0
},
{
name: "M. Daniel DUFRENEY (LDVD)",
votes: 354,
percent: 0.01,
seats: 0
},
{
name: "M. Raoul JENNAR (LEXG)",
votes: 127420,
percent: 4.33,
seats: 0
},
{
name: "M. Christophe RICERCHI (LEXG)",
votes: 593,
percent: 0.02,
seats: 0
},
{
name: "Mme Françoise GROSSETETE (LMAJ)",
votes: 862556,
percent: 29.34,
seats: 5
},
{
name: "M. Jacques GAUTRON (LDVD)",
votes: 626,
percent: 0.02,
seats: 0
},
{
name: "Mme Marie-Christine VERGIAT (LCOP)",
votes: 173576,
percent: 5.90,
seats: 1
},
{
name: "M. Philippe BARIOL (LDVG)",
votes: 136,
percent: 0,
seats: 0
},
{
name: "M. Dominique HAMEL (LAUT)",
votes: 606,
percent: 0.02,
seats: 0
},
{
name: "M. Patrick LOUIS (LDVD)",
votes: 126219,
percent: 4.29,
seats: 0
},
{
name: "M. Francis LALANNE (LAUT)",
votes: 110109,
percent: 3.75,
seats: 0
},
{
name: "Mme Annie VITAL (LDVG)",
votes: 1110,
percent: 0.04,
seats: 0
},
{
name: "M. Vincent PEILLON (LSOC)",
votes: 426043,
percent: 14.49,
seats: 2
},
{
name: "M. Victor Hugo ESPINOSA (LAUT)",
votes: 14521,
percent: 0.49,
seats: 0
},
],
};
var preset_european_parliament_2014_france_ile_de_france = {
name: "Listes candidates aux élections européennes de 2014, circonscription Ile-de-France",
seats: 15,
votes: 2798120,
minimum_percent_required: 5,
lists : [
{
name: "POUR LA FRANCE, AGIR EN EUROPE AVEC ALAIN LAMASSOURE",
votes: 0,
percent: 21.0,
seats: 0
},
{
name: "LISTE BLEU MARINE - NON A BRUXELLES, OUI A LA FRANCE",
votes: 0,
percent: 20.0,
seats: 0
},
{
name: "CHOISIR NOTRE EUROPE",
votes: 0,
percent: 17.0,
seats: 0
},
{
name: "UDI MODEM LES EUROPEENS. LISTE SOUTENUE PAR FRANÇOIS BAYROU ET JEAN-LOUIS BORLOO",
votes: 0,
percent: 10.0,
seats: 0
},
{
name: "LISTE EUROPE ECOLOGIE",
votes: 0,
percent: 9.0,
seats: 0
},
{
name: "STOP A L'EUROPE DE LA FINANCE-L'HUMAIN D'ABORD ! FRONT DE GAUCHE",
votes: 0,
percent: 7.0,
seats: 0
},
{
name: "POUR UNE EUROPE DES TRAVAILLEURES ET DES PEUPLES, ENVOYONS VALSER L'AUSTÉRITÉ ET LE GOUVERNEMENT !",
votes: 0,
percent: 3.5,
seats: 0
},
{
name: "DEBOUT LA FRANCE ! NI SYSTÈME, NI EXTRÊMES, AVEC NICOLAS DUPONT-AIGNAN",
votes: 0,
percent: 2.5,
seats: 0
},
{
name: "NOUVELLE DONNE",
votes: 0,
percent: 2.5,
seats: 0
},
{
name: "NOUS CITOYENS",
votes: 0,
percent: 2.0,
seats: 0
},
{
name: "EUROPE CITOYENNE",
votes: 0,
percent: 1.5,
seats: 0
},
{
name: "DÉMOCRATIE RÉELLE",
votes: 0,
percent: 1.5,
seats: 0
},
{
name: "EUROPIRATES D'IDF",
votes: 0,
percent: 1.0,
seats: 0
},
{
name: "UPR-IDF",
votes: 0,
percent: 1.0,
seats: 0
},
{
name: "LUTTE OUVRIERE FAIRE ENTENDRE LE CAMP DES TRAVAILLEURS",
votes: 0,
percent: 0.5,
seats: 0
},
{
name: "REGIONS ET PEUPLES SOLIDAIRES",
votes: 0,
percent: 0,
seats: 0
},
{
name: "EUROPE SOLIDAIRE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "EUROPE DECROISSANCE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "CANNABIS SANS FRONTIERES STOP LA PROHIBITION",
votes: 0,
percent: 0,
seats: 0
},
{
name: "PARTI FÉDÉRALISTE EUROPÉEN",
votes: 0,
percent: 0,
seats: 0
},
{
name: "POUR UNE FRANCE ROYALE AU COEUR DE L'EUROPE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "ENSEMBLE POUR UNE EUROPE EQUITABLE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "ESPÉRANTO LANGUE COMMUNE ÉQUITABLE POUR L'EUROPE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "COMMUNISTES",
votes: 0,
percent: 0,
seats: 0
},
{
name: "CITOYENS DU VOTE BLANC",
votes: 0,
percent: 0,
seats: 0
},
{
name: "FÉMINISTES POUR UNE EUROPE SOLIDAIRE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "ALLIANCE ECOLOGISTE INDEPENDANTE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "POUR UNE EUROPE LIBRE",
votes: 0,
percent: 0,
seats: 0
},
{
name: "L'EUROPE DE MARRAKECH À ISTANBUL",
votes: 0,
percent: 0,
seats: 0
},
{
name: "PARTI EUROPÉEN",
votes: 0,
percent: 0,
seats: 0
},
{
name: "FORCE VIE",
votes: 0,
percent: 0,
seats: 0
},
],
};
var presets = [
preset_european_parliament_2009_france_ile_de_france,
preset_european_parliament_2009_france_sud_est,
preset_european_parliament_2014_france_ile_de_france,
];
function updateAllSlidersExcept ( me )
{
var sum = 0;
$('input.votes').not(me).each(function(){
sum += parseInt($(this).val());
});
$('input.votes').not(me).each(function(){
var fixed = $(this).parents(".list").children(".slider_fixed").first().is(':checked');
if ( fixed === true )
return;
var value_ratio = 1;
if ( sum > 0 )
value_ratio = $(this).val() / sum;
if ( me != null && me != undefined )
value_rest = getTotalVotes() - me.val();
else
value_rest = getTotalVotes();
$(this).val(value_ratio * value_rest);
updateMySlider ( $(this), $(this).val() );
});
checkSumVotes();
}
function checkSumVotes ()
{
var sum = 0;
$('input.votes').each(function(){
sum += parseInt($(this).val());
});
var theory = getTotalVotes();
var difference = sum - theory;
//var variation = Math.abs( sum - getTotalVotes() ) / Math.max( sum, getTotalVotes() );
var variation = ( sum - theory ) / theory; // positive or negative ratio
var hue; // will be from 0 (red) to 130 (green). will be red when abs(saturation) > 3%
hue = Math.min ( 3, Math.abs(variation) * 100 );
hue = (hue / 3);
hue = (1 - hue) * 130;
$("#total_votes_check").html("Erreur d'approximation : " + difference + " votes <span style='color: hsl(" + hue + ",100%,40%);'>(soit une variation de " + (variation*100) + " %)</span>");
}
function updateMySliderInput ( me, my_value )
{
var votes = me.parents(".slider_container").children('.votes');
votes.val(my_value);
//var votes = (my_value / 100) * getTotalVotes();
//me.parents(".slider_container").children('.votes').val(votes);
var percent = getPercentFromVotes ( my_value );
me.parents(".slider_container").children('.percent').val(percent);
updateAllSlidersExcept($(votes));
}
function updateMySlider ( me, my_value )
{
my_value = parseFloat(my_value);
me.parents(".slider_container").children('.slider').slider("value", my_value);
//var votes = (my_value / 100) * getTotalVotes();
var percent = getPercentFromVotes ( my_value );
me.parents(".slider_container").children('.percent').val(percent);
}
function getTotalVotes ()
{
return parseInt( $("#total_votes").val() );
}
/* not used
// percent: [0;100] (not a ratio)
function getVotesFromPercent ( percent )
{
var votes = Math.floor((my_value / 100) * getTotalVotes());
return votes;
}
*/
function getPercentFromVotes ( votes )
{
votes = parseInt(votes);
return (votes / getTotalVotes() ) * 100;
}
function addList ( name, votes, fixed )
{
if ( name == undefined )
name = "";
if ( votes == undefined )
votes = -1;
if ( fixed == undefined )
fixed = false;
var new_list_value;
if ( votes != -1 )
new_list_value = votes;
else
{
new_list_value = getTotalVotes();
$('#lists .list').each(function(){
//new_list_value -= parseFloat($(this).find("input.slider_input").val());
new_list_value -= parseInt($(this).find("input.votes").val());
});
}
var input_fixed_value = "";
if ( fixed == true )
input_fixed_value = " checked";
$("#lists").append('<div class="list">'
+'Nom : <input type="text" class="list_name" size="20" value="' + name + '" />'
+'<input type="submit" value="Supprimer" class="remove" />'
+'<br/>'
+'<div class="slider_container">'
+'Score : '
+'<input class="votes" type="text" value="' + new_list_value + '" size="6" /> votes, c\'est-à-dire '
+'<input class="percent" type="text" value="' + getPercentFromVotes(new_list_value) + '" size="4" /> % des voix'
+'<div class="slider"></div>'
+'</div>'
+'Verrouiller la valeur <input type="checkbox" class="slider_fixed"' + input_fixed_value + ' />'
+'</div>');
$("#lists .slider").last().slider({
min: 0,
max: getTotalVotes(),
range: "min",
animate: true,
value: new_list_value,
step: 1,
slide: function( event, ui ) {
updateMySliderInput( $(this), ui.value );
}
});
$("#lists input.votes").last().change(function () {
updateMySlider( $(this), $(this).val() );
updateAllSlidersExcept($(this));
});
$("#lists input.percent").last().change(function () {
// update votes value
var votes = ( $(this).val() / 100 ) * getTotalVotes();
var votes_input = $(this).parents(".slider_container").children('.votes');
$(votes_input).val(votes);
// cascade
$(votes_input).trigger('change');
});
// TODO
// remove a list when button is clicked
$("#lists input.remove").last().click(function () {
$(this).parents(".list").remove();
// update results
updateAllSlidersExcept(null);
});
}
function applyPreset ( preset )
{
clearLists();
$("#election_result").html("");
$('#seats').val( preset.seats );
$('#minimum_percent_required').val( preset.minimum_percent_required );
$('#total_votes').val( preset.votes );
for ( var i = 0; i < preset.lists.length; ++i )
{
var list = preset.lists[i];
// if we know the percentage but not the number of votes, deduce it
if ( !list.votes && list.percent )
list.votes = (list.percent / 100) * preset.votes;
addList ( list.name, list.votes, true ); // we load them locked so their value won't be changed on each add
}
// unlock lists
$(".list .slider_fixed").attr('checked', false);
checkSumVotes();
}
function clearLists ()
{
$("#lists").html(null);
}
function computeResultsWithDHondtMethod ( lists, seats )
{
//var total_votes = 0;
for ( var i = 0; i < lists.length; ++i )
{
//total_votes += lists[i].votes;
lists[i].seats = 0;
}
// create table, as in http://en.wikipedia.org/wiki/D%27Hondt_method#Allocation
var table = [];
for ( var row = 0; row < lists.length; ++row )
{
table[row] = [];
}
for ( var column = 0; column < seats; ++column )
{
for ( var row = 0; row < lists.length; ++row )
{
table[row][column] = lists[row].votes / (1 + column);
}
}
console.log(table);
//return lists;
// find the maximum value in the table, and repeat "seats" times
var max_value = 0;
var max_position_column = 0;
var max_position_row = 0;
var equalities = 0;
for ( var seats_given = 0; seats_given < seats; ++seats_given )
{
max_value = 0;
for ( var column = 0; column < seats; ++column )
{
for ( var row = 0; row < lists.length; ++row )
{
if ( table[row][column] > max_value )
{
max_value = table[row][column];
max_position_column = column;
max_position_row = row;
}
}
}
// check for equalities
var number_of_maxima = 0;
for ( var column = 0; column < seats; ++column )
{
for ( var row = 0; row < lists.length; ++row )
{
if ( table[row][column] == max_value )
++number_of_maxima;
}
}
if ( number_of_maxima > 1 )
{
++equalities;
}
// increment number of seats given to the list which has the max
if ( lists[max_position_row].seats == undefined || lists[max_position_row].seats == null )
lists[max_position_row].seats = 1;
else
lists[max_position_row].seats = lists[max_position_row].seats + 1;
// reset winning cell
table[max_position_row][max_position_column] = 0;
}
if ( equalities > 0 )
{
alert("Attention ! Il y a eu " + equalities + " égalité(s) pour l'attribution des sièges.");
}
return lists;
}
// make a JSON from current lists
function getJsonFromLists ()
{
var lists = [];
var i = 0;
$('.list').each(function(){
lists[i++] = {
name: $(this).children(".list_name").val(),
votes: parseInt($(this).children(".slider_container").children(".votes").val()),
//percent: 4.40,
seats: 0
};
});
return lists;
}
// function used to sort an array by the value of one of its fields
function predicatBy(prop)
{
return function(a,b){
if( a[prop] > b[prop]){
return 1;
}else if( a[prop] < b[prop] ){
return -1;
}
return 0;
}
}
$(function() {
$("#preset").change(function(){
applyPreset ( presets[$(this).val()] );
});
$("#list_add").click(function(){
addList();
});
for ( var i = 0; i < presets.length; ++i )
{
var name = presets[i].name;
$("#preset").append('<option value=' + i + '>' + name + '</option>');
}
$("#compute").click(function(){
var lists = getJsonFromLists();
console.log(lists);
//return;
var result_html = "<h2>Sièges attribués</h2>";
var lists_result = computeResultsWithDHondtMethod ( lists, parseInt( $("#seats").val() ) );
lists_result.sort( predicatBy("seats") );
lists_result.reverse();
for ( var i = 0; i < lists_result.length; ++i )
{
result_html += 'Liste "' + lists_result[i].name + '" : ' + lists_result[i].seats + " siège(s)<br/>";
}
$("#election_result").html(result_html);
});
// init
addList();
checkSumVotes ();
});
</script>
<style>
.slider_container {
width: 100%;
}
.slider {
margin: 6px 10px;
}
.list {
margin-bottom: 20px;
background: #ddd;
padding: 10px;
margin: 10px;
width: 95%;
}
.list .remove {
float: right;
}
</style>
</head>
<body>
<h2>Presets</h2>
Charger un preset :
<select id="preset">
<option value="none">Aucun</option>
</select>
<h2>Paramètres généraux</h2>
Nombre de sièges à pourvoir : <input type="text" id="seats" value="13" size="6" />
<br/>
Les listes obtenant moins de <input type="text" id="minimum_percent_required" value="5" size="4" /> % des voix ne peuvent pas obtenir de représentant.
<br/>
Suffrages exprimés : <input type="text" id="total_votes" value="2798120" size="10" /> (= nombre de votes sauf blancs et nuls)
<h2>Listes candidates</h2>
<div id="lists">
</div>
<input type="submit" id="list_add" value="Ajouter une liste" />
<br/>
<br/>
<div id="total_votes_check"></div>
<br/>
<input type="submit" id="compute" value="Calculer l'attribution de sièges" />
<br/>
<div id="election_result"></div>
<h2>À propos</h2>
Simulateur d'élections utilisant la <a href="http://fr.wikipedia.org/wiki/Scrutin_proportionnel_plurinominal#M.C3.A9thode_d.27Hondt">méthode d'Hondt</a>. Inspiré de <a href="http://icon.cat/util/elections">http://icon.cat/util/elections</a>.
<a href="http://www.interieur.gouv.fr/Elections/Les-resultats/Europeennes/elecresult__europeennes_2009/%28path%29/europeennes_2009/index.html">Résultats des élections européennes de 2009 en France</a>
</body>
</html>