Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit 32e49dc

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into transactionNotifications
# Conflicts: # js/views/pageNavVw.js
2 parents 558be77 + 0717983 commit 32e49dc

File tree

108 files changed

+10477
-4730
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+10477
-4730
lines changed

css/obBase.css

Lines changed: 361 additions & 77 deletions
Large diffs are not rendered by default.

imgs/helpdesk-icon.png

20.7 KB
Loading

index.html

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,55 +40,34 @@ <h2 class="ion-android-close custCol-text clickable"></h2>
4040
</div>
4141
</div>
4242
</div>
43-
<div class="modal modal-opaque hide js-loadingMessageModal">
44-
<div class="modal-child modal-childMain">
45-
<div class="btn-corner btn-cornerTR js-closeIndexModal">
46-
<h2 class="ion-close-circled"></h2>
47-
</div>
48-
<h1 class="txt-center rowTop20"><i class="ion-android-sync spinner"></i> Loading...</h1>
49-
<p class="txt-center js-indexLoadingMsg1"></p>
50-
<p class="txt-center js-indexLoadingMsg2"></p>
51-
<p class="txt-center js-indexLoadingMsg3"></p>
52-
<h2 class="txt-center">
53-
&nbsp;<span class="js-indexLoadingMsg4"></span>&nbsp;
54-
</h2>
55-
<div class="rowTop20 width100 positionWrapper pad50">
56-
<div class="txtFieldWrapper">
57-
<input type="text" class="txtField borderRadius3 placeholder-dark" placeholder="http://serverIPorURL/api/v1/"
58-
style="height: 32px; text-indent: 10px;" name="newServer" id="indexNewServer" />
59-
<a class="btn btn-txt btn-insideInput js-newServerIndexApp">Set New Server</a>
60-
</div>
61-
</div>
62-
<div class="rowTop20 width100 positionWrapper pad50">
63-
<div class="txtFieldWrapper">
64-
<a class="btn btn-txtOnly js-defaultServerIndexApp">Set to http://localhost:18469/api/v1/</a>
65-
<a class="btn btn-txt btn-insideInput pull-right js-defaultServerIndexApp">Set to Default</a>
66-
</div>
67-
</div>
68-
<div class="positionBottom row60 width100">
69-
<a class="btn btn-txt hCentered js-closeIndexApp">Close Application</a>
70-
</div>
71-
</div>
72-
</div>
73-
</div>
7443
<div id="statusBar"></div>
7544
<div id="pageNav" class="bar navBar navBar-main custCol-secondary padding0"></div>
76-
<!-- the loading modal must be on top of the page nav or the reload button is hidden -->
77-
<div id="loadingModal" class="modal modal-opaque js-loadingModal top0">
45+
<div id="loadingModal" class="modal modal-opaque modal-cover-fullscreen js-loadingModal hide">
7846
<div class="spinner-with-logo fullCentered">
7947
<i class="ion-android-sync spinner fontSize30 spinner-with-logo-icon"></i>
8048
</div>
81-
<div class="rowTop20">
82-
<a class="btn btn-txt btn-corner btn-cornerTR js-indexReload"><i class="ion-android-sync"></i> Reload</a>
49+
<div id="loadingModalContent">
50+
<p class="fontSize16 js-translate" data-translate="errorMessages.loadingViewError"></p>
51+
<div id="loadingModalBtns">
52+
<a class="btn btn-large marginRight10 custCol-secondary custCol-text js-indexReload"><i class="ion-android-sync"></i> <span class="js-translate" data-translate="Reload"></span></a>
53+
<a class="btn btn-large custCol-secondary custCol-text" href="#home"><i class="ion-eye"></i> <span class="js-translate" data-translate="LoadIndex"></span></a>
54+
</div>
55+
8356
</div>
8457
</div>
8558

8659
<!--TODO: modularize non-modular scripts -->
8760
<script src="js/utils/list.min.js"></script>
8861

8962
<script>
90-
var app = require('./js/main'),
91-
remote = require('remote');
63+
var app = require('./js/start');
64+
65+
window.translateIndex = function(){
66+
$('.js-translate').each(function() {
67+
$(this).text(polyglot.t($(this).data("translate")));
68+
});
69+
};
70+
translateIndex();
9271
$('.js-closeIndexModal').on('click', function(){
9372
$(this).closest('.modal').addClass('hide');
9473
});

js/App.js

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var ipcRenderer = require('ipc-renderer'),
2-
Socket = require('./utils/Socket'),
2+
__ = require('underscore'),
33
$ = require('jquery'),
4-
ServerConfigMd = require('./models/serverConfigMd'),
4+
Socket = require('./utils/Socket'),
55
_app;
66

77
function App() {
@@ -15,55 +15,42 @@ function App() {
1515
this._notifUnread = 0;
1616
this._chatMessagesUnread = 0;
1717

18-
// TODO: what is wrong with the localStorage adapter??? shouldn't need
19-
// to manually provide the data to the model. All that should be needed
20-
// is an ID and then a subsequent fetch, but that doesn't return the data.
21-
// Investigate!
22-
this.serverConfig = new ServerConfigMd( JSON.parse(localStorage['_serverConfig-1'] || '{}') );
23-
24-
// serverConfigMd.fetch();
25-
if (!localStorage['_serverConfig-1']) {
26-
this.serverConfig.save();
27-
}
28-
29-
this.connectHeartbeatSocket();
18+
// TODO: rather than attach the serverConfigs CL
19+
// in main.js, pass in the instance here so the
20+
// dependency is more explicit.
3021
}
3122

3223
App.prototype.connectHeartbeatSocket = function() {
33-
var self = this;
24+
var activeServer = this.serverConfigs.getActive();
3425

35-
clearTimeout(this.heartbeatSocketTimesup);
26+
if (!activeServer) {
27+
throw new Error(`No active server set. Please set via the Server Configs collection.`);
28+
}
3629

3730
if (this._heartbeatSocket) {
38-
this._heartbeatSocket.connect(this.serverConfig.getHeartbeatSocketUrl());
31+
this._heartbeatSocket.connect(activeServer.getHeartbeatSocketUrl());
3932
} else {
40-
this._heartbeatSocket = new Socket(this.serverConfig.getHeartbeatSocketUrl());
41-
42-
this._heartbeatSocket.on('close', function() {
43-
clearTimeout(self._heartbeatSocketTimesup);
44-
});
33+
this._heartbeatSocket = new Socket(activeServer.getHeartbeatSocketUrl());
4534
}
46-
47-
// give up if it takes to long
48-
this._heartbeatSocketTimesup = setTimeout(function() {
49-
if (self._heartbeatSocket.getReadyState() !== 1) {
50-
//self._heartbeatSocket._socket.close(); //turn off for now, until server issues are fixed
51-
alert(polyglot.t('errorMessages.serverTimeout'));
52-
}
53-
}, 30000); //wait for 30 seconds, sometimes the server stalls
5435
};
5536

5637
App.prototype.getHeartbeatSocket = function() {
5738
return this._heartbeatSocket;
5839
};
5940

6041
App.prototype.login = function() {
42+
var activeServer = this.serverConfigs.getActive();
43+
44+
if (!activeServer) {
45+
throw new Error(`No active server set. Please set via the Server Configs collection.`);
46+
}
47+
6148
return $.ajax({
62-
url: this.serverConfig.getServerBaseUrl() + '/login',
49+
url: activeServer.getServerBaseUrl() + '/login',
6350
method: 'POST',
6451
data: {
65-
username: this.serverConfig.get('username'),
66-
password: this.serverConfig.get('password')
52+
username: activeServer.get('username'),
53+
password: activeServer.get('password')
6754
},
6855
timeout: 3000
6956
});
@@ -136,6 +123,10 @@ App.prototype.setUnreadChatMessageCount = function(count) {
136123
}
137124
};
138125

126+
App.prototype.intlNumFormat = function(numberToFormat, maxDigits){
127+
return new Intl.NumberFormat(window.lang, {maximumFractionDigits: maxDigits}).format(numberToFormat);
128+
};
129+
139130
App.getApp = function() {
140131
if (!_app) {
141132
throw new Error('The app instance was never instantiated and is therefore not available.');
@@ -144,7 +135,4 @@ App.getApp = function() {
144135
return _app;
145136
};
146137

147-
148138
module.exports = App;
149-
150-

js/collections/chatConversationsCl.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,39 @@ var Backbone = require('backbone'),
44

55
module.exports = Backbone.Collection.extend({
66
url: function() {
7-
return app.serverConfig.getServerBaseUrl() + '/get_chat_conversations';
7+
return app.serverConfigs.getActive().getServerBaseUrl() + '/get_chat_conversations';
88
},
99

1010
model: ChatConversationMd,
1111

12-
comparator: function(convo) {
13-
return -convo.get('timestamp');
12+
initialize: function() {
13+
this.on('change:unread', function(model){
14+
// Only re-sort collection if unread count was incremented
15+
if (model.hasChanged('unread') && model.get('unread') > 0) {
16+
this.sort();
17+
}
18+
});
19+
},
20+
21+
comparator: function(a, b) {
22+
// Sort by unread messages first
23+
if (a.get('unread') > 0 && b.get('unread') == 0) {
24+
return -1;
25+
}
26+
27+
if (a.get('unread') == 0 && b.get('unread') > 0) {
28+
return 1;
29+
}
30+
31+
// then sort by timestamp
32+
if (a.get('timestamp') > b.get('timestamp')) {
33+
return -1;
34+
}
35+
36+
if (a.get('timestamp') < b.get('timestamp')) {
37+
return 1;
38+
}
39+
40+
return 0;
1441
}
1542
});

js/collections/chatMessagesCl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var Backbone = require('backbone'),
44

55
module.exports = Backbone.Collection.extend({
66
url: function() {
7-
return app.serverConfig.getServerBaseUrl() + '/get_chat_messages';
7+
return app.serverConfigs.getActive().getServerBaseUrl() + '/get_chat_messages';
88
},
99

1010
model: ChatMessageMd,

js/collections/notificationsCl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var Backbone = require('backbone'),
55

66
module.exports = Backbone.Collection.extend({
77
url: function() {
8-
return app.serverConfig.getServerBaseUrl() + '/get_notifications';
8+
return app.serverConfigs.getActive().getServerBaseUrl() + '/get_notifications';
99
},
1010

1111
model: NotificationMd,

js/collections/ratingCl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var __ = require('underscore'),
55

66
module.exports = Backbone.Collection.extend({
77
url: function() {
8-
return app.serverConfig.getServerBaseUrl() + '/get_ratings';
8+
return app.serverConfigs.getActive().getServerBaseUrl() + '/get_ratings';
99
},
1010

1111
model: RatingMd,

js/collections/serverConfigsCl.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var Backbone = require('backbone'),
2+
localStorageSync = require('../utils/backboneLocalStorage'),
3+
ServerConfigMd = require('../models/serverConfigMd');
4+
5+
module.exports = Backbone.Collection.extend({
6+
sync: localStorageSync.sync,
7+
localStorage: new localStorageSync('__serverConfig'),
8+
model: ServerConfigMd,
9+
10+
getActive: function() {
11+
var config = this.get(localStorage.activeServer);
12+
13+
if (!config && this.length) {
14+
config = this.at(this.length - 1);
15+
this.setActive(config.id);
16+
}
17+
18+
return config;
19+
},
20+
21+
setActive: function(id) {
22+
var md;
23+
24+
if (!(md = this.get(id))) {
25+
throw new Error(`Unable to set the active server config. It must be an id of one of the available
26+
server configs stored in this collection.`)
27+
}
28+
29+
if (this._active !== id) {
30+
this._active = id;
31+
localStorage.activeServer = id;
32+
this.trigger('activeServerChange', md);
33+
}
34+
}
35+
});

js/config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ module.exports = {
1515
keyShortcuts: {
1616
undo: 'z',
1717
discover: 'd',
18-
myPage: 'h',
18+
myPage: 't',
1919
customizePage: 'e',
2020
create: 'n',
21-
purchases: 't',
22-
sales: 'y',
21+
purchases: 'k',
22+
sales: 'm',
2323
cases: 'j',
2424
settings: 'g',
2525
addressBar: 'l',
2626
save: 's',
27-
restart: 'r'
27+
refresh: 'r',
28+
restart: 'f'
2829
},
2930

3031
setTestnet: function(testNetBoolean){

0 commit comments

Comments
 (0)