Skip to content
Snippets Groups Projects
Commit 769802c8 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Front-end from Otto Zaiser

parent 620af200
No related branches found
No related tags found
No related merge requests found
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><defs><style>.c{stroke-width:3px;fill:none;stroke:#e4b349;stroke-linecap:round;stroke-linejoin:round}</style></defs><title>ICONOS</title><circle cx="100.09" cy="99.61" r="47.77" fill="#e7f5fb"/><path fill="#b9cc2e" stroke="#46245e" stroke-miterlimit="10" stroke-width="3" d="M98.92 124.17a7 7 0 0 1-4.69-1.81l-17.06-15.51a7 7 0 0 1 9.39-10.33l11.93 10.85 37.57-40.67a7 7 0 0 1 10.26 9.47l-42.27 45.76a7 7 0 0 1-5.13 2.24z"/><path d="M38.16 43.83v7.38m-3.69-3.69h7.38m19-17.5v7.38m-3.69-3.69h7.38m91.38 130.81v7.38m-3.69-3.69h7.38m-33.45-17.96v7.38m-3.69-3.69h7.38" class="c"/></svg>
\ No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><style>.st6,.st7{stroke-width:3;stroke-miterlimit:10}.st6{stroke-linecap:round;stroke-linejoin:round;fill:none;stroke:#e4b349}.st7{fill:#b9cc2e;stroke:#46245e}</style><g id="Capa_2"><circle cx="100.1" cy="99.6" r="47.8" fill="#e7f5fb"/><path d="M45.2 64.8v7.4m-3.7-3.7h7.4m12-24.5v-6.6m-3.7 3.3h7.3m86.4 98.8v7.4m-3.7-3.7h7.4m-28.4 13.1v7.3m-3.7-3.7h7.3" class="st6"/><path fill="#e6e6e6" stroke="#46245e" stroke-miterlimit="10" stroke-width="3" d="M126.9 125H73.1c-6.6 0-12-5.4-12-12V87c0-6.6 5.4-12 12-12h53.8c6.6 0 12 5.4 12 12v26c0 6.6-5.4 12-12 12z"/><path fill="none" stroke="#46245e" stroke-miterlimit="10" stroke-width="3" d="M63.5 78.3l33.4 26.8c1.8 1.5 4.4 1.4 6.2 0l33.1-26.8"/><path d="M61.1 115.5l28.5-16.3m49.2 16.3l-28.5-16.3" class="st7"/></g></svg>
\ No newline at end of file
web/images/logo.png

2.9 KiB

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 139.31 100"><defs><style>.c{fill:#5c5c60}</style><radialGradient id="a" cx="69.48" cy="64.25" r="48.74" gradientTransform="matrix(1.39 0 0 1.39 -27.38 -19.65)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#84d0d0"/><stop offset="1" stop-color="#6a9ad1"/></radialGradient></defs><title>Blockchain Federal Argentina</title><path fill="#e5b449" d="M69.65 53.63a14.47 14.47 0 0 0-14.47 14.48h28.95a14.48 14.48 0 0 0-14.48-14.48z"/><path fill="url(#a)" d="M1.61 68.11V55.32l22.14 12.79L45.9 55.32v12.79h1.61V54.39l22.14-12.78L91.8 54.39v13.72h1.61V54.39L104.48 48l10.27-5.93v26h1.61v-26l21.34 12.32v13.72h1.61V53.47l-23-13.25v-26.5L92.6 0 69.65 13.25 46.7 0 23 13.72v26.5L0 53.47v14.64zm91.8-65.79l21.34 12.32v24.65L93.41 27zm20.53 38.36l-10.26 5.93L92.6 53 71.26 40.68 92.6 28.36zm-43.48-26L91.8 2.32V27L70.46 39.29zm-1.61 25.54L47.51 52.54V27.89l21.34-12.32zM46.7 1.86L68 14.18 46.7 26.5 25.36 14.18zM24.56 15.57L45.9 27.89v24.65l-10.27-5.93-11.07-6.39zm-.81 26L34.83 48l10.27 5.93-21.35 12.32L2.41 53.93z"/><path d="M.09 73.53H5.6c2.66 0 4.58 1.47 4.58 4a3.68 3.68 0 0 1-2 3.39 3.79 3.79 0 0 1 2.59 3.81c0 3-2.3 4.48-5.06 4.48H.09zm5.51 6.62a2.23 2.23 0 0 0 2.32-2.39 2.16 2.16 0 0 0-2.36-2.32H2.3v4.71zm.25 7.21a2.5 2.5 0 0 0 2.7-2.68A2.56 2.56 0 0 0 5.83 82H2.3v5.38zm8.58-13.83h2.21v13.83h7.05v1.91h-9.26zm18.82-.27a7.93 7.93 0 0 1 8.07 8 8.09 8.09 0 1 1-16.17 0 8 8 0 0 1 8.1-8zm0 14.25a6 6 0 0 0 5.8-6.22 5.82 5.82 0 1 0-11.63 0 6 6 0 0 0 5.83 6.22zm18.22-14.25a8.11 8.11 0 0 1 5.73 2.07L56.11 77a7.2 7.2 0 0 0-4.55-1.71 5.71 5.71 0 0 0-5.82 6 5.91 5.91 0 0 0 5.84 6.22 7.11 7.11 0 0 0 4.86-2.05L57.63 87a8.47 8.47 0 0 1-6.12 2.5 8.14 8.14 0 0 1 0-16.28zm9.53.27h2.21v6.62l6.32-6.62H72L65.06 81l7.21 8.23h-2.5l-6.54-7.22v7.22H61zm19.9-.2a8 8 0 0 1 5.65 2l-.83 1.13A7.37 7.37 0 0 0 81 74.75a6.27 6.27 0 0 0-6.31 6.56c0 3.75 2.63 6.8 6.35 6.8A7.35 7.35 0 0 0 86.08 86l.92 1.11a8.36 8.36 0 0 1-6 2.43 7.89 7.89 0 0 1-8-8.21 7.77 7.77 0 0 1 7.9-8zm9.42.26h1.54v7.14H101v-7.14h1.54v15.68H101v-7.16h-9.1v7.16h-1.58zm24.47 10.69h-6.32l-1.78 5h-1.63l5.75-15.68h1.66l5.75 15.68h-1.63zm-3.17-9.06s-.34 1.3-.6 2l-2.1 5.69h5.4l-2.06-5.69c-.26-.73-.6-2-.6-2zm9.16-1.63h1.54v15.68h-1.54zm6.09 0h1.5l8 11.29c.53.78 1.29 2.12 1.29 2.12s-.13-1.29-.13-2.12V73.59h1.54v15.68h-1.49l-8-11.28c-.54-.78-1.3-2.12-1.3-2.12s.13 1.29.13 2.12v11.28h-1.54zM0 94.19h3v.5H.58v2.15h2.1v.5H.58v2.56H0zm7.88 0h3.22v.5H8.44v2.08h2.17v.51H8.44v2.12h2.81v.5H7.88zm8.33 0h1.84a2.86 2.86 0 1 1 0 5.71h-1.84zM18 99.4a2.36 2.36 0 0 0 0-4.71h-1.23v4.71zm7.91-5.21h3.22v.5h-2.66v2.08h2.17v.51h-2.17v2.12h2.8v.5h-3.36zm8.32 0h1.69a2.73 2.73 0 0 1 1.08.15 1.67 1.67 0 0 1-.22 3l.14.23 1.25 2.3h-.65l-1.29-2.4h-1.44v2.4h-.56zM36.15 97a1.18 1.18 0 0 0 .61-2.16 1.61 1.61 0 0 0-.81-.14h-1.16V97zm9.69 1.08h-2.3l-.65 1.82h-.59l2.09-5.71H45l2.09 5.71h-.59zm-1.15-3.3l-.22.74-.77 2.07h2l-.75-2.07a9.7 9.7 0 0 1-.22-.74zm7.02-.59h.56v5.21h2.65v.5h-3.21zm16.58 3.89H66l-.66 1.82h-.59l2.1-5.71h.6l2.1 5.71H69zm-1.15-3.3s-.12.47-.22.74l-.76 2.07h2l-.74-2.07a9.7 9.7 0 0 1-.22-.74zm7.03-.59h1.69a2.7 2.7 0 0 1 1.07.15 1.67 1.67 0 0 1-.22 3l.15.23 1.24 2.3h-.64l-1.29-2.4h-1.44v2.4h-.56zM76.08 97a1.06 1.06 0 0 0 1.13-1.16 1.05 1.05 0 0 0-.52-1 1.61 1.61 0 0 0-.81-.14h-1.15V97zm9.37-2.91a3.08 3.08 0 0 1 2 .67l-.3.42a2.82 2.82 0 0 0-1.71-.57 2.44 2.44 0 0 0 0 4.87 2.49 2.49 0 0 0 1.8-.84v-1h-1v-.51h1.51v2.77h-.52v-.67a2.56 2.56 0 0 1-1.86.77 2.83 2.83 0 0 1-2.8-3 2.87 2.87 0 0 1 2.88-2.91zm7.35.1H96v.5h-2.64v2.08h2.17v.51h-2.17v2.12h2.8v.5H92.8zm8.32 0h.55l2.92 4.11c.19.29.47.77.47.77v-4.88h.56v5.71H105l-2.92-4.11c-.19-.28-.47-.77-.47-.77v4.88h-.57zm11.09.5h-2v-.5h4.66v.5h-2v5.21h-.56zm7.18-.5h.61v5.71h-.56zm5.9 0h.55l2.92 4.11c.19.29.47.77.47.77s-.05-.47-.05-.77v-4.11h.57v5.71h-.55l-2.92-4.11c-.19-.28-.47-.77-.47-.77v4.88h-.56zm12.63 3.89h-2.3L135 99.9h-.59l2.09-5.71h.6l2.1 5.71h-.59zm-1.16-3.3s-.12.47-.21.74l-.77 2.07h2l-.78-2.07a9.7 9.7 0 0 1-.22-.74z" class="c"/></svg>
\ No newline at end of file
web/images/pattern.png

624 B

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path fill="#E00" d="M0 7.562l1.114-3.438c2.565.906 4.43 1.688 5.59 2.35-.306-2.921-.467-4.93-.484-6.027h3.511c-.05 1.597-.234 3.6-.558 6.003 1.664-.838 3.566-1.613 5.714-2.325L16 7.562c-2.05.678-4.06 1.131-6.028 1.356.984.856 2.372 2.381 4.166 4.575l-2.906 2.059c-.935-1.274-2.041-3.009-3.316-5.206-1.194 2.275-2.244 4.013-3.147 5.206l-2.856-2.059c1.872-2.307 3.211-3.832 4.017-4.575A86.77 86.77 0 0 1 0 7.562"/></svg>
\ No newline at end of file
!function(o){function a(){o(this).scrollTop()>110?o("#navbar").addClass("navbar-fondo"):o("#navbar").removeClass("navbar-fondo")}o(".bt-top").hide(),o(window).scroll(function(){a()}),a(),o("#toggle-password").on("click",function(a){a.preventDefault(),"text"==o("#pwd").attr("type")?(o("#pwd").attr("type","password"),o("#toggle-password .toggle-icon").removeClass("fa-eye-slash"),o("#toggle-password .toggle-icon").addClass("fa-eye")):"password"==o("#pwd").attr("type")&&(o("#pwd").attr("type","text"),o("#toggle-password .toggle-icon").addClass("fa-eye-slash"),o("#toggle-password .toggle-icon").removeClass("fa-eye"))})}(jQuery);
\ No newline at end of file
// $ solc --abi src/Ballot.sol | head -4 | tail -1 | jq
var abiBallot = [
{
"name": "vote",
"type": "function",
"payable": false,
"constant": false,
"stateMutability": "nonpayable",
"inputs": [
{
"name": "proposal",
"type": "uint256"
}
],
"outputs": []
},
{
"name": "ballotPercentOfRegisteredVotersReqToBeValid",
"type": "function",
"payable": false,
"constant": true,
"inputs": [],
"stateMutability": "view",
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"name": "voterMap",
"type": "function",
"payable": false,
"constant": true,
"stateMutability": "view",
"inputs": [
{
"name": "",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"name": "getVoterIdx",
"type": "function",
"payable": false,
"constant": true,
"stateMutability": "view",
"inputs": [
{
"name": "voter",
"type": "address"
}
],
"outputs": [
{
"name": "",
"type": "int256"
}
]
},
{
"name": "uncreate",
"type": "function",
"payable": false,
"constant": false,
"stateMutability": "nonpayable",
"inputs": [],
"outputs": []
},
{
"name": "voterList",
"type": "function",
"payable": false,
"constant": true,
"stateMutability": "view",
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"outputs": [
{
"name": "voter",
"type": "address"
},
{
"name": "votesLeft",
"type": "uint256"
}
]
},
{
"name": "ballotCountNonvotesAsBlanks",
"type": "function",
"payable": false,
"constant": true,
"stateMutability": "view",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bool"
}
]
},
{
"name": "ballotVoteBefore",
"type": "function",
"payable": false,
"constant": true,
"stateMutability": "view",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256"
}
]
},
{
"constant": false,
"inputs": [
{
"name": "voters",
"type": "address[]"
}
],
"name": "giveRightToVote",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotVoteStarts",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotMaxVotesPerProposal",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotMaxVotesPerVoter",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotTitle",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [
{
"name": "",
"type": "uint256"
}
],
"name": "proposalList",
"outputs": [
{
"name": "",
"type": "bytes32"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotPercentOfVotesCastToWin",
"outputs": [
{
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "ballotChairman",
"outputs": [
{
"name": "",
"type": "address"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"name": "title",
"type": "string"
},
{
"name": "voteStarts",
"type": "uint256"
},
{
"name": "voteBefore",
"type": "uint256"
},
{
"name": "percentOfRegisteredVotersReqToBeValid",
"type": "uint256"
},
{
"name": "percentOfVotesCastToWin",
"type": "uint256"
},
{
"name": "countNonvotesAsBlanks",
"type": "bool"
},
{
"name": "maxVotesPerVoter",
"type": "uint256"
},
{
"name": "maxVotesPerProposal",
"type": "uint256"
},
{
"name": "proposalNames",
"type": "bytes32[]"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "constructor"
}
];
// $ solc --abi src/Ballot.sol | tail -1 | jq
var abiNew = [
{
"constant": false,
"inputs": [
{
"name": "title",
"type": "string"
},
{
"name": "voteStarts",
"type": "uint256"
},
{
"name": "voteBefore",
"type": "uint256"
},
{
"name": "percentOfRegisteredVotersReqToBeValid",
"type": "uint256"
},
{
"name": "percentOfVotesCastToWin",
"type": "uint256"
},
{
"name": "countNonvotesAsBlanks",
"type": "bool"
},
{
"name": "maxVotesPerVoter",
"type": "uint256"
},
{
"name": "maxVotesPerProposal",
"type": "uint256"
},
{
"name": "proposalNames",
"type": "bytes32[]"
}
],
"name": "newBallot",
"outputs": [
{
"name": "newaddr",
"type": "address"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}
];
var gotEth = 0;
var accExposed = 0;
var rootdiv;
var error;
var netid;
var netname;
var blocknumber = -2;
var nowblock;
var netnames = {
"1": 'Ethereum mainnet',
"2": 'Morden test',
"3": 'ropsten test',
"4": 'Rinkeby test',
'42': 'Kovan test',
'5445': 'BFA test',
'47525974938': 'Blockchain Federal Argentina'
};
var mainaddr = {
'5445': '0xe5bf7c3e8aa529e42fbd99428137b68db75d85f9',
'47525974938': '0xe3e08934b6fa0b68972c08e0f545cee31ed039c6'
};
window.addEventListener('load', page_loaded);
function addchild(parent, childtype, childText, attributes) {
var childNode = document.createElement(childtype);
if (typeof childText == 'string') {
var childTextNode = document.createTextNode(childText);
childNode.appendChild(childTextNode);
}
if (attributes) {
for (var att in attributes)
childNode.setAttribute(att, attributes[att]);
}
parent.appendChild(childNode);
return childNode;
}
function ask_about_contract_address() {
document.getElementById('status').classList.remove("hide");
document.getElementById('voterow').classList.remove("hide");
}
function update_create_new_ballot() {
// Find our div (if it exists).
var div = document.getElementById('div_create_ballot');
if (!div)
return;
// Don't change anything, if we are in the middle of creating a new contract.
if (document.getElementById('newcontract'))
return;
// See if we already have the form inside the div
if (!document.getElementById('nueva_link')) {
addchild(div, 'span', 'o tal vez querés ');
addchild(div, 'a', 'crear una votación nueva', {
'href': 'javascript:ask_for_ballot_details()',
'id': 'nueva_link'
});
addchild(div, 'span', '?');
}
if (mainaddr[netid] == undefined) {
// if we do not have the address of the mother contract, we will
// not present the user with a choice to create a new form.
div.setAttribute('class', 'hidden');
return;
}
div.removeAttribute('class');
}
async function page_loaded() {
var body = document.getElementsByTagName("body")[0];
rootdiv = addchild(body, 'div', undefined, {
'id': 'root'
});
const Web3 = require('web3');
// post Nov 2018 this works
if (window.ethereum) {
window.web3 = new Web3(ethereum);
gotEth = 1;
} else
// pre Nov 2018, we look here
if (window.web3) {
window.web3 = new Web3(web3.currentProvider);
gotEth = 1;
// in pre 2019 dapp browsers acccounts are always exposed
accExposed = 1;
}
else
if (document.URL.search(/file:/) == 0)
error = 'El plugin no puede detectar directamente desde un archivo. El documento necesita estar en un servidor.';
else {
// Non-dapp browsers...
//window.alert("Non-Ethereum browser detected. Consider using MetaMask.");
error = 'No se detectó un browser Ethereum. Por favor, <a href="https://metamask.io/" target="_blank">instalá MetaMask</a>.';
}
if (error) {
//addchild( rootdiv, 'div', error, {'class':'warning'});
alertar(error);
return;
}
// wow, all okay
// add more UI elements
console.log('window.web3.version.api is ' + window.web3.version.api);
ask_about_contract_address();
//addchild( rootdiv, 'hr', undefined, {'width':'20%'} );
addchild(rootdiv, 'div', undefined, {
'id': 'div_create_ballot',
'class': 'hidden'
});
update_create_new_ballot();
get_status();
timer = setInterval(get_status, 1000);
}
function deleteAllChildren(node) {
node.children.forEach(
function (item, idx) {
node.removeChild(item);
}
);
}
async function get_netid() {
window.web3.version.getNetwork(
(err, netId) => {
netid = undefined;
netname = undefined;
if (netId != undefined) {
netid = netId;
netname = netnames[netid];
if (netname == undefined)
netname = netid;
else
netname = netid + " (" + netname + ")";
}
update_status_display();
}
)
}
async function got_block_details(err, block) {
if (err)
return;
nowblock = block;
update_status_display();
}
async function get_status() {
window.web3.eth.getBlockNumber(
(err, blocknum) => {
// If the increase is bigger than one,
// or negative, get the netid.
var diff = blocknum - blocknumber;
if (diff < 0 || diff > 1)
get_netid();
if (blocknum != blocknumber) {
blocknumber = blocknum;
update_status_display();
nowblock = undefined;
window.web3.eth.getBlock(blocknumber, false, got_block_details);
}
}
)
}
function update_status_display() {
var div = document.getElementById('status') ||
addchild(rootdiv, 'div', undefined, {
"class": "status",
"id": "status"
});
var info = [];
if (netname)
info.push('Network ' + netname);
var thattimething;
if (blocknumber) {
var thistxt = "Current block: #" + blocknumber;
if (nowblock)
thistxt += ' @ ' + new Date(nowblock.timestamp * 1000).toISOString();
info.push(thistxt);
}
if (info.length == 0) {
if (div && div.parent)
div.parent.removeChild(div);
} else
div.innerHTML = info.join('<br/>');
update_create_new_ballot()
}
function api_version() {
if (window.web3.version.api.substring(0, 2) == '0.')
return 0;
if (window.web3.version.api.substring(0, 2) == '1.')
return 1;
return -1;
}
function setup_existing_contract(abi, addr) {
if (api_version() == 0) {
var MyContract = window.web3.eth.contract(abiNew);
console.log(MyContract);
contract = MyContract.at(mainaddr[netid]);
return contract;
}
window.alert('Do not know how to deal with contracts at this API version (' + window.web3.version.api + ').');
return;
}
function add_proposal(pos) {
var div = document.getElementById('newtable');
if (!div)
return;
var len = div.children.length;
//
var newnode = document.createElement('tr');
newnode.setAttribute('class', 'proposal');
// We add/adjust text and attribs afterwards
var td1 = addchild(newnode, 'td');
var td2 = addchild(newnode, 'td');
addchild(td2, 'input');
var idx = 0;
for (var i = 0; i < div.children.length; i++) {
if (div.children[i].getAttribute('class') == 'proposal') {
idx++;
if (newnode) {
if (pos == idx) {
div.insertBefore(newnode, div.children[i - 1]);
newnode = undefined;
}
}
}
}
if (newnode && idx < 10)
div.insertBefore(newnode, div.lastChild);
// Fix numbering
idx = 0;
for (var i = 0; i < div.children.length; i++) {
if (div.children[i].getAttribute('class') == 'proposal') {
idx++;
div.children[i].children[0].innerHTML = 'Proposal ' + idx;
div.children[i].children[1].children[0].setAttribute('name', 'proposal' + idx);
}
}
}
async function ask_for_ballot_details() {
if (mainaddr[netid] == undefined)
return;
if (abiNew == undefined)
return
if (abiNew == '')
return;
//
var otherdiv;
if (otherdiv = document.getElementById('div_create_ballot'))
otherdiv.setAttribute('class', 'hidden');
//
// Our territory starts here
//
var newdiv = addchild(rootdiv, 'div', undefined, {
'id': 'newcontract'
});
// Create form.
var form = addchild(newdiv, 'form', undefined, {
'id': 'form_create_new_ballot',
'action': 'javascript:nueva_votacion()'
});
var table = addchild(form, 'table', undefined, {
'id': 'newtable'
});
// Title
var tr = addchild(table, 'tr');
addchild(tr, 'td', 'Title');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'title'
}
);
// Vote Starts
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Vote starts');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'voteStarts'
}
);
// Vote Before
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Vote before');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'voteBefore'
}
);
// % of registered voters req to be valid
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Percent of registered voters must vote for the result to be valid');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'percentOfRegisteredVotersReqToBeValid',
'value': '0.000001'
}
);
// % of votes cast to win
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Percent of votes cast to win');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'percentOfVotesCastToWin',
'value': '50.000001'
}
);
// Count non-votes as blanks
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Count non-votes as blanks');
var select = addchild(
addchild(tr, 'td'),
'select', undefined, {
'name': 'countNonvotesAsBlanks'
}
);
addchild(select, 'option', undefined, {
'value': 'Yes'
}).innerHTML = 'Si / Yes';
addchild(select, 'option', undefined, {
'value': 'No'
}).innerHTML = 'No';
// Max votes per voter
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Maximum number of votes per voter');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'maxVotesPerVoter',
'value': '1'
}
);
// Max votes per proposal
tr = addchild(table, 'tr');
addchild(tr, 'td', 'Maximum number of votes per proposal');
addchild(
addchild(tr, 'td'),
'input', undefined, {
'name': 'maxVotesPerProposal',
'value': '1'
}
);
// more mas extra
tr = addchild(table, 'tr');
addchild(
addchild(tr, 'td', undefined, {
'colspan': '2'
}),
'a', '[ + extra proposal ]', {
'href': 'javascript:add_proposal(999)'
});
// Proposals
add_proposal(1);
//
// submit button to create a new ballot
addchild(form, 'input', undefined, {
'type': 'submit',
'value': 'Crear nueva'
});
}
async function nueva_votacion() {
if (mainaddr[netid] == undefined)
return;
var f = document.forms['form_create_new_ballot'];
var arguments = [];
arguments.push(f['title'].value);
arguments.push(f['voteStarts'].value);
arguments.push(f['voteBefore'].value);
arguments.push(f['percentOfRegisteredVotersReqToBeValid'].value);
arguments.push(f['percentOfVotesCastToWin'].value);
arguments.push(f['countNonvotesAsBlanks'].value);
arguments.push(f['maxVotesPerVoter'].value);
arguments.push(f['maxVotesPerProposal'].value);
var p;
var proposals = [];
for (var i = 1; p = f['proposal' + i]; i++)
proposals.push(p.value);
var newdiv = document.getElementById('newcontract');
var localstatus = addchild(newdiv, 'p', 'Trying to access your account.');
access_accounts();
localstatus.innerHTML = 'Creating new voting contract.';
var contract = setup_existing_contract(abiNew, mainaddr[netid]);
if (!contract)
return;
var rcpt;
if (api_version() == 0)
contract.newBallot.call(
arguments[0],
arguments[1],
arguments[2],
arguments[3],
arguments[4],
arguments[5],
arguments[6],
arguments[7],
proposals, {
gas: 2111000
},
contract_created
);
}
async function contract_created(err, rcpt) {
console.log(rcpt);
if (!rcpt)
return;
//ver_votacion( newaddr );
}
async function ver_votacion(addr) {
if (addr == "")
addr =
document
.getElementById('input_address')
.value;
alertarLoading('Cargando detalles del contrato...');
if (addr && addr.length == 40)
addr = '0x' + addr;
window.web3.eth.getCode(addr, function (err, code) {
if (err) {
alertar('No es posible obtener el bytecode del contrato: ' + err + '');
return;
}
ver_votacion2(addr, code);
});
}
async function ver_votacion2(addr, code) {
console.log(code);
if (code == '0x') {
alertar('No existe un contrato con esa dirección');
return;
}
var keccak3 = window.web3.sha3(code, {
'encoding': 'hex'
});
console.log(keccak3);
if (keccak3 != '0xabcd') {
alertar('No hay una votación en esa dirección.');
return;
}
var contract = setup_existing_contract(abiBallot, addr);
if (!contract)
return;
var detailpromises;
// make sure we have just a single verdiv
var verdiv;
while (verdiv = document.getElementById('verdiv'))
verdiv.parent.removeChild(verdiv);
verdiv = addchild(rootdiv, 'div', undefined, {
'id': 'verdiv'
});
// Get headline
var proposaldiv = addchild(verdiv, 'p', 'Proposal:')
contract.methods.proposal().call({})
.then(
function showproposal(result) {
proposaldiv.innerHTML = 'Proposal: ' + result;
},
function failproposal(err) {
proposaldiv.innerHTML = 'Failed to get proposal: ' + err
}
);
}
function access_accounts() {
if (gotEth) {
if (!accExposed) {
try {
// dapp browsers from after Nov 2018, requires us to ask
// permission to use the account.
ethereum.enable();
// Acccounts now exposed, or the error gets caught
accExposed = 1;
} catch (error) {
// window.alert(
// "Access to your ethereum account was denied. The reason " +
// "given with was \"" +
// error +
// "\"."
// );
alertar("El acceso a tu cuenta de ethereum fue deneagado. La razón es: "+ error +".")
}
}
// web3.eth.sendTransaction({/* ... */});
}
}
async function de_acuerdo_y_firmar() {
access_accounts();
if (!accExposed)
return;
// web3.eth.sendTransaction({/* ... */});
}
function alertar(err){
document.getElementById('alert-wrapper').innerHTML = '<div class="alert alert-danger" role="alert" id="alert"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button><i class="fas fa-exclamation-circle" aria-hidden="true"></i> <span id="alert-content"></span></div>';
document.getElementById('alert-content').innerHTML = err;
document.getElementById('alert').style.display = "block";
}
function alertarLoading(err){
document.getElementById('alert-wrapper').innerHTML = '<div class="alert alert-info" role="alert" id="alert"><i class="fas fa-spinner loading-status" aria-hidden="true"></i> <span id="alert-content"></span></div>';
document.getElementById('alert-content').innerHTML = err;
document.getElementById('alert').style.display = "block";
}
function alertarSuccess(err){
document.getElementById('alert-wrapper').innerHTML = '<div class="alert alert-success" role="alert" id="alert"><i class="fas fa-check" aria-hidden="true"></i> <span id="alert-content"></span></div>';
document.getElementById('alert-content').innerHTML = err;
document.getElementById('alert').style.display = "block";
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html lang="es-AR">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Votar | Blockchain Federal Argentina</title>
<link rel="shortcut icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" media="screen" href="css/vendor.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
</head>
<body>
<a href="#main-content" class="visually-hidden focusable skip-link">Pasar al contenido principal</a>
<nav id="navbar" role="banner" class="navbar navbar-default navbar-fixed-top navbar-content navbar-vote">
<div class="container">
<div class="navbar-header">
<div class="region region-navigation">
<a class="logo navbar-btn pull-left" href="https://bfa.ar/" rel="home">
<img id="logo" src="./images/logo.svg" alt="Blockchain Federal Argentina">
</a>
<div class="vote-status hide" id="status"></div>
</div>
</div>
</div>
</nav>
<div class="diagonal-header"></div>
<main class="container vote" id="main-content">
<div id="alert-wrapper"></div>
<div id="voterow" class="row hide">
<section>
<h1 class="page-header">Título de la votación</h1>
<p class="max-container"><b>Dirección:</b> 0xe3e08934b6fa0b68972c08e0f545cee31ed039
<a class="btn-default btn btn-lg btn-address" aria-label="Cambiar dirección" href="smartVote.html">
Cambiar
</a>
</p>
<div class="resultados" style="display: none;">
<h2>Resultados</h2>
<div class="res_op">
<span class="lab">Opción 1</span>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100" style="width: 60%;">
60%
</div>
</div>
</div>
<div class="res_op">
<span class="lab">Opción 2</span>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100" style="width: 20%;">
20%
</div>
</div>
</div>
<div class="res_op">
<span class="lab">Opción 3</span>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100" style="width: 15%;">
15%
</div>
</div>
</div>
<div class="res_op">
<span class="lab">Opción 4</span>
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100" style="width: 5%;">
5%
</div>
</div>
</div>
<h2>Detalle de la votación</h2>
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>Nombre</th>
<th>Correo</th>
<th>Opción votada</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Mark</td>
<td>mark@bfa.ar</td>
<td>1</td>
</tr>
<tr>
<th scope="row">2</th>
<td>Clara</td>
<td>Clara@bfa.ar</td>
<td>1</td>
</tr>
<tr>
<th scope="row">3</th>
<td>David</td>
<td>David@bfa.ar</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<form action="">
<div class="alert alert-danger" role="alert" id="errorForm">
<p>Comprobá los siguientes errores del formulario:</p>
<ul></ul>
</div>
<fieldset class="form-group votar">
<legend>Opciones para votar</legend>
<div class="radio">
<input type="radio" name="votacion" id="vote_0" required="required" aria-required="true">
<label for="vote_0">Opción 1</label>
</div>
<div class="radio">
<input type="radio" name="votacion" id="vote_1">
<label for="vote_1">Opción 2</label>
</div>
<div class="radio">
<input type="radio" name="votacion" id="vote_3">
<label for="vote_3">Opción 3</label>
</div>
<div class="radio">
<input type="radio" name="votacion" id="vote_4">
<label for="vote_4">Opción 4</label>
</div>
</fieldset>
<div class="form-group col-sm-6 col-sm-push-6">
<button class="btn-primary btn btn-block" type="submit" id="submit">Votar</button>
</div>
</form>
<div class="clearfix"></div>
</section>
</div>
</main>
<footer role="contentinfo">
<div class="container">
<div class="row">
<div class="col col-xs-12">
<div class="region region-footer">
<section>
<h2>Redes Sociales</h2>
<div class="field field--name-body field--type-text-with-summary field--label-hidden field--item">
<ul>
<li><a href="https://www.facebook.com/bfa.ar" target="_blank"><i class="fab fa-facebook-f fa-2x"
aria-hidden="true"></i><span class="sr-only">Facebook</span></a></li>
<li><a href="https://www.twitter.com/bfa_ar" target="_blank"><i class="fab fa-twitter fa-2x"
aria-hidden="true"></i><span class="sr-only">Twitter</span></a></li>
<li><a href="https://www.instagram.com/bfa_ar" target="_blank"><i class="fab fa-instagram fa-2x"
aria-hidden="true"></i><span class="sr-only">Instagram</span></a></li>
<li><a href="https://www.linkedin.com/company/bfar/" target="_blank"><i class="fab fa-linkedin-in fa-2x"
aria-hidden="true"></i><span class="sr-only">Linkedin</span></a></li>
</ul>
<p class="font_small">Blockchain Federal Argentina</p>
</div>
</section>
</div>
</div>
</div>
</div>
</footer>
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<script src="js/vendor/font-awesome531.js"></script>
<script src="js/vendor/jquery.validate.js"></script>
<script src="js/main.js"></script>
<script src="js/vendor/web3.js"></script>
<script src="js/vendor/abi.js"></script>
<script src="js/vendor/ballot.js"></script>
<script>
var container = $('#errorForm');
$("form").validate({
focusInvalid: false,
errorContainer: container,
errorLabelContainer: $("ul", container),
wrapper: 'li',
highlight: function (element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function (element) {
$(element).closest('.form-group').removeClass('has-error');
},
invalidHandler: function (event, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
location.hash = "#errorForm";
var body = $("html, body");
body.stop().animate({
scrollTop: 0
}, 200);
$('#errorForm').focus();
}
},
submitHandler: function (form) {
// do other things for a valid form
//form.submit();
var body = $("html, body");
body.stop().animate({
scrollTop: 0
}, 200)
alertarSuccess('¡Votaste con éxito!');
$("#voterow :input").attr("disabled", true);
$("#voterow .btn").hide();
$("form").hide();
$(".resultados").show();
$(".votar legend").text('Tu voto');
},
messages: {
votacion: {
required: "Seleccioná una opción para poder votar"
}
},
rules: {
votacion: {
required: true
}
}
});
</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="es-AR">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Votación | Blockchain Federal Argentina</title>
<link rel="shortcut icon" href="favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" media="screen" href="css/vendor.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css" />
</head>
<body>
<a href="#main-content" class="visually-hidden focusable skip-link">Pasar al contenido principal</a>
<nav id="navbar" role="banner" class="navbar navbar-default navbar-fixed-top navbar-content navbar-vote">
<div class="container">
<div class="navbar-header">
<div class="region region-navigation">
<a class="logo navbar-btn pull-left" href="https://bfa.ar/" rel="home">
<img id="logo" src="./images/logo.svg" alt="Blockchain Federal Argentina">
</a>
<div class="vote-status hide" id="status"></div>
</div>
</div>
</div>
</nav>
<div class="diagonal-header"></div>
<main class="container vote" id="main-content">
<div id="alert-wrapper"></div>
<div id="voterow" class="row hide">
<section>
<h1 class="page-header">Votación</h1>
<a class="btn-default btn btn-lg btn-header btn-new" aria-label="Crear nueva votación" href="smartNewvote.html">
<span class="hidden-xs">Crear nueva votación</span>
<span class="visible-xs">
<i class="fas fa-plus" aria-hidden="true"></i>
</span>
</a>
<form action="">
<div class="alert alert-danger" role="alert" id="errorForm">
<p>Comprobá los siguientes errores del formulario:</p>
<ul></ul>
</div>
<div class="form-group form-group-lg col-sm-12">
<label for="input_address" class="form-required">Dirección de la votación</label>
<input class="form-control" type="text" id="input_address" name="input_address" value="" size="40"
minlength="40" maxlength="40" required="required" aria-required="true" placeholder="40 caracteres hex (puede empezar con 0x)">
</div>
<div class="form-group col-sm-6 col-sm-push-6">
<button class="btn-primary btn btn-block" type="submit" id="submit">Ver votación</button>
</div>
</form>
</section>
</div>
</main>
<footer role="contentinfo">
<div class="container">
<div class="row">
<div class="col col-xs-12">
<div class="region region-footer">
<section>
<h2>Redes Sociales</h2>
<div class="field field--name-body field--type-text-with-summary field--label-hidden field--item">
<ul>
<li><a href="https://www.facebook.com/bfa.ar" target="_blank"><i class="fab fa-facebook-f fa-2x"
aria-hidden="true"></i><span class="sr-only">Facebook</span></a></li>
<li><a href="https://www.twitter.com/bfa_ar" target="_blank"><i class="fab fa-twitter fa-2x"
aria-hidden="true"></i><span class="sr-only">Twitter</span></a></li>
<li><a href="https://www.instagram.com/bfa_ar" target="_blank"><i class="fab fa-instagram fa-2x"
aria-hidden="true"></i><span class="sr-only">Instagram</span></a></li>
<li><a href="https://www.linkedin.com/company/bfar/" target="_blank"><i class="fab fa-linkedin-in fa-2x"
aria-hidden="true"></i><span class="sr-only">Linkedin</span></a></li>
</ul>
<p class="font_small">Blockchain Federal Argentina</p>
</div>
</section>
</div>
</div>
</div>
</div>
</footer>
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<script src="js/vendor/font-awesome531.js"></script>
<script src="js/vendor/jquery.validate.js"></script>
<script src="js/main.js"></script>
<script src="js/vendor/web3.js"></script>
<script src="js/vendor/abi.js"></script>
<script src="js/vendor/ballot.js"></script>
<script>
var container = $('#errorForm');
$("form").validate({
focusInvalid: false,
errorContainer: container,
errorLabelContainer: $("ul", container),
wrapper: 'li',
highlight: function (element) {
$(element).closest('.form-group').addClass('has-error');
},
unhighlight: function (element) {
$(element).closest('.form-group').removeClass('has-error');
},
submitHandler: function (form) {
// do other things for a valid form
//form.submit();
ver_votacion('');
},
messages: {
input_address: {
required: "Ingresá una dirección válida",
minlength: "La dirección debe tener 40 caractéres incluidos el 0x.",
maxlength: "La dirección debe tener 40 caractéres incluidos el 0x."
}
},
rules: {
input_address: {
required: true,
minlength: 40,
maxlength: 40
}
}
});
</script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment