Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
beautifying tayvano's code but really impressive what she did :)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed May 31, 2016
1 parent 31ed568 commit bbabf2d
Show file tree
Hide file tree
Showing 7 changed files with 19,848 additions and 20,182 deletions.
78 changes: 13 additions & 65 deletions app/scripts/controllers/theDaoProposalCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,73 +64,22 @@ var theDaoProposalCtrl = function($scope, $sce, walletService) {
}

$scope.filters = {
id: globalFuncs.urlGet('id') != null ? parseInt(globalFuncs.urlGet('id')) : '',
open: globalFuncs.urlGet('open') != null ? globalFuncs.urlGet('open') : '',
split: globalFuncs.urlGet('split') != null ? globalFuncs.urlGet('split') : '',
description: globalFuncs.urlGet('description') != null ? globalFuncs.urlGet('description') : ''
};

if (globalFuncs.urlGet('id') == null) {
$scope.comparator = false;
} else {
$scope.filters.id = parseInt(globalFuncs.urlGet('id'));
$scope.comparator = true;
}

if (globalFuncs.urlGet('open') == null) {
} else {
$scope.filters.open = globalFuncs.urlGet('open');
$scope.comparator = false;
}

if (globalFuncs.urlGet('split') == null) {
} else {
$scope.filters.split = globalFuncs.urlGet('split');
$scope.comparator = false;
}

if (globalFuncs.urlGet('description') == null) {
} else {
$scope.filters.description = globalFuncs.urlGet('description');
$scope.comparator = false;
}

if (globalFuncs.urlGet('id') == null && globalFuncs.urlGet('open') == null && globalFuncs.urlGet('split') == null && globalFuncs.urlGet('description') == null ) {
$scope.comparator = globalFuncs.urlGet('id') != null;
if ($scope.filters.id == '' && $scope.filters.open == '' && $scope.filters.split == '' && $scope.filters.description == '' ) {
$scope.filters.split = 'false';
$scope.filters.open = 'true';
$scope.comparator = false;
}

$scope.$watch('filters.id', function() {
if ($scope.filters.id == '') {
$scope.comparator = false;
$scope.filters.id = '';
}
if ($scope.filters.id == null) {
$scope.comparator = false;
}
console.log("split: " + JSON.stringify($scope.filters));
console.log("split: comparator: " + $scope.comparator);
});

$scope.$watch('filters.open', function() {
if ($scope.filters.open == null) {} else {
$scope.comparator = false;
$scope.filters.id = '';
}
console.log("open: " + JSON.stringify($scope.filters));
console.log("open: comparator: " + $scope.comparator);
});
$scope.$watch('filters.split', function() {
if ($scope.filters.split == null) {} else {
$scope.comparator = false;
$scope.filters.id = '';
}
console.log("split: " + JSON.stringify($scope.filters));
console.log("split: comparator: " + $scope.comparator);
});

console.log("load: " + JSON.stringify($scope.filters));
console.log("load: comparator: " + $scope.comparator);



$scope.$watch('filters', function(newValue, oldValue) {
if ((newValue.id!=oldValue.id)&&($scope.filters.id == '' || $scope.filters.id == null)) $scope.comparator = false;
if (newValue.open!=oldValue.open && $scope.filters.open == '') $scope.filters.id = '';
if (newValue.split!=oldValue.split && $scope.filters.split != '') $scope.filters.id = '';
}, true);
$scope.initValues();
$scope.showProposal = function(id) {
if (!$scope.AllProposals[id].showprop) {
Expand Down Expand Up @@ -169,7 +118,7 @@ var theDaoProposalCtrl = function($scope, $sce, walletService) {
recipient: '0x' + proposal[0],
amount: etherUnits.toEther('0x' + proposal[1], 'wei'),
content: proposal[12] == "0" ? "" : proposal.slice(13).join(),
description: proposal[12] == "0" ? "Propsoal ID #" + tProposal.proposalID : globalFuncs.hexToAscii(proposal.slice(13).join('')).replace(/<br>/g, '\n').replace(/\\n/g, '\n'),
description: proposal[12] == "0" ? "Propsoal ID #" + tProposal.proposalID : globalFuncs.stripTags(globalFuncs.hexToAscii(proposal.slice(13).join('')).replace(/<br>/g, '\n').replace(/\\n/g, '\n')),
votingDeadline: new Date(new BigNumber("0x" + proposal[3]).toNumber() * 1000),
today: new Date(),
open: proposal[4] == '1' ? true : false,
Expand Down Expand Up @@ -203,10 +152,9 @@ var theDaoProposalCtrl = function($scope, $sce, walletService) {

if (objProposal.description.indexOf('\n') > 0) {
var firstLine = objProposal.description.substring(0, objProposal.description.indexOf('\n'));
objProposal.descriptionHTML = $sce.trustAsHtml(globalFuncs.stripTags(marked(objProposal.description.substring(firstLine.length + 1) || "")));
objProposal.descriptionHTML = $sce.trustAsHtml(marked(objProposal.description.substring(firstLine.length + 1) || ""));
objProposal.description = firstLine;
}

return objProposal;
}
$scope.generateTx = function() {
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/controllers/thedaoCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var theDaoCtrl = function($scope, $sce, walletService) {
recipient: '0x' + proposal[0],
amount: etherUnits.toEther('0x' + proposal[1], 'wei'),
content: proposal[12] == "0" ? "" : proposal.slice(13).join(),
description: proposal[12] == "0" ? "Propsoal ID #" + $scope.proposalId : globalFuncs.hexToAscii(proposal.slice(13).join('')).replace(/<br>/g, '\n').replace(/\\n/g, '\n'),
description: proposal[12] == "0" ? "Propsoal ID #" + $scope.proposalId : globalFuncs.stripTags(globalFuncs.hexToAscii(proposal.slice(13).join('')).replace(/<br>/g, '\n').replace(/\\n/g, '\n')),
votingDeadline: new Date(new BigNumber("0x" + proposal[3]).toNumber() * 1000),
today: new Date(),
open: proposal[4] == '1' ? true : false,
Expand Down Expand Up @@ -158,7 +158,7 @@ var theDaoCtrl = function($scope, $sce, walletService) {

if ($scope.objProposal.description.indexOf('\n') > 0) {
var firstLine = $scope.objProposal.description.substring(0, $scope.objProposal.description.indexOf('\n'));
$scope.objProposal.descriptionHTML = $sce.trustAsHtml(globalFuncs.stripTags(marked($scope.objProposal.description.substring(firstLine.length + 1) || "")));
$scope.objProposal.descriptionHTML = $sce.trustAsHtml(marked($scope.objProposal.description.substring(firstLine.length + 1) || ""));
$scope.objProposal.description = firstLine;
}
}
Expand Down
8 changes: 1 addition & 7 deletions app/scripts/globalFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,7 @@ globalFuncs.checkAndRedirectHTTPS = function() {
if ((host == window.location.host || githost == window.location.host || hostw == window.location.host || githostw == window.location.host) && (window.location.protocol != "https:")) window.location.protocol = "https";
}
globalFuncs.isStrongPass = function(password) {
if (password.length > 8) {
return true;
} else {
return false;
}
//var re = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}/;
//return re.test(password);
return password.length > 8;
}
globalFuncs.hexToAscii = function(hex) {
return hex.match(/.{1,2}/g).map(function(v) {
Expand Down
Loading

0 comments on commit bbabf2d

Please sign in to comment.