Module:Electowidget

From electowiki

This is the very beginning of a Lua implementation of Electowidget.

(see also: Module:ABIF)

Tests

Test 1

{{#invoke:Electowidget|parse_prefs_line|24: "蘇業"/5 > DGM/2 = AM/2 > SBJ/}}

Result 1

table

Test 2

{{#invoke:Electowidget|prefs_line_json|24: "蘇業"/5 > DGM/2 = AM/2 > SBJ/}}

Result 2

{"prefs":[{"name":"foo1","rating":1},{"name":"foo2","rating":2}],"qty":9999,"orderedlist":true}

Test 3

{{#invoke:Electowidget|get_data|2009 Burlington, Vermont Mayoral Election data}}

Result 3

{

 "version":"0.1",
 "candidates":
 {
   "Kiss":
   {
     "display_name":"Bob Kiss (Progressive)"
   },
   "Montroll":
   {
     "display_name":"Andy Montroll (Democrat)"
   },
   "Simpson":
   {
     "display_name":"James Simpson (Green)"
   },
   "Smith":
   {
     "display_name":"Dan Smith (Independent)"
   },
   "Wright":
   {
     "display_name":"Kurt Wright (Republican)"
   },
   "Write-in":
   {
     "display_name":"Write-in"
   }
 },
 "description":"2009 Burlington mayoral election",
 "display_parameters": true,
 "display_results": true,
 "display_ballots": true,
 "allow_voting": false,
 "ballot_type": null,
 "max_rating": 6,
 "min_rating": 0,
 "count_subpage_ballots": false,
 "count_inline_ballots": true,
 "election_methods":
 [
   {
     "type":"copeland"
   },
   {
     "type":"plurality"
   }
 ],
 "inline_ballot_type":"range-array",
 "inline_ballots":
 [
   {"qty":840, "vote": {"Wright":6}},
   {"qty":355, "vote": {"Kiss":6, "Montroll":5}},
   {"qty":326, "vote": {"Kiss":6}},
   {"qty":271, "vote": {"Wright":6, "Smith":5}},
   {"qty":256, "vote": {"Wright":6, "Montroll":5}},
   {"qty":234, "vote": {"Kiss":6, "Montroll":5, "Smith":4}},
   {"qty":200, "vote": {"Montroll":6, "Kiss":5}},
   {"qty":178, "vote": {"Montroll":6}},
   {"qty":147, "vote": {"Wright":6, "Montroll":5, "Smith":4}},
   {"qty":145, "vote": {"Montroll":6, "Kiss":5, "Smith":4}},
   {"qty":139, "vote": {"Montroll":6, "Smith":5}},
   {"qty":125, "vote": {"Kiss":6, "Smith":5}},
   {"qty":124, "vote": {"Smith":6}},
   {"qty":123, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Wright":3, "Simpson":2}},
   {"qty":122, "vote": {"Wright":6, "Smith":5, "Montroll":4}},
   {"qty":121, "vote": {"Kiss":6, "Smith":5, "Montroll":4}},
   {"qty":120, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Simpson":3, "Wright":2}},
   {"qty":104, "vote": {"Wright":6, "Montroll":5, "Smith":4, "Simpson":3, "Kiss":2}},
   {"qty":103, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Smith":3, "Wright":2}},
   {"qty":102, "vote": {"Wright":6, "Montroll":5, "Smith":4, "Kiss":3, "Simpson":2}},
   {"qty":101, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Kiss":3, "Simpson":2}},
   {"qty":94, "vote": {"Montroll":6, "Wright":5}},
   {"qty":93, "vote": {"Montroll":6, "Smith":5, "Kiss":4}},
   {"qty":93, "vote": {"Smith":6, "Wright":5}},
   {"qty":90, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Simpson":3, "Kiss":2}},
   {"qty":90, "vote": {"Smith":6, "Montroll":5}},
   {"qty":88, "vote": {"Smith":6, "Kiss":5, "Montroll":4}},
   {"qty":83, "vote": {"Smith":6, "Montroll":5, "Kiss":4}},
   {"qty":80, "vote": {"Wright":6, "Kiss":5}},
   {"qty":80, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Simpson":3, "Wright":2}},
   {"qty":76, "vote": {"Wright":6, "Smith":5, "Simpson":4, "Montroll":3, "Kiss":2}},
   {"qty":72, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Wright":3, "Simpson":2}},
   {"qty":71, "vote": {"Kiss":6, "Montroll":5, "Wright":4, "Smith":3, "Simpson":2}},
   {"qty":69, "vote": {"Wright":6, "Montroll":5, "Kiss":4, "Smith":3, "Simpson":2}},
   {"qty":69, "vote": {"Montroll":6, "Smith":5, "Kiss":4, "Wright":3, "Simpson":2}},
   {"qty":66, "vote": {"Kiss":6, "Wright":5}},
   {"qty":62, "vote": {"Montroll":6, "Smith":5, "Wright":4}},
   {"qty":61, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Simpson":3, "Wright":2}},
   {"qty":60, "vote": {"Montroll":6, "Wright":5, "Smith":4, "Kiss":3, "Simpson":2}},
   {"qty":60, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Wright":3}},
   {"qty":58, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Simpson":3, "Wright":2}},
   {"qty":57, "vote": {"Montroll":6, "Wright":5, "Smith":4}},
   {"qty":56, "vote": {"Montroll":6, "Wright":5, "Kiss":4, "Smith":3, "Simpson":2}},
   {"qty":55, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Wright":3, "Simpson":2}},
   {"qty":54, "vote": {"Wright":6, "Montroll":5, "Smith":4, "Kiss":3}},
   {"qty":53, "vote": {"Montroll":6, "Smith":5, "Kiss":4, "Simpson":3, "Wright":2}},
   {"qty":52, "vote": {"Smith":6, "Wright":5, "Montroll":4, "Kiss":3, "Simpson":2}},
   {"qty":52, "vote": {"Wright":6, "Smith":5, "Kiss":4, "Montroll":3, "Simpson":2}},
   {"qty":52, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Kiss":3, "Simpson":2}},
   {"qty":52, "vote": {"Kiss":6, "Montroll":5, "Simpson":4}},
   {"qty":51, "vote": {"Smith":6, "Kiss":5}},
   {"qty":50, "vote": {"Wright":6, "Kiss":5, "Montroll":4, "Smith":3, "Simpson":2}},
   {"qty":50, "vote": {"Smith":6, "Wright":5, "Montroll":4}},
   {"qty":50, "vote": {"Montroll":6, "Kiss":5, "Wright":4, "Smith":3, "Simpson":2}},
   {"qty":48, "vote": {"Kiss":6, "Montroll":5, "Wright":4}},
   {"qty":46, "vote": {"Wright":6, "Montroll":5, "Kiss":4}},
   {"qty":46, "vote": {"Montroll":6, "Kiss":5, "Wright":4}},
   {"qty":45, "vote": {"Wright":6, "Kiss":5, "Smith":4, "Montroll":3, "Simpson":2}},
   {"qty":45, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Kiss":3}},
   {"qty":43, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Wright":3, "Simpson":2}},
   {"qty":42, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Simpson":3}},
   {"qty":41, "vote": {"Montroll":6, "Smith":5, "Kiss":4, "Wright":3}},
   {"qty":41, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Smith":3}},
   {"qty":39, "vote": {"Kiss":6, "Wright":5, "Montroll":4, "Smith":3, "Simpson":2}},
   {"qty":39, "vote": {"Montroll":6, "Wright":5, "Smith":4, "Simpson":3, "Kiss":2}},
   {"qty":38, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Simpson":3, "Wright":2}},
   {"qty":38, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Wright":3}},
   {"qty":37, "vote": {"Smith":6, "Montroll":5, "Wright":4}},
   {"qty":37, "vote": {"Montroll":6, "Wright":5, "Smith":4, "Kiss":3}},
   {"qty":34, "vote": {"Montroll":6, "Wright":5, "Kiss":4}},
   {"qty":32, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Wright":3, "Simpson":2}},
   {"qty":32, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Kiss":3}},
   {"qty":31, "vote": {"Smith":6, "Montroll":5, "Wright":4, "Kiss":3, "Simpson":2}},
   {"qty":31, "vote": {"Kiss":6, "Wright":5, "Montroll":4}},
   {"qty":30, "vote": {"Wright":6, "Smith":5, "Kiss":4}},
   {"qty":29, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Wright":3}},
   {"qty":28, "vote": {"Smith":6, "Wright":5, "Montroll":4, "Simpson":3, "Kiss":2}},
   {"qty":27, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Smith":3, "Wright":2}},
   {"qty":27, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Wright":3}},
   {"qty":27, "vote": {"Smith":6, "Wright":5, "Kiss":4, "Montroll":3, "Simpson":2}},
   {"qty":27, "vote": {"Smith":6, "Montroll":5, "Wright":4, "Kiss":3}},
   {"qty":27, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Kiss":3, "Wright":2}},
   {"qty":26, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Wright":3}},
   {"qty":26, "vote": {"Kiss":6, "Smith":5, "Wright":4, "Montroll":3, "Simpson":2}},
   {"qty":25, "vote": {"Wright":6, "Simpson":5}},
   {"qty":24, "vote": {"Montroll":6, "Kiss":5, "Wright":4, "Smith":3}},
   {"qty":24, "vote": {"Wright":6, "Kiss":5, "Montroll":4}},
   {"qty":24, "vote": {"Kiss":6, "Montroll":5, "Wright":4, "Smith":3}},
   {"qty":24, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Smith":3, "Wright":2}},
   {"qty":23, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Simpson":3, "Kiss":2}},
   {"qty":23, "vote": {"Kiss":6, "Smith":5, "Simpson":4, "Montroll":3, "Wright":2}},
   {"qty":22, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Simpson":3}},
   {"qty":21, "vote": {"Wright":6, "Kiss":5, "Montroll":4, "Simpson":3, "Smith":2}},
   {"qty":21, "vote": {"Wright":6, "Kiss":5, "Smith":4}},
   {"qty":21, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Simpson":3}},
   {"qty":21, "vote": {"Kiss":6, "Wright":5, "Smith":4, "Montroll":3, "Simpson":2}},
   {"qty":20, "vote": {"Montroll":6, "Wright":5, "Kiss":4, "Smith":3}},
   {"qty":19, "vote": {"Wright":6, "Montroll":5, "Simpson":4, "Smith":3, "Kiss":2}},
   {"qty":19, "vote": {"Kiss":6, "Simpson":5}},
   {"qty":19, "vote": {"Wright":6, "Smith":5, "Kiss":4, "Montroll":3}},
   {"qty":18, "vote": {"Smith":6, "Montroll":5, "Simpson":4, "Kiss":3, "Wright":2}},
   {"qty":17, "vote": {"Wright":6, "Smith":5, "Kiss":4, "Simpson":3, "Montroll":2}},
   {"qty":17, "vote": {"Smith":6, "Wright":5, "Montroll":4, "Kiss":3}},
   {"qty":16, "vote": {"Wright":6, "Smith":5, "Simpson":4}},
   {"qty":16, "vote": {"Smith":6, "Wright":5, "Kiss":4}},
   {"qty":16, "vote": {"Smith":6, "Kiss":5, "Wright":4, "Montroll":3, "Simpson":2}},
   {"qty":16, "vote": {"Kiss":6, "Simpson":5, "Montroll":4}},
   {"qty":15, "vote": {"Kiss":6, "Wright":5, "Smith":4, "Montroll":3}},
   {"qty":15, "vote": {"Wright":6, "Montroll":5, "Kiss":4, "Smith":3}},
   {"qty":15, "vote": {"Kiss":6, "Smith":5, "Simpson":4}},
   {"qty":15, "vote": {"Smith":6, "Montroll":5, "Simpson":4, "Wright":3, "Kiss":2}},
   {"qty":15, "vote": {"Wright":6, "Kiss":5, "Montroll":4, "Smith":3}},
   {"qty":15, "vote": {"Wright":6, "Smith":5, "Simpson":4, "Kiss":3, "Montroll":2}},
   {"qty":15, "vote": {"Kiss":6, "Smith":5, "Wright":4, "Montroll":3}},
   {"qty":14, "vote": {"Smith":6, "Kiss":5, "Simpson":4, "Montroll":3, "Wright":2}},
   {"qty":14, "vote": {"Kiss":6, "Montroll":5, "Wright":4, "Simpson":3, "Smith":2}},
   {"qty":13, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Wright":3, "Smith":2}},
   {"qty":13, "vote": {"Kiss":6, "Smith":5, "Wright":4}},
   {"qty":13, "vote": {"Smith":6, "Montroll":5, "Wright":4, "Simpson":3, "Kiss":2}},
   {"qty":13, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Simpson":3}},
   {"qty":13, "vote": {"Montroll":6, "Smith":5, "Kiss":4, "Simpson":3}},
   {"qty":12, "vote": {"Montroll":6, "Kiss":5, "Simpson":4}},
   {"qty":12, "vote": {"Wright":6, "Kiss":5, "Smith":4, "Simpson":3, "Montroll":2}},
   {"qty":12, "vote": {"Smith":6, "Wright":5, "Kiss":4, "Montroll":3}},
   {"qty":12, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Montroll":3, "Wright":2}},
   {"qty":12, "vote": {"Kiss":6, "Wright":5, "Montroll":4, "Smith":3}},
   {"qty":12, "vote": {"Smith":6, "Wright":5, "Simpson":4, "Montroll":3, "Kiss":2}},
   {"qty":12, "vote": {"Kiss":6, "Wright":5, "Montroll":4, "Simpson":3, "Smith":2}},
   {"qty":12, "vote": {"Kiss":6, "Wright":5, "Smith":4}},
   {"qty":12, "vote": {"Montroll":6, "Wright":5, "Simpson":4, "Smith":3, "Kiss":2}},
   {"qty":11, "vote": {"Montroll":6, "Kiss":5, "Wright":4, "Simpson":3, "Smith":2}},
   {"qty":11, "vote": {"Smith":6, "Kiss":5, "Wright":4}},
   {"qty":11, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Wright":3, "Kiss":2}},
   {"qty":11, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Smith":3}},
   {"qty":11, "vote": {"Wright":6, "Write-in":5}},
   {"qty":11, "vote": {"Wright":6, "Simpson":5, "Smith":4, "Montroll":3, "Kiss":2}},
   {"qty":10, "vote": {"Smith":6, "Kiss":5, "Wright":4, "Simpson":3, "Montroll":2}},
   {"qty":10, "vote": {"Write-in":6}},
   {"qty":10, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Simpson":3}},
   {"qty":10, "vote": {"Wright":6, "Simpson":5, "Smith":4, "Kiss":3, "Montroll":2}},
   {"qty":9, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Simpson":3, "Write-in":2}},
   {"qty":9, "vote": {"Wright":6, "Montroll":5, "Kiss":4, "Simpson":3, "Smith":2}},
   {"qty":9, "vote": {"Montroll":6, "Simpson":5, "Smith":4}},
   {"qty":9, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Simpson":3, "Write-in":2}},
   {"qty":9, "vote": {"Montroll":6, "Simpson":5, "Kiss":4, "Smith":3, "Wright":2}},
   {"qty":9, "vote": {"Kiss":6, "Smith":5, "Simpson":4, "Montroll":3}},
   {"qty":9, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Kiss":3, "Wright":2}},
   {"qty":8, "vote": {"Montroll":6, "Simpson":5, "Smith":4, "Kiss":3, "Wright":2}},
   {"qty":8, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Simpson":3}},
   {"qty":8, "vote": {"Montroll":6, "Simpson":5, "Smith":4, "Wright":3, "Kiss":2}},
   {"qty":8, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Smith":3}},
   {"qty":8, "vote": {"Wright":6, "Simpson":5, "Smith":4}},
   {"qty":8, "vote": {"Montroll":6, "Smith":5, "Simpson":4}},
   {"qty":8, "vote": {"Smith":6, "Kiss":5, "Wright":4, "Montroll":3}},
   {"qty":8, "vote": {"Kiss":6, "Simpson":5, "Smith":4}},
   {"qty":7, "vote": {"Montroll":6, "Simpson":5, "Kiss":4}},
   {"qty":7, "vote": {"Wright":6, "Montroll":5, "Smith":4, "Simpson":3}},
   {"qty":7, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Wright":3, "Smith":2}},
   {"qty":7, "vote": {"Wright":6, "Montroll":5, "Simpson":4, "Kiss":3, "Smith":2}},
   {"qty":7, "vote": {"Smith":6, "Kiss":5, "Simpson":4}},
   {"qty":6, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Simpson":3, "Write-in":2}},
   {"qty":6, "vote": {"Kiss":6, "Smith":5, "Simpson":4, "Wright":3, "Montroll":2}},
   {"qty":6, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Montroll":3}},
   {"qty":6, "vote": {"Kiss":6, "Wright":5, "Smith":4, "Simpson":3, "Montroll":2}},
   {"qty":6, "vote": {"Kiss":6, "Wright":5, "Simpson":4, "Smith":3, "Montroll":2}},
   {"qty":6, "vote": {"Kiss":6, "Smith":5, "Simpson":4, "Montroll":3, "Write-in":2}},
   {"qty":6, "vote": {"Smith":6, "Simpson":5}},
   {"qty":5, "vote": {"Smith":6, "Kiss":5, "Simpson":4, "Montroll":3}},
   {"qty":5, "vote": {"Smith":6, "Wright":5, "Kiss":4, "Simpson":3, "Montroll":2}},
   {"qty":5, "vote": {"Smith":6, "Simpson":5, "Kiss":4, "Montroll":3, "Wright":2}},
   {"qty":5, "vote": {"Montroll":6, "Write-in":5}},
   {"qty":5, "vote": {"Montroll":6, "Wright":5, "Smith":4, "Simpson":3}},
   {"qty":5, "vote": {"Wright":6, "Kiss":5, "Smith":4, "Montroll":3}},
   {"qty":5, "vote": {"Kiss":6, "Wright":5, "Simpson":4, "Montroll":3, "Smith":2}},
   {"qty":5, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Write-in":3, "Simpson":2}},
   {"qty":5, "vote": {"Kiss":6, "Smith":5, "Wright":4, "Simpson":3, "Montroll":2}},
   {"qty":5, "vote": {"Wright":6, "Simpson":5, "Montroll":4, "Smith":3, "Kiss":2}},
   {"qty":5, "vote": {"Smith":6, "Montroll":5, "Simpson":4}},
   {"qty":5, "vote": {"Smith":6, "Simpson":5, "Montroll":4}},
   {"qty":5, "vote": {"Wright":6, "Smith":5, "Simpson":4, "Montroll":3}},
   {"qty":4, "vote": {"Simpson":6, "Smith":5, "Kiss":4, "Montroll":3, "Wright":2}},
   {"qty":4, "vote": {"Montroll":6, "Simpson":5}},
   {"qty":4, "vote": {"Kiss":6, "Write-in":5, "Montroll":4, "Smith":3, "Simpson":2}},
   {"qty":4, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Wright":3, "Smith":2}},
   {"qty":4, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Simpson":3}},
   {"qty":4, "vote": {"Wright":6, "Smith":5, "Write-in":4}},
   {"qty":4, "vote": {"Wright":6, "Simpson":5, "Montroll":4, "Kiss":3}},
   {"qty":4, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Write-in":3, "Simpson":2}},
   {"qty":4, "vote": {"Smith":6, "Simpson":5, "Kiss":4, "Montroll":3}},
   {"qty":4, "vote": {"Smith":6, "Wright":5, "Simpson":4}},
   {"qty":4, "vote": {"Kiss":6, "Wright":5, "Montroll":4, "Simpson":3}},
   {"qty":4, "vote": {"Kiss":6, "Write-in":5}},
   {"qty":4, "vote": {"Wright":6, "Simpson":5, "Montroll":4, "Kiss":3, "Smith":2}},
   {"qty":4, "vote": {"Wright":6, "Montroll":5, "Write-in":4}},
   {"qty":4, "vote": {"Montroll":6, "Kiss":5, "Wright":4, "Simpson":3}},
   {"qty":4, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Write-in":3}},
   {"qty":3, "vote": {"Simpson":6, "Wright":5}},
   {"qty":3, "vote": {"Simpson":6, "Kiss":5}},
   {"qty":3, "vote": {"Montroll":6, "Kiss":5, "Write-in":4}},
   {"qty":3, "vote": {"Smith":6, "Wright":5, "Montroll":4, "Simpson":3}},
   {"qty":3, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Wright":3, "Write-in":2}},
   {"qty":3, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Kiss":3, "Write-in":2}},
   {"qty":3, "vote": {"Kiss":6, "Simpson":5, "Wright":4, "Montroll":3, "Smith":2}},
   {"qty":3, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Smith":3, "Write-in":2}},
   {"qty":3, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Wright":3, "Montroll":2}},
   {"qty":3, "vote": {"Montroll":6, "Wright":5, "Kiss":4, "Simpson":3, "Smith":2}},
   {"qty":3, "vote": {"Write-in":6, "Montroll":5}},
   {"qty":3, "vote": {"Wright":6, "Montroll":5, "Simpson":4}},
   {"qty":3, "vote": {"Kiss":6, "Smith":5, "Write-in":4, "Montroll":3, "Simpson":2}},
   {"qty":3, "vote": {"Simpson":6}},
   {"qty":3, "vote": {"Write-in":6, "Wright":5}},
   {"qty":3, "vote": {"Montroll":6, "Wright":5, "Simpson":4}},
   {"qty":3, "vote": {"Wright":6, "Simpson":5, "Write-in":4}},
   {"qty":3, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Write-in":3, "Simpson":2}},
   {"qty":3, "vote": {"Smith":6, "Wright":5, "Simpson":4, "Montroll":3}},
   {"qty":3, "vote": {"Write-in":6, "Kiss":5}},
   {"qty":3, "vote": {"Smith":6, "Montroll":5, "Write-in":4}},
   {"qty":2, "vote": {"Kiss":6, "Wright":5, "Smith":4, "Simpson":3}},
   {"qty":2, "vote": {"Wright":6, "Kiss":5, "Simpson":4, "Smith":3, "Montroll":2}},
   {"qty":2, "vote": {"Smith":6, "Wright":5, "Simpson":4, "Kiss":3, "Montroll":2}},
   {"qty":2, "vote": {"Montroll":6, "Smith":5, "Kiss":4, "Simpson":3, "Write-in":2}},
   {"qty":2, "vote": {"Kiss":6, "Smith":5, "Write-in":4}},
   {"qty":2, "vote": {"Smith":6, "Wright":5, "Write-in":4}},
   {"qty":2, "vote": {"Smith":6, "Simpson":5, "Kiss":4}},
   {"qty":2, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Write-in":3, "Kiss":2}},
   {"qty":2, "vote": {"Smith":6, "Montroll":5, "Simpson":4, "Kiss":3}},
   {"qty":2, "vote": {"Wright":6, "Write-in":5, "Montroll":4, "Kiss":3}},
   {"qty":2, "vote": {"Wright":6, "Kiss":5, "Simpson":4}},
   {"qty":2, "vote": {"Wright":6, "Kiss":5, "Smith":4, "Simpson":3}},
   {"qty":2, "vote": {"Smith":6, "Simpson":5, "Wright":4}},
   {"qty":2, "vote": {"Simpson":6, "Kiss":5, "Montroll":4}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Smith":4, "Wright":3}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Kiss":4, "Smith":3}},
   {"qty":2, "vote": {"Smith":6, "Kiss":5, "Write-in":4, "Montroll":3, "Simpson":2}},
   {"qty":2, "vote": {"Montroll":6, "Write-in":5, "Kiss":4, "Smith":3, "Simpson":2}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Wright":4, "Kiss":3, "Smith":2}},
   {"qty":2, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Write-in":3, "Wright":2}},
   {"qty":2, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Kiss":3}},
   {"qty":2, "vote": {"Wright":6, "Simpson":5, "Kiss":4, "Montroll":3, "Smith":2}},
   {"qty":2, "vote": {"Smith":6, "Kiss":5, "Simpson":4, "Montroll":3, "Write-in":2}},
   {"qty":2, "vote": {"Write-in":6, "Montroll":5, "Smith":4}},
   {"qty":2, "vote": {"Write-in":6, "Montroll":5, "Smith":4, "Simpson":3, "Kiss":2}},
   {"qty":2, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Write-in":3, "Simpson":2}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Wright":4}},
   {"qty":2, "vote": {"Kiss":6, "Montroll":5, "Wright":4, "Write-in":3}},
   {"qty":2, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Wright":3, "Write-in":2}},
   {"qty":2, "vote": {"Kiss":6, "Montroll":5, "Write-in":4}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Kiss":4, "Wright":3}},
   {"qty":2, "vote": {"Simpson":6, "Kiss":5, "Montroll":4, "Wright":3, "Smith":2}},
   {"qty":2, "vote": {"Write-in":6, "Montroll":5, "Simpson":4, "Smith":3, "Kiss":2}},
   {"qty":2, "vote": {"Kiss":6, "Simpson":5, "Wright":4}},
   {"qty":2, "vote": {"Write-in":6, "Montroll":5, "Smith":4, "Kiss":3, "Simpson":2}},
   {"qty":2, "vote": {"Smith":6, "Simpson":5, "Kiss":4, "Wright":3, "Montroll":2}},
   {"qty":2, "vote": {"Smith":6, "Simpson":5, "Wright":4, "Montroll":3, "Kiss":2}},
   {"qty":2, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Write-in":3, "Wright":2}},
   {"qty":2, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Write-in":3, "Smith":2}},
   {"qty":2, "vote": {"Wright":6, "Montroll":5, "Simpson":4, "Kiss":3}},
   {"qty":2, "vote": {"Montroll":6, "Smith":5, "Wright":4, "Simpson":3, "Write-in":2}},
   {"qty":2, "vote": {"Wright":6, "Write-in":5, "Montroll":4, "Smith":3, "Kiss":2}},
   {"qty":2, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Wright":3}},
   {"qty":2, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Simpson":3, "Write-in":2}},
   {"qty":2, "vote": {"Montroll":6, "Simpson":5, "Wright":4, "Smith":3, "Kiss":2}},
   {"qty":1, "vote": {"Montroll":6, "Wright":5, "Write-in":4, "Simpson":3, "Kiss":2}},
   {"qty":1, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Simpson":3, "Write-in":2}},
   {"qty":1, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Wright":3}},
   {"qty":1, "vote": {"Wright":6, "Montroll":5, "Simpson":4, "Smith":3}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Wright":3, "Write-in":2}},
   {"qty":1, "vote": {"Write-in":6, "Wright":5, "Smith":4, "Simpson":3, "Montroll":2}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Kiss":4}},
   {"qty":1, "vote": {"Wright":6, "Write-in":5, "Simpson":4}},
   {"qty":1, "vote": {"Wright":6, "Write-in":6, "Montroll":5, "Kiss":4, "Smith":3}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Montroll":4, "Smith":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Write-in":5, "Montroll":4, "Smith":3, "Simpson":2}},
   {"qty":1, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Write-in":3}},
   {"qty":1, "vote": {"Simpson":6, "Smith":5, "Wright":4}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Smith":4, "Montroll":3, "Simpson":2}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Write-in":3, "Kiss":2}},
   {"qty":1, "vote": {"Write-in":6, "Smith":5}},
   {"qty":1, "vote": {"Write-in":6, "Montroll":5, "Kiss":4, "Smith":3, "Simpson":2}},
   {"qty":1, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Write-in":3}},
   {"qty":1, "vote": {"Wright":6, "Write-in":5, "Kiss":4}},
   {"qty":1, "vote": {"Write-in":6, "Wright":5, "Simpson":4, "Montroll":3, "Kiss":2}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Write-in":4, "Montroll":3}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Smith":4, "Write-in":3, "Wright":2}},
   {"qty":1, "vote": {"Write-in":6, "Kiss":5, "Wright":4, "Montroll":3}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Wright":4, "Smith":3, "Simpson":2}},
   {"qty":1, "vote": {"Simpson":6, "Wright":5, "Kiss":4, "Smith":3, "Montroll":2}},
   {"qty":1, "vote": {"Simpson":6, "Smith":5, "Kiss":4}},
   {"qty":1, "vote": {"Simpson":6, "Montroll":5, "Wright":4, "Smith":3, "Kiss":2}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Wright":4}},
   {"qty":1, "vote": {"Smith":6, "Wright":5, "Kiss":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Simpson":6, "Smith":5, "Montroll":4, "Kiss":3, "Wright":2}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Montroll":4}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Write-in":4, "Montroll":3, "Kiss":2}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Kiss":4, "Wright":3}},
   {"qty":1, "vote": {"Montroll":6, "Simpson":5, "Wright":4, "Kiss":3}},
   {"qty":1, "vote": {"Kiss":6, "Wright":5, "Simpson":4, "Montroll":3}},
   {"qty":1, "vote": {"Simpson":6, "Write-in":5}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Write-in":3, "Simpson":2}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Kiss":4, "Smith":3, "Montroll":2}},
   {"qty":1, "vote": {"Montroll":6, "Write-in":5, "Simpson":4}},
   {"qty":1, "vote": {"Wright":6, "Write-in":5, "Montroll":4}},
   {"qty":1, "vote": {"Wright":6, "Write-in":6, "Smith":5, "Montroll":4, "Simpson":3, "Kiss":2}},
   {"qty":1, "vote": {"Kiss":6, "Montroll":5, "Smith":4, "Wright":3, "Write-in":2}},
   {"qty":1, "vote": {"Simpson":6, "Montroll":5, "Smith":4, "Wright":3, "Kiss":2}},
   {"qty":1, "vote": {"Wright":6, "Montroll":5, "Kiss":4, "Simpson":3}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Write-in":3}},
   {"qty":1, "vote": {"Simpson":6, "Montroll":5, "Wright":4, "Kiss":3, "Write-in":2}},
   {"qty":1, "vote": {"Montroll":6, "Simpson":5, "Wright":4, "Write-in":3, "Kiss":2}},
   {"qty":1, "vote": {"Smith":6, "Write-in":5}},
   {"qty":1, "vote": {"Montroll":6, "Write-in":5, "Simpson":4, "Smith":3}},
   {"qty":1, "vote": {"Smith":6, "Montroll":5, "Kiss":4, "Simpson":3, "Write-in":2}},
   {"qty":1, "vote": {"Montroll":6, "Simpson":5, "Smith":4, "Kiss":3}},
   {"qty":1, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Wright":3}},
   {"qty":1, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Wright":4, "Kiss":3}},
   {"qty":1, "vote": {"Smith":6, "Montroll":5, "Wright":4, "Write-in":3, "Simpson":2}},
   {"qty":1, "vote": {"Write-in":6, "Smith":5, "Kiss":4, "Wright":3, "Montroll":2}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Smith":4, "Write-in":3, "Wright":2}},
   {"qty":1, "vote": {"Smith":6, "Kiss":5, "Wright":4, "Simpson":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Montroll":4, "Smith":3}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Wright":4, "Simpson":3, "Smith":2}},
   {"qty":1, "vote": {"Wright":6, "Write-in":6, "Montroll":5}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Wright":3}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Wright":4, "Smith":3, "Montroll":2}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Smith":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Kiss":6, "Wright":5, "Smith":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Simpson":6, "Montroll":5, "Smith":4}},
   {"qty":1, "vote": {"Smith":6, "Kiss":5, "Wright":4, "Simpson":3}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Montroll":4, "Write-in":3, "Kiss":2}},
   {"qty":1, "vote": {"Smith":6, "Montroll":5, "Simpson":4, "Kiss":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Montroll":5, "Write-in":4, "Smith":3, "Kiss":2}},
   {"qty":1, "vote": {"Montroll":6, "Simpson":5, "Write-in":4, "Smith":3, "Kiss":2}},
   {"qty":1, "vote": {"Wright":6, "Write-in":5, "Smith":4, "Montroll":3, "Simpson":2}},
   {"qty":1, "vote": {"Montroll":6, "Wright":5, "Write-in":4}},
   {"qty":1, "vote": {"Wright":6, "Kiss":5, "Simpson":4, "Montroll":3}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Montroll":4, "Smith":3, "Wright":2}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Smith":4, "Write-in":3, "Montroll":2}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":6, "Wright":5, "Montroll":4, "Smith":3, "Simpson":2}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Write-in":4}},
   {"qty":1, "vote": {"Wright":6, "Montroll":5, "Smith":4, "Kiss":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Kiss":4, "Montroll":4}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Kiss":3}},
   {"qty":1, "vote": {"Montroll":6, "Smith":5, "Simpson":4, "Wright":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Simpson":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Write-in":6, "Kiss":5, "Smith":4, "Simpson":3, "Montroll":2}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Write-in":4, "Montroll":3, "Wright":2}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Wright":3}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Write-in":4, "Wright":3, "Simpson":2}},
   {"qty":1, "vote": {"Kiss":6, "Smith":5, "Wright":4, "Simpson":3}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Write-in":4, "Wright":3}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Smith":3, "Write-in":2}},
   {"qty":1, "vote": {"Kiss":6, "Smith":5, "Simpson":4, "Write-in":3, "Montroll":2}},
   {"qty":1, "vote": {"Kiss":6, "Montroll":5, "Write-in":4, "Wright":3, "Simpson":2}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Montroll":4, "Wright":3, "Kiss":2}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Montroll":4}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Montroll":4, "Wright":3, "Write-in":2}},
   {"qty":1, "vote": {"Smith":6, "Kiss":5, "Simpson":4, "Wright":3}},
   {"qty":1, "vote": {"Wright":6, "Simpson":5, "Smith":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Write-in":4, "Montroll":3, "Simpson":2}},
   {"qty":1, "vote": {"Montroll":6, "Simpson":5, "Smith":4, "Kiss":3, "Write-in":2}},
   {"qty":1, "vote": {"Smith":6, "Kiss":5, "Montroll":4, "Wright":3, "Write-in":2}},
   {"qty":1, "vote": {"Montroll":6, "Wright":5, "Simpson":4, "Kiss":3, "Smith":2}},
   {"qty":1, "vote": {"Kiss":6, "Montroll":5, "Simpson":4, "Write-in":3, "Wright":2}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Smith":4, "Montroll":3}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Kiss":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Kiss":6, "Wright":5, "Simpson":4, "Montroll":3, "Write-in":2}},
   {"qty":1, "vote": {"Kiss":6, "Write-in":5, "Montroll":4, "Smith":3}},
   {"qty":1, "vote": {"Wright":6, "Smith":5, "Write-in":4, "Simpson":3}},
   {"qty":1, "vote": {"Montroll":6, "Wright":5, "Smith":4, "Write-in":3}},
   {"qty":1, "vote": {"Simpson":6, "Smith":5, "Wright":4, "Montroll":3, "Kiss":2}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Montroll":4, "Smith":3}},
   {"qty":1, "vote": {"Wright":6, "Montroll":5, "Kiss":4, "Smith":3, "Write-in":2}},
   {"qty":1, "vote": {"Smith":6, "Montroll":5, "Wright":4, "Simpson":3}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Wright":4, "Montroll":3, "Smith":2}},
   {"qty":1, "vote": {"Write-in":6, "Kiss":5, "Montroll":4}},
   {"qty":1, "vote": {"Simpson":6, "Smith":5, "Montroll":4}},
   {"qty":1, "vote": {"Write-in":6, "Montroll":5, "Kiss":4, "Wright":3}},
   {"qty":1, "vote": {"Montroll":6, "Write-in":5, "Smith":4, "Kiss":3, "Simpson":2}},
   {"qty":1, "vote": {"Smith":6, "Simpson":5, "Wright":4, "Kiss":3, "Montroll":2}},
   {"qty":1, "vote": {"Kiss":6, "Simpson":5, "Write-in":4}},
   {"qty":1, "vote": {"Simpson":6, "Kiss":5, "Smith":4, "Wright":3}},
   {"qty":1, "vote": {"Kiss":6, "Smith":5, "Montroll":4, "Write-in":3, "Wright":2}},
   {"qty":1, "vote": {"Wright":6, "Kiss":5, "Simpson":4, "Montroll":3, "Smith":2}},
   {"qty":1, "vote": {"Montroll":6, "Kiss":5, "Simpson":4, "Write-in":3, "Smith":2}}
     ]

}


-- From: User:RobLa
-- Date: ~~~~
-- Comment: I think I'd like the new version of Electowidget to use ABIF
local p = {}

function p.parse_prefs_line(line)
  local qty, prefs = tostring(line):match('(%d+):%s*(.*)')
  local prefs_table = {}

  if prefs == '' then
    return { qty = qty, comment = nil, orderedlist = true }
  end

  local rank = 1

  --for name, rating in prefs:gmatch('([^/]+)/([^ ]+)') do
  --  prefs_table[rank] = {
  --    name = name,
  --    rating = tonumber(rating),
  --  }
    prefs_table[0]={name="foo1" , rating=1}
    prefs_table[1]={name="foo2" , rating=2}

    qty = 9999
    rank = rank + 1
  -- end

  return {
    qty = tonumber(qty),
    prefs = prefs_table,
    comment = nil,
    orderedlist = true
  }
end

function p.prefs_line_json(prefsline)
	data = p.parse_prefs_line(prefsline)
	return mw.text.jsonEncode(data)
end


function p.get_data(frame)
	-- copied and adapted from 
	--   https://en.wikipedia.org/wiki/Module:Format_TemplateData
    -- local title, s = mw.title.new(tostring(datapage))
	local title = mw.title.new(frame.args[1])
	local s = title:getContent()
    local i, j = s:find( "<electowidget>", 1, true )
    local r
    if i then
        local k = s:find( "</electowidget>", j, true )
        if k then
           r = mw.text.trim( s:sub( j + 1,  k - 1 ) )
        end
    end
    return r
end -- find()

return p