├── .gitignore ├── Demo.gif ├── LICENSE ├── README.md ├── Source code ├── Candidate │ ├── LICENSE │ ├── README.md │ ├── bs-config.json │ ├── build-log │ ├── build │ │ └── contracts │ │ │ ├── Candidate.json │ │ │ ├── Election.json │ │ │ └── Migrations.json │ ├── contracts │ │ ├── .gitkeep │ │ ├── Candidate.sol │ │ └── Migrations.sol │ ├── go-ipfs │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build-log │ │ ├── install.sh │ │ └── ipfs.exe │ ├── install.sh │ ├── ipfs.exe │ ├── migrations │ │ ├── 1_initial_migration.js │ │ └── 2_deploy_contracts.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── chart2.html │ │ ├── css │ │ │ ├── bootstrap.min.css │ │ │ ├── bootstrap.min.css.map │ │ │ └── voter.css │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── index.html │ │ ├── js │ │ │ ├── app.js │ │ │ ├── bootstrap.min.js │ │ │ ├── truffle-contract.js │ │ │ └── web3.min.js │ │ ├── party.JPG │ │ └── test.JPG │ ├── test │ │ ├── .gitkeep │ │ └── election.js │ └── truffle-config.js ├── Voter_centralized │ ├── app.js │ ├── controllers │ │ ├── control.js │ │ └── sha.js │ ├── img │ │ ├── party.JPG │ │ └── test.JPG │ ├── models │ │ └── voters.js │ ├── package-lock.json │ ├── package.json │ ├── public │ │ └── assests │ │ │ ├── reuslt.css │ │ │ ├── styles.css │ │ │ └── voter.css │ └── views │ │ ├── register.ejs │ │ ├── result.ejs │ │ └── upform.ejs ├── election-master │ ├── LICENSE │ ├── README.md │ ├── bs-config.json │ ├── build-log │ ├── build │ │ └── contracts │ │ │ ├── Election.json │ │ │ └── Migrations.json │ ├── contracts │ │ ├── .gitkeep │ │ ├── Election.sol │ │ └── Migrations.sol │ ├── go-ipfs │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build-log │ │ ├── install.sh │ │ └── ipfs.exe │ ├── install.sh │ ├── ipfs.exe │ ├── migrations │ │ ├── 1_initial_migration.js │ │ └── 2_deploy_contracts.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── chart2.html │ │ ├── css │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── index.html │ │ ├── js │ │ │ ├── app.js │ │ │ ├── bootstrap.min.js │ │ │ ├── truffle-contract.js │ │ │ └── web3.min.js │ │ ├── party.JPG │ │ └── test.JPG │ ├── test │ │ ├── .gitkeep │ │ └── election.js │ └── truffle-config.js └── package-lock.json └── evoting.jpg /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | .parcel-cache 78 | 79 | # Next.js build output 80 | .next 81 | out 82 | 83 | # Nuxt.js build / generate output 84 | .nuxt 85 | dist 86 | 87 | # Gatsby files 88 | .cache/ 89 | # Comment in the public line in if your project uses Gatsby and not Next.js 90 | # https://nextjs.org/blog/next-9-1#public-directory-support 91 | # public 92 | 93 | # vuepress build output 94 | .vuepress/dist 95 | 96 | # Serverless directories 97 | .serverless/ 98 | 99 | # FuseBox cache 100 | .fusebox/ 101 | 102 | # DynamoDB Local files 103 | .dynamodb/ 104 | 105 | # TernJS port file 106 | .tern-port 107 | 108 | # Stores VSCode versions used for testing VSCode extensions 109 | .vscode-test 110 | 111 | # yarn v2 112 | .yarn/cache 113 | .yarn/unplugged 114 | .yarn/build-state.yml 115 | .yarn/install-state.gz 116 | .pnp.* 117 | 118 | .DS_Store -------------------------------------------------------------------------------- /Demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Demo.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Priyam Shah 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | E-voting 4 |

5 | 6 |

Blockchain-based E-voting System

7 | 8 |
9 | 10 | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) 11 | 12 |

A Blockchain-based voting system that aims to address many of the problems faced in today’s elections and promises new opportunities, from securing transparency, making the voting process more accessible, affordable, and safe.

13 | 14 |
15 | 16 | ----------------------------------------- 17 | ### Inspiration 18 | 19 | * Around the time of TSEC hackathon, the news was filled with articles and debates claiming that the voting machines were rigged in the recently conducted provincial elections in the state of UP in India. Ballot and EVM are the only methods that have been used for voting for years now, and each has its own drawbacks. 20 | 21 | * We felt that it is imperative to develop a better mechanism for voting. So during the hackathon, we developed a blockchain-based E-voting system. This system retains the benefits of the traditional methods such as anonymity of voters, enables real-time vote counting, and decentralized control, which prevents unfair practices. 22 | 23 | ------------------------------------------ 24 | ### Features 25 | 26 | - `Decentralized Control` : Lesser chance of unfair practices and errors due to **Immutability** and **Transparency** 27 | - `Reduced complications` : As compared to EVM or Ballot, complications are reduced 28 | - `Faster Results` : Enables real-time vote counting 29 | - `Retains benefits of the traditional systems` : Ensures anonymity of voters and provides improved security 30 | 31 | ------------------------------------------ 32 | ### Demo 33 |

34 | 35 |

36 | 37 | 38 | ------------------------------------------ 39 | ### File Structure 40 | 41 | - `Voter_centralized` : Contains a voter registration system which generated private and public keys for voters. 42 | - `election-master` : Contains a decentralized application for voting system. 43 | - `Candidate` : Contains a decentralized application for candidate registeration. 44 | 45 | ------------------------------------------ 46 | ### Installation 47 | 48 | * Clone the Repository 49 | ```sh 50 | $ git clone https://github.com/Hash-It-Out/EVoting 51 | ``` 52 | * Install dependencies 53 | ```sh 54 | $ npm install 55 | ``` 56 | 57 | ------------------------------------------ 58 | ### Note 59 | - This project was done in less than `24 hours with minimal pre-preparation` at TSEC hackathon. 60 | 61 | ------------------------------------------ 62 | ### Contributors 63 | 64 | Mihir Gandhi - [mihir-m-gandhi](https://github.com/mihir-m-gandhi) 65 | 66 | Priyam Shah- [priyamshah112](https://github.com/priyamshah112) 67 | 68 | Devansh Solanki - [devanshslnk](https://github.com/devanshslnk) 69 | 70 | Mihir Shah - [mihir-ms](https://github.com/mihir-ms) 71 | 72 | ------------------------------------------ 73 | ### License 74 | This project is licensed under the MIT - see the [LICENSE](./LICENSE) file for details. 75 | -------------------------------------------------------------------------------- /Source code/Candidate/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Juan Batiz-Benet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Source code/Candidate/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Election - DAPP Tutorial 3 | Build your first decentralized application, or Dapp, on the Ethereum Network with this tutorial! 4 | 5 | **Full Free Video Tutorial:** 6 | https://youtu.be/3681ZYbDSSk 7 | 8 | 9 | Follow the steps below to download, install, and run this project. 10 | 11 | ## Dependencies 12 | Install these prerequisites to follow along with the tutorial. See free video tutorial or a full explanation of each prerequisite. 13 | - NPM: https://nodejs.org 14 | - Truffle: https://github.com/trufflesuite/truffle 15 | - Ganache: http://truffleframework.com/ganache/ 16 | - Metamask: https://metamask.io/ 17 | 18 | 19 | ## Step 1. Clone the project 20 | `git clone https://github.com/dappuniversity/election` 21 | 22 | ## Step 2. Install dependencies 23 | ``` 24 | $ cd election 25 | $ npm install 26 | ``` 27 | ## Step 3. Start Ganache 28 | Open the Ganache GUI client that you downloaded and installed. This will start your local blockchain instance. See free video tutorial for full explanation. 29 | 30 | 31 | ## Step 4. Compile & Deploy Election Smart Contract 32 | `$ truffle migrate --reset` 33 | You must migrate the election smart contract each time your restart ganache. 34 | 35 | ## Step 5. Configure Metamask 36 | See free video tutorial for full explanation of these steps: 37 | - Unlock Metamask 38 | - Connect metamask to your local Etherum blockchain provided by Ganache. 39 | - Import an account provided by ganache. 40 | 41 | ## Step 6. Run the Front End Application 42 | `$ npm run dev` 43 | Visit this URL in your browser: http://localhost:3000 44 | 45 | If you get stuck, please reference the free video tutorial. 46 | 47 | -------------------------------------------------------------------------------- /Source code/Candidate/bs-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": { 3 | "baseDir": ["./src", "./build/contracts"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Source code/Candidate/build-log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/build-log -------------------------------------------------------------------------------- /Source code/Candidate/contracts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/contracts/.gitkeep -------------------------------------------------------------------------------- /Source code/Candidate/contracts/Candidate.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.2; 2 | 3 | contract Candidate{ 4 | // Model a Candidate 5 | struct Candidate1 { 6 | uint id; 7 | string name; 8 | uint age; 9 | string voterId; 10 | uint aadhar; 11 | bool criminalRecord; 12 | bool itr; 13 | } 14 | 15 | // Store accounts that have voted 16 | // mapping(address => bool) public voters; 17 | // Store Candidates 18 | // Fetch Candidate 19 | 20 | mapping(address => bool) public addedCandidates; 21 | 22 | mapping(uint => Candidate1) public candidates; //declaring it public gives us a getter function by default 23 | // Store Candidates Count 24 | uint public candidatesCount; 25 | 26 | // voted event 27 | /*event addedEvent ( 28 | uint indexed _candidateid 29 | );*/ 30 | 31 | function Candidate () public { 32 | addCandidate("Candidate 1", 26, "r5tctvuyg", 5464, true, true); 33 | addCandidate("Candidate 2", 28, "rdfgctvufdgdfgyg", 864185548, true, true); 34 | } 35 | 36 | function addCandidate (string _name, uint _age, string _voterId, uint _aadhar, bool _criminalRecord, bool _itr) public returns (bool){ //available only to contract, not other accounts 37 | require(_criminalRecord && _itr); 38 | candidatesCount ++; 39 | candidates[candidatesCount] = Candidate1(candidatesCount, _name, _age, _voterId, _aadhar, _criminalRecord, _itr); 40 | return true; 41 | } 42 | 43 | // function setStore(string _value) public { 44 | // aadhar = _value; 45 | // } 46 | 47 | // function getAadhar() public view returns (string){ 48 | // return Candidate1.aadhar.toString(); 49 | // } 50 | 51 | /*function isCandidate (uint _aadhar) public returns (bool) { //solidity allows sending meta data, msg.sender gives the account from which the function call is sent 52 | // trigger voted event 53 | uint flag=1; 54 | uint temp2 = _aadhar; 55 | for(uint i=1;i<=candidatesCount;i++) 56 | { 57 | uint temp = candidates[i].aadhar; 58 | if(temp == temp2) 59 | { 60 | flag=0; 61 | } 62 | } 63 | if(flag==1) 64 | { 65 | return true; 66 | } 67 | else{ 68 | return false; 69 | }*/ 70 | 71 | /*function add (uint _candidateId) public { //solidity allows sending meta data, msg.sender gives the account from which the function call is sent 72 | // require that they haven't voted before 73 | require(!candidates[msg.sender]); 74 | 75 | // require a valid candidate 76 | require(_candidateId > 0 && _candidateId <= candidatesCount); 77 | 78 | // record that voter has voted 79 | candidates[msg.sender] = true; 80 | 81 | // update candidate vote Count 82 | candidates[_candidateId].voteCount ++; 83 | 84 | // trigger voted event 85 | addedEvent(_candidateId); 86 | }*/ 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Source code/Candidate/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.2; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | function Migrations() { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source code/Candidate/go-ipfs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Juan Batiz-Benet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Source code/Candidate/go-ipfs/README.md: -------------------------------------------------------------------------------- 1 | # ipfs commandline tool 2 | 3 | This is the [ipfs](http://ipfs.io) commandline tool. It contains a full ipfs node. 4 | 5 | ## Install 6 | 7 | To install it, move the binary somewhere in your `$PATH`: 8 | 9 | ```sh 10 | sudo mv ipfs /usr/local/bin/ipfs 11 | ``` 12 | 13 | Or run `sudo ./install.sh` which does this for you. 14 | 15 | ## Usage 16 | 17 | First, you must initialize your local ipfs node: 18 | 19 | ```sh 20 | ipfs init 21 | ``` 22 | 23 | This will give you directions to get started with ipfs. 24 | You can always get help with: 25 | 26 | ```sh 27 | ipfs --help 28 | ``` 29 | -------------------------------------------------------------------------------- /Source code/Candidate/go-ipfs/build-log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/go-ipfs/build-log -------------------------------------------------------------------------------- /Source code/Candidate/go-ipfs/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Installation script for ipfs. It tries to move $bin in one of the 4 | # directories stored in $binpaths. 5 | 6 | INSTALL_DIR=$(dirname $0) 7 | 8 | bin="$INSTALL_DIR/ipfs" 9 | binpaths="/usr/local/bin /usr/bin" 10 | 11 | # This variable contains a nonzero length string in case the script fails 12 | # because of missing write permissions. 13 | is_write_perm_missing="" 14 | 15 | for binpath in $binpaths; do 16 | if mv "$bin" "$binpath/$bin" 2> /dev/null; then 17 | echo "Moved $bin to $binpath" 18 | exit 0 19 | else 20 | if [ -d "$binpath" -a ! -w "$binpath" ]; then 21 | is_write_perm_missing=1 22 | fi 23 | fi 24 | done 25 | 26 | echo "We cannot install $bin in one of the directories $binpaths" 27 | 28 | if [ -n "$is_write_perm_missing" ]; then 29 | echo "It seems that we do not have the necessary write permissions." 30 | echo "Perhaps try running this script as a privileged user:" 31 | echo 32 | echo " sudo $0" 33 | echo 34 | fi 35 | 36 | exit 1 37 | -------------------------------------------------------------------------------- /Source code/Candidate/go-ipfs/ipfs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/go-ipfs/ipfs.exe -------------------------------------------------------------------------------- /Source code/Candidate/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Installation script for ipfs. It tries to move $bin in one of the 4 | # directories stored in $binpaths. 5 | 6 | INSTALL_DIR=$(dirname $0) 7 | 8 | bin="$INSTALL_DIR/ipfs" 9 | binpaths="/usr/local/bin /usr/bin" 10 | 11 | # This variable contains a nonzero length string in case the script fails 12 | # because of missing write permissions. 13 | is_write_perm_missing="" 14 | 15 | for binpath in $binpaths; do 16 | if mv "$bin" "$binpath/$bin" 2> /dev/null; then 17 | echo "Moved $bin to $binpath" 18 | exit 0 19 | else 20 | if [ -d "$binpath" -a ! -w "$binpath" ]; then 21 | is_write_perm_missing=1 22 | fi 23 | fi 24 | done 25 | 26 | echo "We cannot install $bin in one of the directories $binpaths" 27 | 28 | if [ -n "$is_write_perm_missing" ]; then 29 | echo "It seems that we do not have the necessary write permissions." 30 | echo "Perhaps try running this script as a privileged user:" 31 | echo 32 | echo " sudo $0" 33 | echo 34 | fi 35 | 36 | exit 1 37 | -------------------------------------------------------------------------------- /Source code/Candidate/ipfs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/ipfs.exe -------------------------------------------------------------------------------- /Source code/Candidate/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /Source code/Candidate/migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | var Candidate = artifacts.require("./Candidate.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Candidate); 5 | }; 6 | -------------------------------------------------------------------------------- /Source code/Candidate/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pet-shop", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /Source code/Candidate/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pet-shop", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "truffle.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "dev": "lite-server", 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "devDependencies": {} 16 | } 17 | -------------------------------------------------------------------------------- /Source code/Candidate/src/chart2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Voting Results 5 | 6 | 7 | 8 | 9 |

Voting Results

10 |
11 |
12 | 13 |
14 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 126 | 127 | -------------------------------------------------------------------------------- /Source code/Candidate/src/css/voter.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background:rgba(74, 189, 172,1) !important; 3 | } 4 | 5 | h2{ 6 | color: #fff !important; 7 | } 8 | .form { 9 | border-radius: 5px; 10 | background-color: #f2f2f2; 11 | padding: 20px; 12 | } 13 | .but{ 14 | 15 | text-align: center; 16 | 17 | } 18 | .but1{ 19 | background-color: #fc4a1a; 20 | color: #fff; 21 | } 22 | .but1:hover { 23 | background-color: #fc1919; 24 | } 25 | 26 | img { 27 | display: block; 28 | margin-left: auto; 29 | margin-right: auto; 30 | width: 50%; 31 | border-radius: 50%; 32 | } 33 | 34 | #snackbar { 35 | visibility: hidden; 36 | background-color: #333; 37 | color: #fff; 38 | text-align: center; 39 | border-radius: 2px; 40 | padding: 16px; 41 | position: fixed; 42 | } 43 | 44 | #snackbar.show { 45 | visibility: visible; 46 | 47 | } 48 | .form { 49 | border-radius: 5px; 50 | background-color: #f2f2f2; 51 | padding: 20px; 52 | } 53 | .but{ 54 | 55 | text-align: center; 56 | } 57 | img { 58 | display: block; 59 | margin-left: auto; 60 | margin-right: auto; 61 | width: 50%; 62 | border-radius: 50%; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Source code/Candidate/src/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Source code/Candidate/src/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Source code/Candidate/src/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Source code/Candidate/src/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Source code/Candidate/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Candidate Registration 13 | 256 | 257 | 258 |
259 |
260 |

261 |

Add Candidate

262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 | Avatar 270 |
271 | 272 |
273 | 274 | 275 |
276 |
277 | 278 | 279 |
280 |
281 | 282 | 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 |

Congrats! You are successfully registered as a candidate.

339 |
340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | -------------------------------------------------------------------------------- /Source code/Candidate/src/js/app.js: -------------------------------------------------------------------------------- 1 | var candidatesResults; 2 | 3 | App = { 4 | web3Provider: null, 5 | contracts: {}, 6 | account: '0x0', 7 | hasVoted: false, 8 | 9 | init: function() { 10 | return App.initWeb3(); 11 | }, 12 | 13 | initWeb3: function() { 14 | // TODO: refactor conditional 15 | if (typeof web3 !== 'undefined') { 16 | // If a web3 instance is already provided by Meta Mask. 17 | App.web3Provider = web3.currentProvider; 18 | web3 = new Web3(web3.currentProvider); 19 | } else { 20 | // Specify default instance if no web3 instance provided 21 | App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545'); 22 | web3 = new Web3(App.web3Provider); 23 | } 24 | return App.initContract(); 25 | }, 26 | 27 | initContract: function() { 28 | $.getJSON("Candidate.json", function(election) { 29 | // Instantiate a new truffle contract from the artifact 30 | App.contracts.Candidate = TruffleContract(election); 31 | // Connect provider to interact with contract 32 | App.contracts.Candidate.setProvider(App.web3Provider); 33 | 34 | // App.listenForEvents(); 35 | 36 | return App.render(); 37 | }); 38 | }, 39 | 40 | // // Listen for events emitted from the contract 41 | // listenForEvents: function() { 42 | 43 | // App.contracts.Candidate.deployed().then(function(instance) { 44 | // // Restart Chrome if you are unable to receive this event 45 | // // This is a known issue with Metamask 46 | // // https://github.com/MetaMask/metamask-extension/issues/2393 47 | // instance.votedEvent({}, { 48 | // fromBlock: 0, 49 | // toBlock: 'latest' 50 | // }).watch(function(error, event) { 51 | // console.log("event triggered", event) 52 | // // Reload when a new vote is recorded 53 | 54 | // }); 55 | // }); 56 | // return App.render(); 57 | // }, 58 | 59 | render: function() { 60 | var candidateInstance; 61 | var done=$("#done"); 62 | var main=$("#main"); 63 | main.show(); 64 | done.hide(); 65 | 66 | // Load account data 67 | web3.eth.getCoinbase(function(err, account) { 68 | if (err === null) { 69 | App.account = account; 70 | $("#accountAddress").html("Your Account: " + account); 71 | } 72 | }); 73 | 74 | // Load contract data 75 | App.contracts.Candidate.deployed().then(function(instance) { //listing candidates 76 | candidateInstance = instance; 77 | return candidateInstance.candidatesCount(); 78 | }).then(function(candidatesCount) { 79 | candidatesResults = []; 80 | candidatesResults.splice(0,candidatesResults.length); 81 | 82 | for (var i = 1; i <= candidatesCount; i++) { 83 | candidateInstance.candidates(i).then(function(candidate) { 84 | // var id = candidate[0]; 85 | // var name = candidate[1]; 86 | 87 | var aadhar = candidate[4]; 88 | // Render candidate Result 89 | candidatesResults.push(aadhar); 90 | console.log(aadhar); 91 | 92 | }); 93 | } 94 | 95 | }).then(function(isCandidate) { 96 | if(isCandidate) { 97 | main.hide(); 98 | done.show(); 99 | } 100 | else 101 | { 102 | main.show(); 103 | done.hide(); 104 | } 105 | }).catch(function(error) { 106 | console.warn(error); 107 | }); 108 | }, 109 | 110 | 111 | 112 | 113 | AddCandidate: function() { 114 | var candidateName = $('#name').val(); 115 | var candidateAge = $('#age').val(); 116 | var candidateGender = $('#gen').val(); 117 | var candidateVoterId = $('#vtrid').val(); 118 | var candidateAdharId = $('#adrid').val(); 119 | var candidateCrimeFile = $('#cmf').val(); 120 | var candidateItrFile = $('#itr').val(); 121 | var candidateimgFile = $('#imgf').val(); 122 | 123 | // console.log(candidateName + " " + candidateAge + " " + candidateGender + " " + candidateVoterId + " " + candidateAdharId + " " + candidateCrimeFile + " " + candidateItrFile + " " + candidateimgFile); 124 | 125 | App.contracts.Candidate.deployed().then(function(instance) { 126 | console.log("in"); 127 | var flag=true; 128 | for(var i=0;i<=candidatesResults.length;i++){ 129 | if (candidatesResults[i] === candidateAdharId ) 130 | flag=false; 131 | } 132 | if (flag == false){ 133 | alert("Candidate Already Registered"); 134 | } 135 | else{ 136 | return instance.addCandidate(candidateName,candidateAge,candidateVoterId,candidateAdharId,true,true, { from: App.account }); 137 | } 138 | }).then(function(result) { 139 | var done = $("#done"); 140 | $("#main").hide(); 141 | done.show(); 142 | }).catch(function(err) { 143 | console.error(err); 144 | }); 145 | 146 | }, 147 | }; 148 | 149 | // loadJs: function() 150 | 151 | $(function() { 152 | $(window).load(function() { 153 | App.init(); 154 | }); 155 | }); 156 | -------------------------------------------------------------------------------- /Source code/Candidate/src/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.7 (http://getbootstrap.com) 3 | * Copyright 2011-2016 Twitter, Inc. 4 | * Licensed under the MIT license 5 | */ 6 | if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -------------------------------------------------------------------------------- /Source code/Candidate/src/party.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/party.JPG -------------------------------------------------------------------------------- /Source code/Candidate/src/test.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/src/test.JPG -------------------------------------------------------------------------------- /Source code/Candidate/test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Candidate/test/.gitkeep -------------------------------------------------------------------------------- /Source code/Candidate/test/election.js: -------------------------------------------------------------------------------- 1 | var Candidate = artifacts.require("./Candidate.sol"); 2 | 3 | contract("Candidate", function(accounts) { 4 | var candidateInstance; 5 | 6 | it("initializes with two candidates", function() { //mocha 7 | return Candidate.deployed().then(function(instance) { 8 | return instance.candidatesCount(); 9 | }).then(function(count) { 10 | assert.equal(count, 2); //chai 11 | }); 12 | }); 13 | 14 | it("it initializes the candidates with the correct values", function() { 15 | Candidate.deployed().then(function(instance) { 16 | return instance.candidatesCount(); 17 | }).then(function(count) { 18 | for (var i = 1; i <= count; i++) { 19 | candidateInstance.candidates(i).then(function(candidate) { 20 | assert.equal(candidate[0], i, "contains the correct id"); 21 | assert.equal(candidate[1], "Candidate "+ i, "contains the correct name"); 22 | assert.ok(candidate[2]>=25, "age greater than 25"); 23 | }); 24 | } 25 | }); 26 | }); 27 | 28 | // return Candidate.deployed().then(function(instance) { 29 | // candidateInstance = instance; 30 | 31 | // for(var i=1;i<=candidatesCount();i++){ 32 | // return candidateInstance.candidates(i); 33 | // .then(function(candidate) { 34 | // assert.equal(candidate[0], i, "contains the correct id"); 35 | // assert.equal(candidate[1], "Candidate "+ i, "contains the correct name"); 36 | // assert.ok(candidate[2]>=25, "age greater than 25"); 37 | // } 38 | 39 | 40 | // for (var i = 1; i <= 1; i++) { 41 | // candidateInstance.candidates(i).then(function(candidate) { 42 | // assert.equal(candidate[0], i, "contains the correct id"); 43 | // assert.equal(candidate[1], "Candidate "+ i, "contains the correct name"); 44 | // assert.ok(candidate[2]>=25, "age greater than 25"); 45 | // }); 46 | // } 47 | 48 | 49 | 50 | // it("allows a voter to cast a vote", function() { 51 | // return Election.deployed().then(function(instance) { 52 | // electionInstance = instance; 53 | // candidateId = 1; 54 | // return electionInstance.vote(candidateId, { from: accounts[0] }); 55 | // }).then(function(receipt) { 56 | // assert.equal(receipt.logs.length, 1, "an event was triggered"); 57 | // assert.equal(receipt.logs[0].event, "votedEvent", "the event type is correct"); 58 | // assert.equal(receipt.logs[0].args._candidateId.toNumber(), candidateId, "the candidate id is correct"); 59 | // return electionInstance.voters(accounts[0]); 60 | // }).then(function(voted) { 61 | // assert(voted, "the voter was marked as voted"); 62 | // return electionInstance.candidates(candidateId); 63 | // }).then(function(candidate) { 64 | // var voteCount = candidate[2]; 65 | // assert.equal(voteCount, 1, "increments the candidate's vote count"); 66 | // }) 67 | // }); 68 | 69 | // it("throws an exception for invalid candidature", function() { 70 | // return Candidate.deployed().then(function(instance) { 71 | // candidateInstance = instance; 72 | // return candidateInstance.addCandidate("Priyam",12,"gyfuifghs","ygfyuaef",true,true, { from: accounts[1] }) 73 | // }).then(assert.fail).catch(function(error) { 74 | // assert(error.message.indexOf('revert') >= 0, "error message must contain revert"); 75 | // return electionInstance; 76 | // }).then(function(candidate) { 77 | 78 | // var voteCount = candidate1[2]; 79 | // assert.equal(voteCount, 1, "candidate 1 did not receive any votes"); 80 | // return electionInstance.candidates(2); 81 | // }) 82 | // }); 83 | 84 | // it("throws an exception for double candidature", function() { 85 | // return Candidate.deployed().then(function(instance) { 86 | // candidateInstance = instance; 87 | // candidateId = 2; 88 | // candidateInstance.add(candidateId,"Priyam",26,"hgfds","adsfh",true,true, { from: accounts[1] }); 89 | // return electionInstance.candidates(candidateId); 90 | // }).then(function(candidate) { 91 | // var voteCount = candidate[2]; 92 | // assert.equal(voteCount, 1, "accepts first vote"); 93 | // // Try to vote again 94 | // return electionInstance.vote(candidateId, { from: accounts[1] }); 95 | // }).then(assert.fail).catch(function(error) { 96 | // assert(error.message.indexOf('revert') >= 0, "error message must contain revert"); 97 | // return electionInstance.candidates(1); 98 | // }).then(function(candidate1) { 99 | // var voteCount = candidate1[2]; 100 | // assert.equal(voteCount, 1, "candidate 1 did not receive any votes"); 101 | // return electionInstance.candidates(2); 102 | // }).then(function(candidate2) { 103 | // var voteCount = candidate2[2]; 104 | // assert.equal(voteCount, 1, "candidate 2 did not receive any votes"); 105 | // }); 106 | // }); 107 | }); -------------------------------------------------------------------------------- /Source code/Candidate/truffle-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // for more about customizing your Truffle configuration! 4 | networks: { 5 | development: { 6 | host: "127.0.0.1", 7 | port: 7545, 8 | network_id: "*" // Match any network id 9 | } 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/app.js: -------------------------------------------------------------------------------- 1 | var express=require('express'); 2 | var bparser=require('body-parser'); 3 | var control=require('./controllers/control'); 4 | 5 | var app=express(); 6 | 7 | //set up template engine 8 | app.set('view engine','ejs'); 9 | //use static files 10 | app.use(express.static('./public')); 11 | app.get("/",function(req,res){ 12 | res.send("working"); 13 | }); 14 | control(app); 15 | 16 | app.listen(3000); 17 | //fire controllers which handles the routing 18 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/controllers/control.js: -------------------------------------------------------------------------------- 1 | var bparser=require('body-parser'); 2 | var sha=require("./sha.js"); 3 | var path=require("path"); 4 | var fs=require("fs-extra"); 5 | var busboy=require("connect-busboy"); 6 | var Voters=require("../models/voters"); 7 | var formidable=require("formidable"); 8 | module.exports=function(app){ 9 | // var arr=[{item:'value1'},{item:'value2'},{item:'value3'}] 10 | app.use(busboy()); 11 | 12 | app.use(bparser.urlencoded({extended:false})); 13 | app.get('/signup',function(req,res){ 14 | res.render("register",{message:""}); 15 | }); 16 | 17 | 18 | app.post('/signup',function(req,res){ 19 | // console.log(req.body); 20 | var fname=req.body.fname; 21 | var lname=req.body.lname; 22 | var dob=req.body.dob; 23 | var gender=req.body.gender; 24 | var address=req.body.address; 25 | var adhar=req.body.adhar; 26 | if(!fname || !lname){ 27 | 28 | res.render('register',{message:"Fill in all the details"}); 29 | 30 | }else{ 31 | 32 | Voters.findOne({adhar:adhar}).then(function(voter){ 33 | if(!voter) 34 | { var newVoter={fname:fname,lname:lname,dob:dob,gender:gender,address:address,adhar:adhar}; 35 | 36 | var new_voter=new Voters(newVoter); 37 | new_voter.save(function(err){ 38 | console.log(err); 39 | }); 40 | 41 | var x=sha.SHA256(adhar); 42 | console.log(x); 43 | res.render("result",{message:x}); 44 | 45 | 46 | }else{ 47 | res.render("register",{message:"you have already registered"}); 48 | } 49 | }).catch(function(error){ 50 | console.log("error",error); 51 | }); 52 | } 53 | 54 | }); 55 | 56 | // app.get("/upload",function(req,res){ 57 | 58 | // res.render("upform",{message:""}); 59 | 60 | 61 | // }); 62 | // app.post("/upload",function(req,res){ 63 | // console.log(1); 64 | // var fstream; 65 | // req.pipe(req.busboy); 66 | // req.busboy.on("file",function(fieldname,file,filename){ 67 | // console.log("Uploading: "+filename); 68 | // fstream=fs.createWriteStream(__dirname+"/img/"+filename); 69 | // file.pipe(fstream); 70 | // fstream.on('close',function(){ 71 | // console.log("file uploaded"+filename); 72 | // res.redirect("/"); 73 | // }); 74 | 75 | 76 | 77 | // }); 78 | 79 | // }); 80 | 81 | // app.post('/upload', function (req, res){ 82 | 83 | // var form = new formidable.IncomingForm(); 84 | // var dict={"hello":"q"}; 85 | // form.parse(req); 86 | 87 | // form.on('fileBegin', function (name, file){ 88 | 89 | // file.path ='./img/' + file.name; 90 | // console.log(file.name); 91 | // dict[name]=file.path; 92 | // console.log(name); 93 | // store(dict); 94 | // // dict={"name":file.name,"second":file.name}; 95 | // // console.log(dict); 96 | 97 | // }); 98 | // var store=function(dict){ 99 | // if(Object.keys(dict).length===3){ 100 | // console.log(dict); 101 | // } 102 | // } 103 | // form.on('file', function (name, file){ 104 | // console.log('Uploaded ' + file.name); 105 | 106 | // }); 107 | 108 | // res.redirect("/"); 109 | // // return res.json(200, { 110 | // // result: 'Upload Success' 111 | // // }); 112 | // }); 113 | 114 | }; 115 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/controllers/sha.js: -------------------------------------------------------------------------------- 1 | module.exports.SHA256=function (s){ 2 | var chrsz = 8; 3 | var hexcase = 0; 4 | function safe_add (x, y) { 5 | var lsw = (x & 0xFFFF) + (y & 0xFFFF); 6 | var msw = (x >> 16) + (y >> 16) + (lsw >> 16); 7 | return (msw << 16) | (lsw & 0xFFFF); 8 | } 9 | function S (X, n) { return ( X >>> n ) | (X << (32 - n)); } 10 | function R (X, n) { return ( X >>> n ); } 11 | function Ch(x, y, z) { return ((x & y) ^ ((~x) & z)); } 12 | function Maj(x, y, z) { return ((x & y) ^ (x & z) ^ (y & z)); } 13 | function Sigma0256(x) { return (S(x, 2) ^ S(x, 13) ^ S(x, 22)); } 14 | function Sigma1256(x) { return (S(x, 6) ^ S(x, 11) ^ S(x, 25)); } 15 | function Gamma0256(x) { return (S(x, 7) ^ S(x, 18) ^ R(x, 3)); } 16 | function Gamma1256(x) { return (S(x, 17) ^ S(x, 19) ^ R(x, 10)); } 17 | function core_sha256 (m, l) { 18 | var K = new Array(0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3, 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174, 0xE49B69C1, 0xEFBE4786, 0xFC19DC6, 0x240CA1CC, 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA, 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7, 0xC6E00BF3, 0xD5A79147, 0x6CA6351, 0x14292967, 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13, 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85, 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3, 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070, 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5, 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3, 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208, 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2); 19 | var HASH = new Array(0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A, 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19); 20 | var W = new Array(64); 21 | var a, b, c, d, e, f, g, h, i, j; 22 | var T1, T2; 23 | m[l >> 5] |= 0x80 << (24 - l % 32); 24 | m[((l + 64 >> 9) << 4) + 15] = l; 25 | for ( var i = 0; i>5] |= (str.charCodeAt(i / chrsz) & mask) << (24 - i%32); 64 | } 65 | return bin; 66 | } 67 | function Utf8Encode(string) { 68 | string = string.replace(/\r\n/g,"\n"); 69 | var utftext = ""; 70 | for (var n = 0; n < string.length; n++) { 71 | var c = string.charCodeAt(n); 72 | if (c < 128) { 73 | utftext += String.fromCharCode(c); 74 | } 75 | else if((c > 127) && (c < 2048)) { 76 | utftext += String.fromCharCode((c >> 6) | 192); 77 | utftext += String.fromCharCode((c & 63) | 128); 78 | } 79 | else { 80 | utftext += String.fromCharCode((c >> 12) | 224); 81 | utftext += String.fromCharCode(((c >> 6) & 63) | 128); 82 | utftext += String.fromCharCode((c & 63) | 128); 83 | } 84 | } 85 | return utftext; 86 | } 87 | function binb2hex (binarray) { 88 | var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; 89 | var str = ""; 90 | for(var i = 0; i < binarray.length * 4; i++) { 91 | str += hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8+4)) & 0xF) + 92 | hex_tab.charAt((binarray[i>>2] >> ((3 - i%4)*8 )) & 0xF); 93 | } 94 | return str; 95 | } 96 | s = Utf8Encode(s); 97 | return binb2hex(core_sha256(str2binb(s), s.length * chrsz)); 98 | } 99 | 100 | // x=SHA256("devansh"); 101 | // console.log(x); -------------------------------------------------------------------------------- /Source code/Voter_centralized/img/party.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Voter_centralized/img/party.JPG -------------------------------------------------------------------------------- /Source code/Voter_centralized/img/test.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/Voter_centralized/img/test.JPG -------------------------------------------------------------------------------- /Source code/Voter_centralized/models/voters.js: -------------------------------------------------------------------------------- 1 | var mongoose=require('mongoose'); 2 | mongoose.connect('mongodb://localhost:27017/Evoting'); 3 | var db = mongoose.connection; 4 | db.on('error', console.error.bind(console, 'connection error:')); 5 | db.once('open', function() { 6 | // we're connected! 7 | }); 8 | 9 | 10 | 11 | 12 | var voter_schema=new mongoose.Schema({ 13 | fname:String, 14 | lname:String, 15 | gender:String, 16 | dob:Date, 17 | address:String, 18 | adhar:String 19 | 20 | 21 | 22 | }); 23 | var Voters=mongoose.model('Voters',voter_schema); 24 | 25 | module.exports=Voters; 26 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "voter_centralized", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "body-parser": "^1.18.3", 13 | "connect-busboy": "0.0.2", 14 | "cookie-parser": "^1.4.3", 15 | "ejs": "^2.6.1", 16 | "express": "^4.16.3", 17 | "express-session": "^1.15.6", 18 | "formidable": "^1.2.1", 19 | "fs-extra": "^7.0.0", 20 | "mongoose": "^5.2.17", 21 | "nodemon": "^1.18.4" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/public/assests/reuslt.css: -------------------------------------------------------------------------------- 1 | @keyframes beginOpacity { 2 | 0% { 3 | opacity:0; 4 | } 5 | 100% { 6 | opacity:1; 7 | } 8 | } 9 | 10 | @keyframes bubble { 11 | 0% { 12 | transform:scale(0); 13 | } 14 | 50% { 15 | transform:scale(1); 16 | } 17 | 100% { 18 | transform:scale(1); 19 | } 20 | } 21 | 22 | @keyframes title { 23 | 0% { 24 | opacity:0; 25 | font-size:6rem; 26 | } 27 | 25% { 28 | opacity:1; 29 | font-size:6rem; 30 | } 31 | 75% { 32 | opacity:1; 33 | font-size:6rem; 34 | } 35 | 100% { 36 | opacity:1; 37 | font-size:4.2rem; 38 | } 39 | } 40 | 41 | @keyframes thumbBubble { 42 | 0% { 43 | height:360px; 44 | margin:30px 0; 45 | transform:scale(1); 46 | } 47 | 100% { 48 | height:122px; 49 | margin:0; 50 | transform:scale(.34); 51 | } 52 | } 53 | 54 | @keyframes burst { 55 | 0% { 56 | opacity:0; 57 | transform:scale(0); 58 | } 59 | 50% { 60 | opacity:1; 61 | transform:scale(1); 62 | } 63 | 100% { 64 | opacity:0; 65 | transform:scale(2); 66 | } 67 | } 68 | 69 | @keyframes thumb { 70 | 0% { 71 | transform:scale(0) rotate(0); 72 | } 73 | 50% { 74 | transform:scale(1) rotate(-5deg); 75 | } 76 | 100% { 77 | transform:scale(1) rotate(0); 78 | } 79 | } 80 | body{ 81 | background:rgba(74, 189, 172,1) !important; 82 | } 83 | .tandc{ 84 | text-decoration: none; 85 | } 86 | .confirmationHeader { 87 | margin-top:20px; 88 | } 89 | .bodyContents { 90 | width:90%; 91 | margin:0 auto; 92 | text-align:center; 93 | } 94 | .bodyContents .contentContainer { 95 | width:30%; 96 | display:inline-block; 97 | font-size:30px; 98 | border-radius:3px; 99 | background-color:#DBF5FF; 100 | padding:30px 0; 101 | margin:.25%; 102 | } 103 | h1.confirmTitle { 104 | font-family: 'Poppins', sans-serif; 105 | font-weight:700; 106 | text-align:center; 107 | font-size:6rem; 108 | animation-name: title; 109 | animation-duration: 2s; 110 | animation-timing-function: ease-out; 111 | animation-delay: 0s; 112 | animation-iteration-count: 1; 113 | animation-fill-mode: forwards; 114 | margin:0; 115 | } 116 | .text-center .progressSteps { 117 | float:none; 118 | display:inline-block; 119 | opacity:0; 120 | animation-name: beginOpacity; 121 | animation-duration: .5s; 122 | animation-timing-function: ease-out; 123 | animation-delay: 0s; 124 | animation-iteration-count: 1; 125 | animation-fill-mode: forwards; 126 | } 127 | .confirmationHeader { 128 | text-align:center; 129 | margin-bottom:36px; 130 | } 131 | .confirmationHeader .thumbsUp { 132 | position:relative; 133 | height:360px; 134 | width:410px; 135 | text-align:center; 136 | display:inline-block; 137 | margin:30px 0; 138 | transform:scale(1); 139 | transform-origin:bottom center; 140 | animation-name: thumbBubble; 141 | animation-duration: .5s; 142 | animation-timing-function: cubic-beziercubic-bezier(0.39, 0.575, 0.565, 1); 143 | animation-delay: 1.5s; 144 | animation-iteration-count: 1; 145 | animation-fill-mode: forwards; 146 | } 147 | .confirmationHeader .thumbsUp img { 148 | display:inline-block; 149 | position:absolute; 150 | width:auto; 151 | height:100%; 152 | bottom:0; 153 | left:0; 154 | } 155 | .confirmationHeader .thumbsUp img.shadow { 156 | width:100%; 157 | height:auto; 158 | display:inline-block; 159 | opacity:0; 160 | animation-name: beginOpacity; 161 | animation-duration: .5s; 162 | animation-timing-function: ease-out; 163 | animation-delay: 1s; 164 | animation-iteration-count: 1; 165 | animation-fill-mode: forwards; 166 | } 167 | .confirmationHeader .thumbsUp img.bubble { 168 | width:100%; 169 | height:auto; 170 | transform:scale(0); 171 | transform-origin:bottom center; 172 | animation-name: bubble; 173 | animation-duration: 1s; 174 | animation-delay: 0; 175 | animation-timing-function: ease-out; 176 | animation-iteration-count: 1; 177 | animation-fill-mode: forwards; 178 | 179 | } 180 | .confirmationHeader .thumbsUp img.burst { 181 | opacity:0; 182 | left:30px; 183 | transform:scale(0); 184 | transform-origin:center center; 185 | animation-name: burst; 186 | animation-duration: .5s; 187 | animation-timing-function: ease-out; 188 | animation-iteration-count: 1; 189 | animation-fill-mode: forwards; 190 | } 191 | .confirmationHeader .thumbsUp img.burst.one { 192 | animation-delay: 1s; 193 | } 194 | .confirmationHeader .thumbsUp img.burst.two { 195 | animation-delay: 1.25s; 196 | } 197 | .confirmationHeader .thumbsUp img.thumb { 198 | width:218px; 199 | height:auto; 200 | bottom:104px; 201 | left:100px; 202 | transform:scale(0) rotate(0); 203 | transform-origin:bottom left; 204 | animation-name: thumb; 205 | animation-duration: 1s; 206 | animation-timing-function: ease-out; 207 | animation-delay: .5s; 208 | animation-iteration-count: 1; 209 | animation-fill-mode: forwards; 210 | } 211 | .bodyContents { 212 | opacity:0; 213 | animation-name: beginOpacity; 214 | animation-duration: .5s; 215 | animation-timing-function: ease-out; 216 | animation-delay: 1.5s; 217 | animation-iteration-count: 1; 218 | animation-fill-mode: forwards; 219 | } 220 | @media only screen and (max-width: 480px) { 221 | @keyframes thumbBubble { 222 | 0% { 223 | height:266px; 224 | margin:30px 0; 225 | transform:scale(1); 226 | } 227 | 100% { 228 | height:122px; 229 | margin:-20px 0 0; 230 | transform:scale(.34); 231 | } 232 | } 233 | .confirmationHeader .thumbsUp { 234 | height:266px; 235 | width:304px; 236 | margin:5px 0; 237 | } 238 | h1.confirmTitle { 239 | font-size:5.2rem; 240 | } 241 | .confirmationHeader .thumbsUp img.thumb { 242 | width:162px; 243 | bottom:78px; 244 | left:75px; 245 | } 246 | } -------------------------------------------------------------------------------- /Source code/Voter_centralized/public/assests/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #0d1521; 3 | font-family: tahoma; 4 | color: #989898; 5 | } 6 | 7 | #todo-table{ 8 | position: relative; 9 | width: 95%; 10 | background: #090d13; 11 | margin: 0 auto; 12 | padding: 20px; 13 | box-sizing: border-box; 14 | } 15 | 16 | #todo-table form:after{ 17 | margin: 0; 18 | content: ''; 19 | display: block; 20 | clear: both; 21 | } 22 | 23 | input[type="text"]{ 24 | width: 50%; 25 | padding: 20px; 26 | background:#181c22; 27 | border: 0; 28 | 29 | font-size: 20px; 30 | color: #989898; 31 | } 32 | 33 | button{ 34 | padding: 20px; 35 | width: 30%; 36 | 37 | background: #23282e; 38 | border: 0; 39 | box-sizing: border-box; 40 | color: #fff; 41 | cursor: pointer; 42 | font-size: 20px; 43 | } 44 | 45 | ul{ 46 | list-style-type: none; 47 | padding: 0; 48 | margin: 0; 49 | } 50 | 51 | a { 52 | color: #989898; 53 | text-decoration: none; 54 | 55 | } 56 | li{ 57 | width: 100%; 58 | padding: 20px; 59 | box-sizing: border-box; 60 | font-family: arial; 61 | font-size: 20px; 62 | cursor: pointer; 63 | letter-spacing: 1px; 64 | } 65 | 66 | li:hover{ 67 | text-decoration: line-through; 68 | background: rgba(0,0,0,0.2); 69 | } 70 | 71 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/public/assests/voter.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background:rgba(74, 189, 172,1) !important; 3 | } 4 | .contianer{ 5 | text-align:center !important; 6 | } 7 | h2{ 8 | color: #fff !important; 9 | } 10 | .form { 11 | border-radius: 5px; 12 | background-color: #f2f2f2; 13 | padding: 20px; 14 | } 15 | .but{ 16 | 17 | text-align: center; 18 | 19 | } 20 | .but1{ 21 | background-color: #fc4a1a; 22 | color: #fff; 23 | } 24 | .but1:hover { 25 | background-color: #fc1919; 26 | } 27 | 28 | img { 29 | display: block; 30 | margin-left: auto; 31 | margin-right: auto; 32 | width: 50%; 33 | border-radius: 50%; 34 | } 35 | 36 | #snackbar { 37 | visibility: hidden; 38 | background-color: #333; 39 | color: #fff; 40 | text-align: center; 41 | border-radius: 2px; 42 | padding: 16px; 43 | position: fixed; 44 | } 45 | 46 | #snackbar.show { 47 | visibility: visible; 48 | 49 | } 50 | .form { 51 | border-radius: 5px; 52 | background-color: #f2f2f2; 53 | padding: 20px; 54 | } 55 | .but{ 56 | 57 | text-align: center; 58 | } 59 | img { 60 | display: block; 61 | margin-left: auto; 62 | margin-right: auto; 63 | width: 50%; 64 | border-radius: 50%; 65 | } 66 | .msg{ 67 | 68 | } -------------------------------------------------------------------------------- /Source code/Voter_centralized/views/register.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 |
22 |

23 |

Add Voter

24 |
25 |
26 |
27 |
28 |
29 | <%= message %> 30 |
31 |
32 | Avatar 33 |
34 | 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 |
47 | 48 |
49 | 50 | 51 |
52 |
53 | 54 | 59 |
60 |
61 | 62 | 63 |
64 | 65 | 80 |
81 |
82 | 83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/views/result.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 | 32 | 33 |
34 |

You're done!!

35 |
36 |
37 |
38 |

Your private key is:

39 | <%= message %> 40 |
    41 | 42 |
    43 |

    Terms and conditions which should be followed.

    44 |
  •   s simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry
  • 45 |
  •   s simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry
  • 46 |
  •   s simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry
  • 47 | 48 |
49 |
50 |
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Source code/Voter_centralized/views/upform.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | angular file upload 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source code/election-master/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Juan Batiz-Benet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Source code/election-master/README.md: -------------------------------------------------------------------------------- 1 | 2 | # Election - DAPP Tutorial 3 | Build your first decentralized application, or Dapp, on the Ethereum Network with this tutorial! 4 | 5 | **Full Free Video Tutorial:** 6 | https://youtu.be/3681ZYbDSSk 7 | 8 | 9 | Follow the steps below to download, install, and run this project. 10 | 11 | ## Dependencies 12 | Install these prerequisites to follow along with the tutorial. See free video tutorial or a full explanation of each prerequisite. 13 | - NPM: https://nodejs.org 14 | - Truffle: https://github.com/trufflesuite/truffle 15 | - Ganache: http://truffleframework.com/ganache/ 16 | - Metamask: https://metamask.io/ 17 | 18 | 19 | ## Step 1. Clone the project 20 | `git clone https://github.com/dappuniversity/election` 21 | 22 | ## Step 2. Install dependencies 23 | ``` 24 | $ cd election 25 | $ npm install 26 | ``` 27 | ## Step 3. Start Ganache 28 | Open the Ganache GUI client that you downloaded and installed. This will start your local blockchain instance. See free video tutorial for full explanation. 29 | 30 | 31 | ## Step 4. Compile & Deploy Election Smart Contract 32 | `$ truffle migrate --reset` 33 | You must migrate the election smart contract each time your restart ganache. 34 | 35 | ## Step 5. Configure Metamask 36 | See free video tutorial for full explanation of these steps: 37 | - Unlock Metamask 38 | - Connect metamask to your local Etherum blockchain provided by Ganache. 39 | - Import an account provided by ganache. 40 | 41 | ## Step 6. Run the Front End Application 42 | `$ npm run dev` 43 | Visit this URL in your browser: http://localhost:3000 44 | 45 | If you get stuck, please reference the free video tutorial. 46 | 47 | -------------------------------------------------------------------------------- /Source code/election-master/bs-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "server": { 3 | "baseDir": ["./src", "./build/contracts"] 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /Source code/election-master/build-log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/build-log -------------------------------------------------------------------------------- /Source code/election-master/contracts/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/contracts/.gitkeep -------------------------------------------------------------------------------- /Source code/election-master/contracts/Election.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.20; 2 | 3 | contract Election { 4 | // Model a Candidate 5 | struct Candidate { 6 | uint id; 7 | string name; 8 | uint voteCount; 9 | } 10 | 11 | // Store accounts that have voted 12 | mapping(address => bool) public voters; 13 | // Store Candidates 14 | // Fetch Candidate 15 | mapping(uint => Candidate) public candidates; //declaring it public gives us a getter function by default 16 | // Store Candidates Count 17 | uint public candidatesCount; 18 | 19 | // voted event 20 | event votedEvent ( 21 | uint indexed _candidateId 22 | ); 23 | 24 | function Election () public { 25 | addCandidate("Candidate 1"); 26 | addCandidate("Candidate 2"); 27 | } 28 | 29 | function addCandidate (string _name) private { //available only to contract, not other accounts 30 | candidatesCount ++; 31 | candidates[candidatesCount] = Candidate(candidatesCount, _name, 0); 32 | } 33 | 34 | function vote (uint _candidateId) public { //solidity allows sending meta data, msg.sender gives the account from which the function call is sent 35 | // require that they haven't voted before 36 | require(!voters[msg.sender]); 37 | 38 | // require a valid candidate 39 | require(_candidateId > 0 && _candidateId <= candidatesCount); 40 | 41 | // record that voter has voted 42 | voters[msg.sender] = true; 43 | 44 | // update candidate vote Count 45 | candidates[_candidateId].voteCount ++; 46 | 47 | // trigger voted event 48 | votedEvent(_candidateId); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source code/election-master/contracts/Migrations.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.4.2; 2 | 3 | contract Migrations { 4 | address public owner; 5 | uint public last_completed_migration; 6 | 7 | modifier restricted() { 8 | if (msg.sender == owner) _; 9 | } 10 | 11 | function Migrations() { 12 | owner = msg.sender; 13 | } 14 | 15 | function setCompleted(uint completed) restricted { 16 | last_completed_migration = completed; 17 | } 18 | 19 | function upgrade(address new_address) restricted { 20 | Migrations upgraded = Migrations(new_address); 21 | upgraded.setCompleted(last_completed_migration); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source code/election-master/go-ipfs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Juan Batiz-Benet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Source code/election-master/go-ipfs/README.md: -------------------------------------------------------------------------------- 1 | # ipfs commandline tool 2 | 3 | This is the [ipfs](http://ipfs.io) commandline tool. It contains a full ipfs node. 4 | 5 | ## Install 6 | 7 | To install it, move the binary somewhere in your `$PATH`: 8 | 9 | ```sh 10 | sudo mv ipfs /usr/local/bin/ipfs 11 | ``` 12 | 13 | Or run `sudo ./install.sh` which does this for you. 14 | 15 | ## Usage 16 | 17 | First, you must initialize your local ipfs node: 18 | 19 | ```sh 20 | ipfs init 21 | ``` 22 | 23 | This will give you directions to get started with ipfs. 24 | You can always get help with: 25 | 26 | ```sh 27 | ipfs --help 28 | ``` 29 | -------------------------------------------------------------------------------- /Source code/election-master/go-ipfs/build-log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/go-ipfs/build-log -------------------------------------------------------------------------------- /Source code/election-master/go-ipfs/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Installation script for ipfs. It tries to move $bin in one of the 4 | # directories stored in $binpaths. 5 | 6 | INSTALL_DIR=$(dirname $0) 7 | 8 | bin="$INSTALL_DIR/ipfs" 9 | binpaths="/usr/local/bin /usr/bin" 10 | 11 | # This variable contains a nonzero length string in case the script fails 12 | # because of missing write permissions. 13 | is_write_perm_missing="" 14 | 15 | for binpath in $binpaths; do 16 | if mv "$bin" "$binpath/$bin" 2> /dev/null; then 17 | echo "Moved $bin to $binpath" 18 | exit 0 19 | else 20 | if [ -d "$binpath" -a ! -w "$binpath" ]; then 21 | is_write_perm_missing=1 22 | fi 23 | fi 24 | done 25 | 26 | echo "We cannot install $bin in one of the directories $binpaths" 27 | 28 | if [ -n "$is_write_perm_missing" ]; then 29 | echo "It seems that we do not have the necessary write permissions." 30 | echo "Perhaps try running this script as a privileged user:" 31 | echo 32 | echo " sudo $0" 33 | echo 34 | fi 35 | 36 | exit 1 37 | -------------------------------------------------------------------------------- /Source code/election-master/go-ipfs/ipfs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/go-ipfs/ipfs.exe -------------------------------------------------------------------------------- /Source code/election-master/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Installation script for ipfs. It tries to move $bin in one of the 4 | # directories stored in $binpaths. 5 | 6 | INSTALL_DIR=$(dirname $0) 7 | 8 | bin="$INSTALL_DIR/ipfs" 9 | binpaths="/usr/local/bin /usr/bin" 10 | 11 | # This variable contains a nonzero length string in case the script fails 12 | # because of missing write permissions. 13 | is_write_perm_missing="" 14 | 15 | for binpath in $binpaths; do 16 | if mv "$bin" "$binpath/$bin" 2> /dev/null; then 17 | echo "Moved $bin to $binpath" 18 | exit 0 19 | else 20 | if [ -d "$binpath" -a ! -w "$binpath" ]; then 21 | is_write_perm_missing=1 22 | fi 23 | fi 24 | done 25 | 26 | echo "We cannot install $bin in one of the directories $binpaths" 27 | 28 | if [ -n "$is_write_perm_missing" ]; then 29 | echo "It seems that we do not have the necessary write permissions." 30 | echo "Perhaps try running this script as a privileged user:" 31 | echo 32 | echo " sudo $0" 33 | echo 34 | fi 35 | 36 | exit 1 37 | -------------------------------------------------------------------------------- /Source code/election-master/ipfs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/ipfs.exe -------------------------------------------------------------------------------- /Source code/election-master/migrations/1_initial_migration.js: -------------------------------------------------------------------------------- 1 | var Migrations = artifacts.require("./Migrations.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Migrations); 5 | }; 6 | -------------------------------------------------------------------------------- /Source code/election-master/migrations/2_deploy_contracts.js: -------------------------------------------------------------------------------- 1 | var Election = artifacts.require("./Election.sol"); 2 | 3 | module.exports = function(deployer) { 4 | deployer.deploy(Election); 5 | }; 6 | -------------------------------------------------------------------------------- /Source code/election-master/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pet-shop", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /Source code/election-master/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pet-shop", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "truffle.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "dev": "lite-server", 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "ISC", 15 | "devDependencies": {} 16 | } 17 | -------------------------------------------------------------------------------- /Source code/election-master/src/chart2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Voting Results 5 | 6 | 7 | 8 | 9 |

Voting Results

10 |
11 |
12 | 13 |
14 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 126 | 127 | -------------------------------------------------------------------------------- /Source code/election-master/src/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Source code/election-master/src/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Source code/election-master/src/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Source code/election-master/src/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Source code/election-master/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Election 9 | 10 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 77 | 78 | 79 | 81 |

ELECTION 2018

82 |
83 | 84 |
85 |
86 |
87 |

Loading...

88 |
89 |
90 |

Thanks for voting!

91 |
92 |
93 |
94 |
95 | 96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | 104 |
105 | 106 | 107 | 117 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | -------------------------------------------------------------------------------- /Source code/election-master/src/js/app.js: -------------------------------------------------------------------------------- 1 | App = { 2 | web3Provider: null, 3 | contracts: {}, 4 | account: '0x0', 5 | hasVoted: false, 6 | 7 | init: function() { 8 | return App.initWeb3(); 9 | }, 10 | 11 | initWeb3: function() { 12 | // TODO: refactor conditional 13 | if (typeof web3 !== 'undefined') { 14 | // If a web3 instance is already provided by Meta Mask. 15 | App.web3Provider = web3.currentProvider; 16 | web3 = new Web3(web3.currentProvider); 17 | } else { 18 | // Specify default instance if no web3 instance provided 19 | App.web3Provider = new Web3.providers.HttpProvider('http://localhost:7545'); 20 | web3 = new Web3(App.web3Provider); 21 | } 22 | return App.initContract(); 23 | }, 24 | 25 | initContract: function() { 26 | $.getJSON("Election.json", function(election) { 27 | // Instantiate a new truffle contract from the artifact 28 | App.contracts.Election = TruffleContract(election); 29 | // Connect provider to interact with contract 30 | App.contracts.Election.setProvider(App.web3Provider); 31 | 32 | // App.listenForEvents(); 33 | 34 | return App.render(); 35 | }); 36 | }, 37 | 38 | // Listen for events emitted from the contract 39 | listenForEvents: function() { 40 | 41 | App.contracts.Election.deployed().then(function(instance) { 42 | // Restart Chrome if you are unable to receive this event 43 | // This is a known issue with Metamask 44 | // https://github.com/MetaMask/metamask-extension/issues/2393 45 | instance.votedEvent({}, { 46 | fromBlock: 0, 47 | toBlock: 'latest' 48 | }).watch(function(error, event) { 49 | console.log("event triggered", event) 50 | // Reload when a new vote is recorded 51 | 52 | }); 53 | }); 54 | return App.render(); 55 | }, 56 | 57 | render: function() { 58 | var electionInstance; 59 | var loader = $("#loader"); 60 | var content = $("#content"); 61 | var done = $("#done"); 62 | var result=$(".result"); 63 | var main=$(".main"); 64 | main.show(); 65 | result.hide(); 66 | loader.show(); 67 | content.hide(); 68 | done.hide(); 69 | 70 | // Load account data 71 | web3.eth.getCoinbase(function(err, account) { 72 | if (err === null) { 73 | App.account = account; 74 | $("#accountAddress").html("Your Account: " + account); 75 | } 76 | }); 77 | 78 | // Load contract data 79 | App.contracts.Election.deployed().then(function(instance) { //listing candidates 80 | electionInstance = instance; 81 | return electionInstance.candidatesCount(); 82 | }).then(function(candidatesCount) { 83 | var candidatesResults = $("#candidatesResults"); 84 | candidatesResults.empty(); 85 | 86 | var candidatesSelect = $('#candidatesSelect'); 87 | candidatesSelect.empty(); 88 | 89 | var labels_array=[]; 90 | var data_array=[]; 91 | 92 | for (var i = 1; i <= candidatesCount; i++) { 93 | electionInstance.candidates(i).then(function(candidate) { 94 | var id = candidate[0]; 95 | var name = candidate[1]; 96 | var voteCount = candidate[2]; 97 | 98 | labels_array.push(name); 99 | data_array.push(voteCount); 100 | 101 | 102 | // Render candidate Result 103 | /*var candidateTemplate = "" + id + "" + name + "" + voteCount + "" 104 | candidatesResults.append(candidateTemplate);*/ 105 | 106 | // Render candidate ballot option 107 | var candidateOption = ` 108 |
109 |
110 | 120 | Avatar 121 | 122 |
123 |
124 |

` + name + `

125 |

Party: BJP Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

126 |

Party Symbol

127 | 128 |
129 |
`; 130 | 131 | candidatesSelect.append(candidateOption); 132 | }); 133 | } 134 | 135 | /*var ctx = document.getElementById('myChart').getContext('2d'); 136 | var chart = new Chart(ctx, { 137 | type: 'bar', 138 | data:{ 139 | labels:labels_array, 140 | datasets:[{ 141 | label:'# of Votes', 142 | data: data_array, 143 | backgroundColor:[ 144 | 'rgba(255, 99, 132, 0.6)', 145 | 'rgba(54, 162, 235, 0.6)', 146 | 'rgba(255, 206, 86, 0.6)', 147 | 'rgba(75, 192, 192, 0.6)', 148 | 'rgba(153, 102, 255, 0.6)', 149 | 'rgba(255, 159, 64, 0.6)', 150 | 'rgba(255, 99, 132, 0.6)' 151 | ], 152 | borderWidth:1, 153 | borderColor:'#777', 154 | hoverBorderWidth:3, 155 | hoverBorderColor:'#000' 156 | }] 157 | }, 158 | options:{ 159 | title:{ 160 | display:true, 161 | text:"Each Candidate's Vote(s)", 162 | fontSize:25 163 | }, 164 | legend:{ 165 | display:true, 166 | position:'right', 167 | labels:{ 168 | fontColor:'#000' 169 | } 170 | }, 171 | layout:{ 172 | padding:{ 173 | left:50, 174 | right:0, 175 | bottom:0, 176 | top:0 177 | } 178 | }, 179 | tooltips:{ 180 | enabled:true 181 | } 182 | } 183 | }); 184 | 185 | var ctx = document.getElementById('myChart1').getContext('2d'); 186 | var chart = new Chart(ctx, { 187 | type: 'pie', 188 | data:{ 189 | labels:labels_array, 190 | datasets:[{ 191 | label:'# of Votes', 192 | data: data_array, 193 | backgroundColor:[ 194 | 'rgba(255, 99, 132, 0.6)', 195 | 'rgba(54, 162, 235, 0.6)', 196 | 'rgba(255, 206, 86, 0.6)', 197 | 'rgba(75, 192, 192, 0.6)', 198 | 'rgba(153, 102, 255, 0.6)', 199 | 'rgba(255, 159, 64, 0.6)', 200 | 'rgba(255, 99, 132, 0.6)' 201 | ], 202 | borderWidth:1, 203 | borderColor:'#777', 204 | hoverBorderWidth:3, 205 | hoverBorderColor:'#000' 206 | }] 207 | }, 208 | 209 | options:{ 210 | title:{ 211 | display:true, 212 | text:'Vote Share', 213 | fontSize:25 214 | }, 215 | legend:{ 216 | display:true, 217 | position:'right', 218 | labels:{ 219 | fontColor:'#000' 220 | } 221 | }, 222 | layout:{ 223 | padding:{ 224 | left:50, 225 | right:0, 226 | bottom:0, 227 | top:0 228 | } 229 | }, 230 | tooltips:{ 231 | enabled:true 232 | } 233 | } 234 | });*/ 235 | 236 | 237 | return electionInstance.voters(App.account); 238 | }).then(function(hasVoted) { 239 | // Do not allow a user to vote 240 | if(hasVoted) { 241 | content.hide(); 242 | loader.hide(); 243 | var done = $("#done"); 244 | var resultLink = ``; 245 | done.append(resultLink); 246 | done.show(); 247 | } 248 | else 249 | { 250 | loader.hide(); 251 | content.show(); 252 | done.hide(); 253 | } 254 | }).catch(function(error) { 255 | console.warn(error); 256 | }); 257 | }, 258 | 259 | castVote: function(i) { 260 | // var candidateId = $('#candidatesSelect').val(); 261 | var candidateId=i; 262 | //console.log("value:",candidateId); 263 | App.contracts.Election.deployed().then(function(instance) { 264 | return instance.vote(candidateId, { from: App.account }); 265 | }).then(function(result) { 266 | // Wait for votes to update 267 | var done = $("#done"); 268 | var resultLink = `
`; 269 | done.append(resultLink); 270 | $("#content").hide(); 271 | $("#loader").hide(); 272 | done.show(); 273 | }).catch(function(err) { 274 | console.error(err); 275 | }); 276 | }, 277 | 278 | loadJs: function(){ 279 | var result=$(".result"); 280 | var main=$(".main"); 281 | 282 | var labelss_array=[]; 283 | var datas_array=[]; 284 | 285 | 286 | App.contracts.Election.deployed().then(function(instance) { //listing candidates 287 | electionInstance = instance; 288 | return electionInstance.candidatesCount(); 289 | }).then(function(candidatesCount) { 290 | var candidatesResults = $("#candidatesResults"); 291 | candidatesResults.empty(); 292 | 293 | var candidatesSelect = $('#candidatesSelect'); 294 | candidatesSelect.empty(); 295 | 296 | for (var i = 1; i <= candidatesCount; i++) { 297 | electionInstance.candidates(i).then(function(candidate) { 298 | var id = candidate[0]; 299 | var name = candidate[1]; 300 | var voteCount = candidate[2]; 301 | 302 | labelss_array.push(name); 303 | // console.log(name); 304 | // console.log(labels_array[0]) 305 | datas_array.push(voteCount); 306 | }); 307 | } 308 | }); 309 | 310 | console.log(labelss_array[0]); 311 | var ctx = document.getElementById('myChart1'); 312 | var chart = new Chart(ctx, { 313 | type: 'pie', 314 | data:{ 315 | labels:labelss_array, 316 | datasets:[{ 317 | label:'# of Votes', 318 | data: datas_array, 319 | backgroundColor:[ 320 | 'rgba(255, 99, 132, 0.6)', 321 | 'rgba(54, 162, 235, 0.6)', 322 | 'rgba(255, 206, 86, 0.6)', 323 | 'rgba(75, 192, 192, 0.6)', 324 | 'rgba(153, 102, 255, 0.6)', 325 | 'rgba(255, 159, 64, 0.6)', 326 | 'rgba(255, 99, 132, 0.6)' 327 | ], 328 | borderWidth:1, 329 | borderColor:'#777', 330 | hoverBorderWidth:3, 331 | hoverBorderColor:'#000' 332 | }] 333 | }, 334 | options:{ 335 | title:{ 336 | display:true, 337 | text:"Vote Share", 338 | fontSize:20, 339 | }, 340 | legend:{ 341 | display:true, 342 | position:'right', 343 | labels:{ 344 | fontColor:'#000' 345 | } 346 | }, 347 | layout:{ 348 | padding:{ 349 | left:25, 350 | right:0, 351 | bottom:0, 352 | top:0 353 | } 354 | }, 355 | tooltips:{ 356 | enabled:true 357 | } 358 | } 359 | }); 360 | 361 | result.show(); 362 | main.hide(); 363 | 364 | } 365 | }; 366 | 367 | // loadJs: function() 368 | 369 | $(function() { 370 | $(window).load(function() { 371 | App.init(); 372 | }); 373 | }); 374 | -------------------------------------------------------------------------------- /Source code/election-master/src/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.7 (http://getbootstrap.com) 3 | * Copyright 2011-2016 Twitter, Inc. 4 | * Licensed under the MIT license 5 | */ 6 | if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -------------------------------------------------------------------------------- /Source code/election-master/src/party.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/party.JPG -------------------------------------------------------------------------------- /Source code/election-master/src/test.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/src/test.JPG -------------------------------------------------------------------------------- /Source code/election-master/test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/Source code/election-master/test/.gitkeep -------------------------------------------------------------------------------- /Source code/election-master/test/election.js: -------------------------------------------------------------------------------- 1 | var Election = artifacts.require("./Election.sol"); 2 | 3 | contract("Election", function(accounts) { 4 | var electionInstance; 5 | 6 | it("initializes with two candidates", function() { //mocha 7 | return Election.deployed().then(function(instance) { 8 | return instance.candidatesCount(); 9 | }).then(function(count) { 10 | assert.equal(count, 2); //chai 11 | }); 12 | }); 13 | 14 | it("it initializes the candidates with the correct values", function() { 15 | return Election.deployed().then(function(instance) { 16 | electionInstance = instance; 17 | return electionInstance.candidates(1); 18 | }).then(function(candidate) { 19 | assert.equal(candidate[0], 1, "contains the correct id"); 20 | assert.equal(candidate[1], "Candidate 1", "contains the correct name"); 21 | assert.equal(candidate[2], 0, "contains the correct votes count"); 22 | return electionInstance.candidates(2); 23 | }).then(function(candidate) { 24 | assert.equal(candidate[0], 2, "contains the correct id"); 25 | assert.equal(candidate[1], "Candidate 2", "contains the correct name"); 26 | assert.equal(candidate[2], 0, "contains the correct votes count"); 27 | }); 28 | }); 29 | 30 | it("allows a voter to cast a vote", function() { 31 | return Election.deployed().then(function(instance) { 32 | electionInstance = instance; 33 | candidateId = 1; 34 | return electionInstance.vote(candidateId, { from: accounts[0] }); 35 | }).then(function(receipt) { 36 | assert.equal(receipt.logs.length, 1, "an event was triggered"); 37 | assert.equal(receipt.logs[0].event, "votedEvent", "the event type is correct"); 38 | assert.equal(receipt.logs[0].args._candidateId.toNumber(), candidateId, "the candidate id is correct"); 39 | return electionInstance.voters(accounts[0]); 40 | }).then(function(voted) { 41 | assert(voted, "the voter was marked as voted"); 42 | return electionInstance.candidates(candidateId); 43 | }).then(function(candidate) { 44 | var voteCount = candidate[2]; 45 | assert.equal(voteCount, 1, "increments the candidate's vote count"); 46 | }) 47 | }); 48 | 49 | it("throws an exception for invalid candiates", function() { 50 | return Election.deployed().then(function(instance) { 51 | electionInstance = instance; 52 | return electionInstance.vote(99, { from: accounts[1] }) 53 | }).then(assert.fail).catch(function(error) { 54 | assert(error.message.indexOf('revert') >= 0, "error message must contain revert"); 55 | return electionInstance.candidates(1); 56 | }).then(function(candidate1) { 57 | var voteCount = candidate1[2]; 58 | assert.equal(voteCount, 1, "candidate 1 did not receive any votes"); 59 | return electionInstance.candidates(2); 60 | }).then(function(candidate2) { 61 | var voteCount = candidate2[2]; 62 | assert.equal(voteCount, 0, "candidate 2 did not receive any votes"); 63 | }); 64 | }); 65 | 66 | it("throws an exception for double voting", function() { 67 | return Election.deployed().then(function(instance) { 68 | electionInstance = instance; 69 | candidateId = 2; 70 | electionInstance.vote(candidateId, { from: accounts[1] }); 71 | return electionInstance.candidates(candidateId); 72 | }).then(function(candidate) { 73 | var voteCount = candidate[2]; 74 | assert.equal(voteCount, 1, "accepts first vote"); 75 | // Try to vote again 76 | return electionInstance.vote(candidateId, { from: accounts[1] }); 77 | }).then(assert.fail).catch(function(error) { 78 | assert(error.message.indexOf('revert') >= 0, "error message must contain revert"); 79 | return electionInstance.candidates(1); 80 | }).then(function(candidate1) { 81 | var voteCount = candidate1[2]; 82 | assert.equal(voteCount, 1, "candidate 1 did not receive any votes"); 83 | return electionInstance.candidates(2); 84 | }).then(function(candidate2) { 85 | var voteCount = candidate2[2]; 86 | assert.equal(voteCount, 1, "candidate 2 did not receive any votes"); 87 | }); 88 | }); 89 | }); 90 | -------------------------------------------------------------------------------- /Source code/election-master/truffle-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // See 3 | // for more about customizing your Truffle configuration! 4 | networks: { 5 | development: { 6 | host: "127.0.0.1", 7 | port: 7545, 8 | network_id: "*" // Match any network id 9 | } 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /Source code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1 3 | } 4 | -------------------------------------------------------------------------------- /evoting.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hash-It-Out/EVoting/fc63c00b9643a1eef4b7f0f2bf19e04a2e3ec444/evoting.jpg --------------------------------------------------------------------------------