Skip to content

Commit a9c585e

Browse files
committed
porting IGB module and some other basic cleanup
1 parent 6ba8013 commit a9c585e

5 files changed

Lines changed: 56 additions & 68 deletions

File tree

‎src/EVEoj.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ exports.Const = require('./Const.js');
66
exports.Utils = require('./Utils.js');
77
exports.SDD = require('./SDD.js');
88
exports.map = require('./map.js');
9+
if (exports.Utils.isBrowser) {
10+
exports.IGB = require('./IGB.js');
11+
}
912

1013
exports.V_MAJOR = 0;
1114
exports.V_MINOR = 2;

‎src/IGB.js‎

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
1-
EVEoj.IGB = EVEoj.IGB || {};
2-
(function ($) {
3-
var ME = EVEoj.IGB,
4-
E = EVEoj,
5-
6-
/* private functions */
7-
_IGBClick, // basic click handler for IGB scheme
8-
_Ready // runs when DOM ready fires
9-
;
10-
11-
_IGBClick = function (ev) {
12-
var corp_id,
13-
chan,
14-
cctype,
15-
trustme,
16-
trust_req = false,
17-
href
18-
;
19-
20-
href = $(this).attr('href');
21-
if (!href.match(/^eve:/i)) return; // huh.. that's odd
22-
ev.preventDefault();
1+
/* global jQuery: false */
2+
/* global CCPEVE: false */
3+
'use strict';
4+
5+
var $ = jQuery;
236

24-
if (href.match(/^eve:trust:/i)) trust_req = true;
25-
href = href.replace(/^eve:\s*/i, '').replace(/^trust:\s*/i, '');
26-
27-
/*
28-
if (typeof(navigator) != 'undefined' && navigator.hasOwnProperty('userAgent') && !navigator.userAgent.match(/EVE\-IGB/)) {
29-
// straight browser detection for IGB
30-
return;
31-
}
32-
*/
33-
if (typeof(CCPEVE) == 'undefined') {
34-
// impl based detection for IGB
35-
return;
36-
}
37-
38-
corp_id = $(this).data('igb-corpid');
39-
chan = $(this).data('igb-chan');
40-
cctype = $(this).data('igb-cctype');
41-
trustme = $(this).data('igb-trustme');
7+
function IGBClick(ev) {
8+
var corp_id,
9+
chan,
10+
cctype,
11+
trustme,
12+
trust_req = false,
13+
href
14+
;
4215

43-
if (corp_id && corp_id > 0) CCPEVE.showInfo(2, corp_id);
44-
if (chan) CCPEVE.joinChannel(chan);
45-
if (cctype) CCPEVE.createContract(cctype);
46-
if (trustme) CCPEVE.requestTrust(trustme);
47-
};
16+
href = $(this).attr('href');
17+
if (!href.match(/^eve:/i)) return; // huh.. that's odd
18+
ev.preventDefault();
19+
20+
if (href.match(/^eve:trust:/i)) trust_req = true;
21+
href = href.replace(/^eve:\s*/i, '').replace(/^trust:\s*/i, '');
4822

49-
_Ready = function () {
50-
$("a[href^='eve:']").click(_IGBClick);
51-
};
52-
53-
$(_Ready);
23+
/*
24+
if (typeof(navigator) != 'undefined' && navigator.hasOwnProperty('userAgent') && !navigator.userAgent.match(/EVE\-IGB/)) {
25+
// straight browser detection for IGB
26+
return;
27+
}
28+
*/
29+
if (typeof(CCPEVE) == 'undefined') {
30+
// impl based detection for IGB
31+
return;
32+
}
5433

55-
})(jQuery);
34+
corp_id = $(this).data('igb-corpid');
35+
chan = $(this).data('igb-chan');
36+
cctype = $(this).data('igb-cctype');
37+
trustme = $(this).data('igb-trustme');
38+
39+
if (corp_id && corp_id > 0) CCPEVE.showInfo(2, corp_id);
40+
if (chan) CCPEVE.joinChannel(chan);
41+
if (cctype) CCPEVE.createContract(cctype);
42+
if (trustme) CCPEVE.requestTrust(trustme);
43+
}
44+
45+
$(function () {
46+
$("a[href^='eve:']").click(IGBClick);
47+
});

‎src/SDD.Source.json.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ var Utils = require('./Utils');
44
var req_browser_ignore = require;
55

66
if (Utils.isBrowser) {
7+
// AJAX-based JSON loader; only for browserify/standalone version
78
module.exports = require('./SDD.Source.json_browser.js');
89
}
910
else {
11+
// nodeFS based JSON loader; required in a way that browserify will ignore
1012
module.exports = req_browser_ignore('./SDD.Source.json_node.js');
1113
}

‎src/Utils.js‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ exports.isBrowser = typeof(window) !== 'undefined';
77
var req_browser_ignore = require;
88
var BB;
99

10-
// var extend = require('node.extend');
11-
// var Promise = require('bluebird');
12-
1310
var F = function () {};
1411

1512
// implementations from external stuff (mostly jQuery) that might theoretically change later
@@ -23,26 +20,20 @@ exports.create = (typeof Object.create == 'function')
2320
F.prototype = o;
2421
return new F();
2522
};
26-
/*
27-
ME.extend = $.extend;
28-
ME.deferred = $.Deferred;
29-
ME.ajax = $.ajax;
30-
*/
31-
//exports.deferred = jQuery.Deferred;
23+
3224
if (exports.isBrowser) {
25+
// grab deferred from global, custom-built bluebird (inserted by uglify)
3326
exports.deferred = Promise.defer;
27+
28+
// grab ajax from jQuery (implied dependency)
29+
exports.ajax = jQuery.ajax;
3430
}
3531
else {
32+
// bluebird required in a way that browserify will ignore (since using custom built for standalone)
3633
BB = req_browser_ignore('bluebird');
3734
exports.deferred = BB.defer;
3835
}
39-
exports.ajax = jQuery.ajax;
40-
/*
41-
function isBrowser() {
42-
return typeof(window) !== 'undefined';
43-
}
44-
isBrowser();
45-
*/
36+
4637
exports.FormatNum = function (val, fixed) {
4738
var stringy = [],
4839
base = String(Math.floor(val)),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var EVEoj = require('../../src/core');
3+
var EVEoj = require('../../src/EVEoj.js');
44

55
describe('EVEoj', function() {
66
it('EVEoj.VERSION test', function() {

0 commit comments

Comments
 (0)