Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
justmoon committed Aug 22, 2013
2 parents ab37ac3 + e38b005 commit cfea2c9
Show file tree
Hide file tree
Showing 17 changed files with 327 additions and 124 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ module.exports = function(grunt) {
'concat:deps','concat:deps_debug',
'uglify:deps_ie',
'concat:deps_ie', 'concat:deps_ie_debug']);
grunt.registerTask('deps', ['concat:deps', 'min:deps']);
grunt.registerTask('deps', ['uglify:deps', 'uglify:deps_ie',
'concat:deps', 'concat:deps_ie',
'concat:deps_debug', 'concat:deps_ie_debug']);
grunt.registerTask('dist', ['default',
'copy:web', 'copy:nw_linux', 'copy:nw_linux_debug']);
};
Expand Down
1 change: 1 addition & 0 deletions config-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var Options = {
server: {
"trusted" : true,
"trace" : true,
"websocket_ip" : "s1.ripple.com",
"websocket_port" : 443,
"websocket_ssl" : true /**/
Expand Down
124 changes: 90 additions & 34 deletions deps/js/ripple.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/jade/tabs/balance.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ section.panel.content(ng-controller="BalanceCtrl")
.currency-summary.positive(ng-show='account.Balance')
.balancebox
.label XRP - Ripple
.balance
span(rp-tooltip="{{account.Balance | rpamount}} (reserve: {{ account.reserve | rpamount }} XRP)") {{account.Balance | rpamount:{rel_precision: 0} }}
.balance.xrp
span(rp-tooltip="{{account.Balance | rpamount}}") {{account.Balance | rpamount:{rel_precision: 0} }}
span(class="secondary") (reserve: {{ account.reserve | rpamount }} XRP)
.balancebox(ng-repeat="entry in balances", ng-hide="entry.total.is_zero()")
.label {{entry.total | rpcurrencyfull}}
.balance
Expand Down
5 changes: 4 additions & 1 deletion src/jade/tabs/convert.jade
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ section.panel.content(ng-controller="ConvertCtrl")
required
rp-autofill='$routeParams.amount'
rp-autofill-amount
rp-positive-amount)
rp-amount
rp-amount-positive)
input.currency#amount_currency(
name='amount_currency', type='text'
rp-combobox="currency_query", rp-combobox-select
Expand All @@ -34,6 +35,8 @@ section.panel.content(ng-controller="ConvertCtrl")
| Please enter an amount.
.error(rp-error-on='rpAmount')
| Not a valid amount.
.error(rp-error-on='rpAmountPositive')
| Please enter an amount greater than zero.
p.literal(ng-show="convert.path_status == 'waiting'") Please enter the conversion details.
p.literal.throbber(ng-show="convert.path_status == 'pending'") Calculating...
p.literal(ng-show="convert.path_status == 'no-path' && convert.currency_code != 'XRP'") No path found!
Expand Down
24 changes: 16 additions & 8 deletions src/jade/tabs/send.jade
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ section#t-send.single.content(ng-controller='SendCtrl')
.error(rp-error-on='rpStdt')
| Invalid destination tag
label(for='send_amount') Recipient will receive
.amount(ng-hide="send.currency_force")
.amount(ng-if="!send.currency_force")
input.value#send_amount(
name='send_amount', type='text'
ng-model='send.amount'
Expand All @@ -64,41 +64,49 @@ section#t-send.single.content(ng-controller='SendCtrl')
rp-autofill-amount
rp-max-amount
rp-max-amount-currency='{{send.currency}}'
rp-positive-amount)
rp-amount
rp-amount-positive
rp-amount-xrp-limit
rp-amount-xrp-limit-currency='{{send.currency}}')
input.currency#send_amount_currency(
name='send_amount_currency', type='text'
rp-combobox="{{send.currency_choices}}", rp-combobox-select
ng-model='send.currency'
rp-autofill='$routeParams.amount'
rp-autofill-currency)
.input-append(ng-show="send.currency_force")
input.value#send_force_amount(
name='send_force_amount', type='text'
.input-append(ng-if="send.currency_force")
input.value#send_amount(
name='send_amount', type='text'
ng-model='send.amount'
required
rp-autofill='$routeParams.amount'
rp-autofill-amount
rp-max-amount
rp-max-amount-currency='{{send.currency}}'
rp-positive-amount)
rp-amount
rp-amount-positive
rp-amount-xrp-limit
rp-amount-xrp-limit-currency='{{send.currency}}')
span.add-on(ng-bind="send.currency_force")
.errorGroup(rp-errors='send_amount')
.error(rp-error-on='required')
| Please enter an amount.
.error(rp-error-on='rpAmount')
| Not a valid amount.
.error(rp-error-on='rpAmountPositive')
| Amount must be greater than zero.
.error(rp-error-on='rpMaxAmount')
| This transaction exceeds your balance, you can send a max. of {{account.max_spend | rpamount:{rel_precision: 0} }} XRP
.error(ng-show="disallowXrp") Recipient does not allow XRP payments. Are you sure you want to send XRP anyway?
.notice(ng-show="send.trust_limit") {{send.recipient | rpcontactname}} trusts you for {{send.trust_limit | rpamount}} {{send.trust_limit | rpcurrency}}.
.submitsection(ng-show="send.currency_code == 'XRP'")
button.btn.btn-success.submit(type='submit', ng-disabled='sendForm.$invalid || send.self') Send XRP
button.btn.btn-success.submit(type='submit', ng-disabled='sendForm.$invalid || send.self || !send.recipient_resolved') Send XRP
p.literal(ng-show="send.fund_status == 'insufficient-xrp'") Destination account is unfunded; send at least {{send.xrp_deficiency | rpamount}} XRP to initialize it. 
a(href="https://ripple.com/wiki/Reserves", target="_blank") More information
p.literal(ng-show="send.path_status == 'waiting'") Please enter the transaction details.
p.literal.throbber(ng-show="send.path_status == 'checking'") Checking
p.literal.throbber(ng-show="send.path_status == 'fed-check'") Analyzing address
p.literal.throbber(ng-show="send.path_status == 'bridge-quote'") Retrieving Ripple address
p.literal.throbber(ng-show="send.path_status == 'bridge-quote'") Requesting quote
p.literal.throbber(ng-show="send.path_status == 'pending' && send.currency_code != 'XRP'") Calculating paths
p.literal.throbber(ng-show="send.path_status == 'pending' && send.currency_code == 'XRP'") Calculating alternatives
p.literal(ng-show="send.path_status == 'no-path' && send.currency_code != 'XRP'") No path found!
Expand Down
40 changes: 26 additions & 14 deletions src/jade/tabs/trade.jade
Original file line number Diff line number Diff line change
Expand Up @@ -133,41 +133,53 @@ section.panel.content(ng-controller="TradeCtrl")
input#order_amount(
name='amount', type='text'
ng-model='order.first', ng-change='calc_second()'
rp-positive-amount, currency="{{order.first_currency}}"
rp-amount
rp-amount-positive
rp-amount-xrp-limit
rp-amount-xrp-limit-currency="{{order.first_currency}}"
required)
.add-on {{order.first_currency}}
.errorGroup(rp-errors='amount')
.error(rp-error-on='required') Required
.error(rp-error-on='rpAmount') Not a valid amount.
.error(rp-error-on='rpXrpLimit') There is a limit of 100 billion XRPs
.error(rp-error-on='rpAmountPositive') Must be greater than zero
.error(rp-error-on='rpAmountXrpLimit') There is a limit of 100 billion XRPs
.sign x
.value-field
label(for='order_price') Price of Each
.input-append
input#order_price(
name='price', type='text'
ng-model='order.price', ng-change='calc_second()'
rp-positive-amount, currency="{{order.second_currency}}"
rp-amount
rp-amount-positive
rp-amount-xrp-limit
rp-amount-xrp-limit-currency="{{order.second_currency}}"
required)
.add-on {{order.second_currency}}
.errorGroup(rp-errors='price')
.error(rp-error-on='required') Required
.error(rp-error-on='rpAmount') Not a valid price.
.error(rp-error-on='rpXrpLimit') There is a limit of 100 billion XRPs
.error(rp-error-on='rpAmount') Not a valid amount.
.error(rp-error-on='rpAmountPositive') Must be greater than zero
.error(rp-error-on='rpAmountXrpLimit') There is a limit of 100 billion XRPs
.sign =
.value-field
label(for='order_value') Order Value
.input-append
input#order_value(
name='value', type='text'
ng-model='order.second', ng-change='calc_first()'
rp-positive-amount, currency="{{order.second_currency}}"
rp-amount
rp-amount-positive
rp-amount-xrp-limit
rp-amount-xrp-limit-currency="{{order.second_currency}}"
required)
.add-on {{order.second_currency}}
.errorGroup(rp-errors='value')
.error(rp-error-on='required') Required
.error(rp-error-on='rpAmount') Not a valid value.
.error(rp-error-on='rpXrpLimit') There is a limit of 100 billion XRPs
.error(rp-error-on='rpAmount') Not a valid amount.
.error(rp-error-on='rpAmountPositive') Must be greater than zero
.error(rp-error-on='rpAmountXrpLimit') There is a limit of 100 billion XRPs
.message(ng-show='orderForm.$valid')
| You are wanting to {{order.type}}
| {{order.first_amount | rpamount:{precision: 10} }} {{order.first_amount | rpcurrency}}
Expand All @@ -178,12 +190,12 @@ section.panel.content(ng-controller="TradeCtrl")
.submitsection
button.btn.btn-success.submit(type='submit', ng-disabled='orderForm.$invalid') Place Order
div(ng-hide="order.showWidget")
p.literal Your balance is not enough to do an offer.
p.literal Your balance is not enough to create an order.

//- 2. Confirmation
form.mode-confirm(ng-switch-when='confirm', ng-submit="order_confirmed()")
p.literal You are about to place an offer {{order.type}}ing
p.literal You are about to create an order to {{order.type}}
.amount_feedback
span.value {{order.first_amount | rpamount}}
span.currency {{order.first_amount | rpcurrency}}
Expand All @@ -200,7 +212,7 @@ section.panel.content(ng-controller="TradeCtrl")
//- 3. Sending
group.mode-sending(ng-switch-when='sending')
p.throbber.literal Sending offer to Ripple network...
p.throbber.literal Sending order to Ripple network...

//- 4. Error
Expand Down Expand Up @@ -235,15 +247,15 @@ section.panel.content(ng-controller="TradeCtrl")
span(ng-switch-default) Trade failed, reason: {{engine_result_message}}
hr
div(class="actionLink")
a(href="#trade", ng-click="reset(true)") Enter another offer
a(href="#trade", ng-click="reset(true)") Submit another order

ul.filter-tabs
li.my(ng-show="account.Balance"): a(
ng-click="order.listing = 'my'"
ng-click="setListing('my')"
ng-class="{active: order.listing == 'my'}")
| My Orders
li.orderbook: a(
ng-click="order.listing = 'orderbook'"
ng-click="setListing('orderbook')"
ng-class="{active: order.listing == 'orderbook'}")
| Order book

Expand Down
7 changes: 5 additions & 2 deletions src/js/directives/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ module.directive('rpErrors', [function() {
selectedScope;

function updateErrorTransclude() {
var field = formController[fieldName],
$error = field && field.$error;
var field = formController[fieldName];

if (!field) return;

var $error = field && field.$error;

if (selectedElement) {
selectedScope.$destroy();
Expand Down
80 changes: 66 additions & 14 deletions src/js/directives/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,36 +482,88 @@ module.directive('rpMaxAmount', function () {
/**
* Amount validator
*/
module.directive('rpPositiveAmount', function () {
function parseAmount(value) {
// replace commas with dots
if (value && value.toString().indexOf(",") != -1) {
value = value.split(",").join(".");
}

return parseFloat(value);
}

module.directive('rpAmount', function () {
return {
restrict: 'A',
require: '?ngModel',
link: function (scope, elm, attr, ctrl) {
if (!ctrl) return;

var validator = function(value) {
ctrl.$setValidity('rpAmount', false);
var parsedValue = parseAmount(value);

// replace commas with dots
if(value && value.toString().indexOf(",") != -1) {
value = value.split(",").join(".");
}
// check for valid amount
ctrl.$setValidity('rpAmount', parsedValue == value);

return parsedValue;
};

// check for valid and positive amount
var parsedValue = parseFloat(value);
if (parsedValue == value && parsedValue > 0) {
ctrl.$setValidity('rpAmount', true);
ctrl.$formatters.push(validator);
ctrl.$parsers.unshift(validator);
}
};
});

// XRP limit is 100 bln
if (attr.currency && attr.currency.toLowerCase() === 'xrp')
ctrl.$setValidity('rpXrpLimit', parsedValue < 100000000000);
module.directive('rpAmountPositive', function () {
return {
restrict: 'A',
require: '?ngModel',
link: function (scope, elm, attr, ctrl) {
if (!ctrl) return;

var validator = function(value) {
var parsedValue = parseAmount(value);

// check for positive amount
ctrl.$setValidity('rpAmountPositive', parsedValue > 0);

return parsedValue;
};

return parsedValue;
ctrl.$formatters.push(validator);
ctrl.$parsers.unshift(validator);
}
};
});

module.directive('rpAmountXrpLimit', function () {
return {
restrict: 'A',
require: '?ngModel',
link: function (scope, elm, attr, ctrl) {
if (!ctrl) return;

var validator = function(value) {
var parsedValue = parseAmount(value);

var currency = attr.rpAmountXrpLimitCurrency;

// If XRP, ensure amount is less than 100 billion
if (currency &&
currency.toLowerCase() === 'xrp') {
ctrl.$setValidity('rpAmountXrpLimit', parsedValue <= 100000000000);
} else {
ctrl.$setValidity('rpAmountXrpLimit', true);
}

return parsedValue;
};

ctrl.$formatters.push(validator);
ctrl.$parsers.unshift(validator);

attr.$observe('rpAmountXrpLimitCurrency', function() {
validator(ctrl.$viewValue);
});
}
};
});
Expand Down
11 changes: 7 additions & 4 deletions src/js/services/federation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@ module.factory('rpFederation', ['$q', '$rootScope', 'rpRippleTxt',

if (txtPromise) {
if ("function" === typeof txtPromise.then) {
txtPromise.then(processTxt);
txtPromise.then(processTxt, handleNoTxt);
} else {
processTxt(txtPromise);
}
} else {
handleNoTxt();
}

return federationPromise.promise;

function handleNoTxt() {
federationPromise.reject({
result: "error",
error: "noRippleTxt",
error_message: "Ripple.txt not available for the requested domain."
});
}

return federationPromise.promise;

function processTxt(txt) {
if (txt.federation_url) {
$.ajax({
Expand Down
8 changes: 7 additions & 1 deletion src/js/services/rippletxt.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ module.factory('rpRippleTxt', ['$q', '$rootScope',
txtPromise.resolve(sections);
});
},
error: next
error: function (xhr, status) {
setImmediate(function () {
$scope.$apply(function () {
next(xhr, status);
});
});
}
});
};
next();
Expand Down
4 changes: 2 additions & 2 deletions src/js/tabs/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ ConvertTab.prototype.angular = function (module)
tx.send_max($scope.convert.alt.send_max);
tx.paths($scope.convert.alt.paths);

tx.on('success', function (res) {
tx.on('proposed', function (res) {
$scope.$apply(function () {
setEngineStatus(res, false);
$scope.converted(tx.hash);
Expand Down Expand Up @@ -332,4 +332,4 @@ ConvertTab.prototype.angular = function (module)
});
};

module.exports = ConvertTab;
module.exports = ConvertTab;
Loading

0 comments on commit cfea2c9

Please sign in to comment.