Merge branch 'gh-pages' of github.com:breunigs/ingress-intel-total-conversion into gh-pages
This commit is contained in:
commit
9c2bc7a779
@ -27,8 +27,9 @@ Please follow the these guidelines. Some are just preference, others are good pr
|
|||||||
- use identity operators: `===` and `!==`. [Why do I want this?](http://stackoverflow.com/a/359509/1684530)
|
- use identity operators: `===` and `!==`. [Why do I want this?](http://stackoverflow.com/a/359509/1684530)
|
||||||
- jQuery is your friend
|
- jQuery is your friend
|
||||||
- indent using two spaces
|
- indent using two spaces
|
||||||
- opening brace on the same line with a space after the if/for/etc: `if(blub) {`
|
- opening brace on the same line: `if(blub) {`
|
||||||
- else clauses: `} else if(blub) {` or `} else {`
|
- else clauses: `} else if(blub) {` or `} else {`
|
||||||
|
- there should be no space after `if`, `for`, etc. E.g. `if(true) { doStuff(); } else { dontDoStuff(); }`
|
||||||
- comments: `// this is a comment`
|
- comments: `// this is a comment`
|
||||||
- quotes: Use single-quotes for JavaScript and double-quotes for HTML content. Example: `$('body').append('<div id="soup">Soup!</div>');`.
|
- quotes: Use single-quotes for JavaScript and double-quotes for HTML content. Example: `$('body').append('<div id="soup">Soup!</div>');`.
|
||||||
- there is no length limit on lines, but try to keep them short where suitable
|
- there is no length limit on lines, but try to keep them short where suitable
|
||||||
|
@ -3,44 +3,69 @@
|
|||||||
// REDEEMING /////////////////////////////////////////////////////////
|
// REDEEMING /////////////////////////////////////////////////////////
|
||||||
|
|
||||||
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||||
if (data.error) {
|
if(data.error) {
|
||||||
var error = '';
|
var error = '';
|
||||||
if (data.error === 'ALREADY_REDEEMED') {
|
if(data.error === 'ALREADY_REDEEMED') {
|
||||||
error = 'The passcode has already been redeemed.';
|
error = 'The passcode has already been redeemed.';
|
||||||
} else if (data.error === 'ALREADY_REDEEMED_BY_PLAYER') {
|
} else if(data.error === 'ALREADY_REDEEMED_BY_PLAYER') {
|
||||||
error = 'You have already redeemed this passcode.';
|
error = 'You have already redeemed this passcode.';
|
||||||
} else if (data.error === 'INVALID_PASSCODE') {
|
} else if(data.error === 'INVALID_PASSCODE') {
|
||||||
error = 'This passcode is invalid.';
|
error = 'This passcode is invalid.';
|
||||||
} else {
|
} else {
|
||||||
error = 'There was a problem redeeming the passcode. Try again?';
|
error = 'There was a problem redeeming the passcode. Try again?';
|
||||||
}
|
}
|
||||||
alert('<strong>' + data.error + '</strong>\n' + error);
|
alert('<strong>' + data.error + '</strong>\n' + error);
|
||||||
} else if (data.result) {
|
} else if(data.result) {
|
||||||
var xmp_level = 0, xmp_count = 0;
|
var tblResult = $('<table class="redeem-result" />');
|
||||||
var res_level = 0, res_count = 0;
|
tblResult.append($('<tr><th colspan="2">Passcode accepted!</th></tr>'));
|
||||||
var shield_rarity = '', shield_count = 0;
|
|
||||||
|
|
||||||
// This assumes that each passcode gives only one type of resonator/XMP/shield.
|
if(data.result.apAward)
|
||||||
// This may break at some point, depending on changes to passcode functionality.
|
tblResult.append($('<tr><td>+</td><td>' + data.result.apAward + 'AP</td></tr>'));
|
||||||
for (var i in data.result.inventoryAward) {
|
if(data.result.xmAward)
|
||||||
|
tblResult.append($('<tr><td>+</td><td>' + data.result.xmAward + 'XM</td></tr>'));
|
||||||
|
|
||||||
|
var resonators = {};
|
||||||
|
var bursts = {};
|
||||||
|
var shields = {};
|
||||||
|
|
||||||
|
for(var i in data.result.inventoryAward) {
|
||||||
var acquired = data.result.inventoryAward[i][2];
|
var acquired = data.result.inventoryAward[i][2];
|
||||||
if (acquired.modResource) {
|
if(acquired.modResource) {
|
||||||
if (acquired.modResource.resourceType === 'RES_SHIELD') {
|
if(acquired.modResource.resourceType === 'RES_SHIELD') {
|
||||||
shield_rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join('');
|
var rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join('');
|
||||||
shield_count++;
|
if(!shields[rarity]) shields[rarity] = 0;
|
||||||
|
shields[rarity] += 1;
|
||||||
}
|
}
|
||||||
} else if (acquired.resourceWithLevels) {
|
} else if(acquired.resourceWithLevels) {
|
||||||
if (acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') {
|
if(acquired.resourceWithLevels.resourceType === 'EMITTER_A') {
|
||||||
xmp_level = acquired.resourceWithLevels.level;
|
var level = acquired.resourceWithLevels.level
|
||||||
xmp_count++;
|
if(!resonators[level]) resonators[level] = 0;
|
||||||
} else if (acquired.resourceWithLevels.resourceType === 'EMITTER_A') {
|
resonators[level] += 1;
|
||||||
res_level = acquired.resourceWithLevels.level;
|
} else if(acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') {
|
||||||
res_count++;
|
var level = acquired.resourceWithLevels.level
|
||||||
|
if(!bursts[level]) bursts[level] = 0;
|
||||||
|
bursts[level] += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alert('<strong>Passcode accepted!</strong>\n' + [data.result.apAward + 'AP', data.result.xmAward + 'XM', xmp_count + 'xL' + xmp_level + ' XMP', res_count + 'xL' + res_level + ' RES', shield_count + 'x' + shield_rarity + ' SH'].join('/'));
|
$.each(resonators, function(lvl, count) {
|
||||||
|
var text = 'Resonator';
|
||||||
|
if(count >= 2) text += ' ('+count+')';
|
||||||
|
tblResult.append($('<tr ><td style="color: ' +window.COLORS_LVL[lvl]+ ';">L' +lvl+ '</td><td>' + text + '</td></tr>'));
|
||||||
|
});
|
||||||
|
$.each(bursts, function(lvl, count) {
|
||||||
|
var text = 'Xmp Burster';
|
||||||
|
if(count >= 2) text += ' ('+count+')';
|
||||||
|
tblResult.append($('<tr ><td style="color: ' +window.COLORS_LVL[lvl]+ ';">L' +lvl+ '</td><td>' + text + '</td></tr>'));
|
||||||
|
});
|
||||||
|
$.each(shields, function(lvl, count) {
|
||||||
|
var text = 'Portal Shield';
|
||||||
|
if(count >= 2) text += ' ('+count+')';
|
||||||
|
tblResult.append($('<tr><td>'+lvl+'</td><td>'+text+'</td></tr>'));
|
||||||
|
});
|
||||||
|
|
||||||
|
alert(tblResult, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +76,8 @@ window.setupRedeem = function() {
|
|||||||
window.postAjax('redeemReward', data, window.handleRedeemResponse,
|
window.postAjax('redeemReward', data, window.handleRedeemResponse,
|
||||||
function(response) {
|
function(response) {
|
||||||
var extra = '';
|
var extra = '';
|
||||||
if (response && response.status) {
|
if(response && response.status) {
|
||||||
if (response.status === 429) {
|
if(response.status === 429) {
|
||||||
extra = 'You have been rate-limited by the server. Wait a bit and try again.';
|
extra = 'You have been rate-limited by the server. Wait a bit and try again.';
|
||||||
} else {
|
} else {
|
||||||
extra = 'The server indicated an error.';
|
extra = 'The server indicated an error.';
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="8"
|
android:minSdkVersion="8"
|
||||||
android:targetSdkVersion="17" />
|
android:targetSdkVersion="10" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
|
@ -3,4 +3,4 @@ ingress intel total conversion (IITC)
|
|||||||
|
|
||||||
# [User documentation moved to the wiki. Please see there!](https://github.com/breunigs/ingress-intel-total-conversion/wiki/IITC-Mobile)
|
# [User documentation moved to the wiki. Please see there!](https://github.com/breunigs/ingress-intel-total-conversion/wiki/IITC-Mobile)
|
||||||
|
|
||||||
# [For developer docs, please see there!](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/mobile/HACKING.md)
|
### [For developer docs, please see HACKING.md](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/mobile/HACKING.md)
|
||||||
|
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
<item android:id="@+id/reload_button"
|
<item android:id="@+id/reload_button"
|
||||||
android:orderInCategory="100"
|
android:orderInCategory="100"
|
||||||
android:showAsAction="never"
|
android:showAsAction="never"
|
||||||
android:title="@string/reload"></item>
|
android:title="@string/reload"></item>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
@ -15,26 +15,26 @@ import android.widget.Toast;
|
|||||||
public class IITC_Mobile extends Activity {
|
public class IITC_Mobile extends Activity {
|
||||||
|
|
||||||
private IITC_WebView iitc_view;
|
private IITC_WebView iitc_view;
|
||||||
private boolean back_button_pressed = false;
|
private boolean back_button_pressed = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
// we do not want to reload our page every time we switch orientations...
|
// we do not want to reload our page every time we switch orientations...
|
||||||
// so restore state if activity was already created
|
// so restore state if activity was already created
|
||||||
if(savedInstanceState != null) {
|
if(savedInstanceState != null) {
|
||||||
((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
|
((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// load new iitc web view with ingress intel page
|
// load new iitc web view with ingress intel page
|
||||||
iitc_view= (IITC_WebView) findViewById(R.id.webview);
|
iitc_view= (IITC_WebView) findViewById(R.id.webview);
|
||||||
iitc_view.setWebChromeClient(new WebChromeClient());
|
iitc_view.setWebChromeClient(new WebChromeClient());
|
||||||
iitc_view.loadUrl("https://www.ingress.com/intel");
|
iitc_view.loadUrl("https://www.ingress.com/intel");
|
||||||
|
|
||||||
// listen to touches (think we need this)
|
// listen to touches (think we need this)
|
||||||
iitc_view.setOnTouchListener(new OnTouchListener() {
|
iitc_view.setOnTouchListener(new OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
back_button_pressed = false;
|
back_button_pressed = false;
|
||||||
@ -43,50 +43,49 @@ public class IITC_Mobile extends Activity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// save instance state to avoid reloading on orientation change
|
||||||
|
@Override
|
||||||
|
protected void onSaveInstanceState(Bundle outState) {
|
||||||
|
iitc_view.saveState(outState);
|
||||||
|
}
|
||||||
|
|
||||||
// save instance state to avoid reloading on orientation change
|
// we want a self defined behavior on resume
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
protected void onResume() {
|
||||||
iitc_view.saveState(outState);
|
super.onResume();
|
||||||
}
|
this.back_button_pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
// we want a self defined behavior on resume
|
// we want a self defined behavior for the back button
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
public void onBackPressed() {
|
||||||
super.onResume();
|
if (this.back_button_pressed) {
|
||||||
this.back_button_pressed = false;
|
super.onBackPressed();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
this.back_button_pressed = true;
|
||||||
|
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
|
||||||
// we want a self defined behavior for the back button
|
@Override
|
||||||
@Override
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
public void onBackPressed() {
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
if (this.back_button_pressed) {
|
getMenuInflater().inflate(R.menu.main, menu);
|
||||||
super.onBackPressed();
|
return true;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
this.back_button_pressed = true;
|
|
||||||
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Handle item selection
|
||||||
getMenuInflater().inflate(R.menu.main, menu);
|
switch (item.getItemId()) {
|
||||||
return true;
|
case R.id.reload_button:
|
||||||
}
|
iitc_view.reload();
|
||||||
|
return true;
|
||||||
@Override
|
default:
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
return super.onOptionsItemSelected(item);
|
||||||
// Handle item selection
|
}
|
||||||
switch (item.getItemId()) {
|
}
|
||||||
case R.id.reload_button:
|
|
||||||
iitc_view.reload();
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@ public class IITC_WebViewClient extends WebViewClient {
|
|||||||
CookieManager cm = CookieManager.getInstance();
|
CookieManager cm = CookieManager.getInstance();
|
||||||
final String cookie = cm.getCookie("https://www.ingress.com/intel");
|
final String cookie = cm.getCookie("https://www.ingress.com/intel");
|
||||||
if(cookie != null) {
|
if(cookie != null) {
|
||||||
web.loadUrl("javascript: (function() { "
|
web.loadUrl("javascript: (function() { "
|
||||||
+ "var script=document.createElement('script');"
|
+ "var script=document.createElement('script');"
|
||||||
+ "script.type='text/javascript';"
|
+ "script.type='text/javascript';"
|
||||||
+ "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
|
+ "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
|
||||||
+ "document.getElementsByTagName('head').item(0).appendChild(script);"
|
+ "document.getElementsByTagName('head').item(0).appendChild(script);"
|
||||||
+ "})()");
|
+ "})()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
style.css
12
style.css
@ -748,3 +748,15 @@ td {
|
|||||||
td + td {
|
td + td {
|
||||||
padding-left: 4px;
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* redeem results *****************************************************/
|
||||||
|
.redeem-result {
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: arial,helvetica,sans-serif;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.redeem-result tr > td:first-child {
|
||||||
|
width: 50px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user