Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
WestCoastSwing
/
RelativePlacement
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
b7f65896
...
b7f658961d510cbfc5dba721f592596abe3a3b06
authored
2016-12-07 19:44:08 +0100
by
Vincent Peybernes
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
#9
Prepare publish - add README
1 parent
915a7f71
Pipeline
#23
for
b7f65896
passed
in 52 seconds
Changes
2
Pipelines
1
Builds
3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletions
README.md
lib/relative-placement.js
README.md
0 → 100644
View file @
b7f6589
# RelativePlacementJS
This library provide an placement system with the relative placement algorithm used in
West Coast Swing dance competitions.
## Understading relative placement
Relative placement is a placement system where electors (judges) provide there own placement
of each candidates.
The algorithm consist to search for each place a majority of votes for a candidate at this
placement or a greater placement.
You can refer to this explain from boogiebythebay.org for all the details.
## Get RelativePlacementJS
```
shell
npm install relative-placement-js --save
```
With node:
```
javascript
var
RelativePlacement
=
require
(
'relative-placement-js'
);
```
With browser:
```
html
<script
src=
"{BASE_PATH}/node_modules/relative-placement-js/dist/relative-placement.js"
></script>
<!-- Or the original ES6 sources -->
<script
src=
"{BASE_PATH}/node_modules/relative-placement-js/lib/relative-placement.js"
></script>
```
With AngularJS:
```
javascript
angular
.
module
(
'myApp'
,
[
'relative-placement-js'
]).
controller
(
'MyCtrl'
,
[
'$scope'
,
'RelativePlacement'
,
function
(
$scope
,
RelativePlacement
){
}
]);
```
## Use RelativePlacementJS
```
javascript
var
contest
=
new
RelativePlacement
();
contest
.
addCandidates
([
'A'
,
'B'
,
'C'
]);
contest
.
addCandidate
(
'D'
);
contest
.
addVote
([
'A'
,
'B'
,
'C'
,
'D'
]);
contest
.
addVotes
([
[
'A'
,
'B'
,
'C'
,
'D'
],
[
'A'
,
'C'
,
'B'
,
'D'
],
[
'A'
,
'B'
,
'D'
,
'C'
],
[
'B'
,
'A'
,
'C'
,
'D'
],
[
'B'
,
'A'
,
'D'
,
'C'
]
]);
var
result
=
contest
.
getResult
();
// return ['A','B','C','D'];
```
\ No newline at end of file
lib/relative-placement.js
View file @
b7f6589
...
...
@@ -7,7 +7,7 @@
if
(
global
&&
module
&&
module
.
exports
)
return
module
.
exports
=
definition
();
//Browser export
if
(
window
){
if
(
angular
&&
angular
.
version
.
major
==
1
)
return
angular
.
module
(
'relative
Placement
'
).
factory
(
'RelativePlacement'
,
definition
);
if
(
angular
&&
angular
.
version
.
major
==
1
)
return
angular
.
module
(
'relative
-placement-js
'
).
factory
(
'RelativePlacement'
,
definition
);
if
(
requirejs
)
return
define
(
definition
());
window
.
RelativePlacement
=
definition
();
...
...
Please
register
or
sign in
to post a comment