#9 Prepare publish - add README
Showing
2 changed files
with
61 additions
and
1 deletions
README.md
0 → 100644
1 | # RelativePlacementJS | ||
2 | |||
3 | This library provide an placement system with the relative placement algorithm used in | ||
4 | West Coast Swing dance competitions. | ||
5 | |||
6 | ## Understading relative placement | ||
7 | |||
8 | Relative placement is a placement system where electors (judges) provide there own placement | ||
9 | of each candidates. | ||
10 | |||
11 | The algorithm consist to search for each place a majority of votes for a candidate at this | ||
12 | placement or a greater placement. | ||
13 | |||
14 | You can refer to this explain from boogiebythebay.org for all the details. | ||
15 | |||
16 | ## Get RelativePlacementJS | ||
17 | ```shell | ||
18 | npm install relative-placement-js --save | ||
19 | ``` | ||
20 | With node: | ||
21 | ```javascript | ||
22 | var RelativePlacement = require('relative-placement-js'); | ||
23 | ``` | ||
24 | |||
25 | With browser: | ||
26 | ```html | ||
27 | <script src="{BASE_PATH}/node_modules/relative-placement-js/dist/relative-placement.js"></script> | ||
28 | <!-- Or the original ES6 sources --> | ||
29 | <script src="{BASE_PATH}/node_modules/relative-placement-js/lib/relative-placement.js"></script> | ||
30 | ``` | ||
31 | |||
32 | With AngularJS: | ||
33 | ```javascript | ||
34 | angular.module('myApp', ['relative-placement-js']).controller('MyCtrl', [ | ||
35 | '$scope', 'RelativePlacement', | ||
36 | function($scope, RelativePlacement){ | ||
37 | |||
38 | } | ||
39 | ]); | ||
40 | ``` | ||
41 | |||
42 | ## Use RelativePlacementJS | ||
43 | |||
44 | ```javascript | ||
45 | var contest = new RelativePlacement(); | ||
46 | |||
47 | contest.addCandidates(['A','B','C']); | ||
48 | contest.addCandidate('D'); | ||
49 | |||
50 | contest.addVote(['A','B','C','D']); | ||
51 | contest.addVotes([ | ||
52 | ['A','B','C','D'], | ||
53 | ['A','C','B','D'], | ||
54 | ['A','B','D','C'], | ||
55 | ['B','A','C','D'], | ||
56 | ['B','A','D','C'] | ||
57 | ]); | ||
58 | |||
59 | var result = contest.getResult(); // return ['A','B','C','D']; | ||
60 | ``` | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | if(global && module && module.exports) return module.exports = definition(); | 7 | if(global && module && module.exports) return module.exports = definition(); |
8 | //Browser export | 8 | //Browser export |
9 | if(window){ | 9 | if(window){ |
10 | if(angular && angular.version.major == 1) return angular.module('relativePlacement').factory('RelativePlacement', definition); | 10 | if(angular && angular.version.major == 1) return angular.module('relative-placement-js').factory('RelativePlacement', definition); |
11 | if(requirejs) return define(definition()); | 11 | if(requirejs) return define(definition()); |
12 | 12 | ||
13 | window.RelativePlacement = definition(); | 13 | window.RelativePlacement = definition(); | ... | ... |
-
Please register or sign in to post a comment