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)
|
||||
- jQuery is your friend
|
||||
- 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 {`
|
||||
- there should be no space after `if`, `for`, etc. E.g. `if(true) { doStuff(); } else { dontDoStuff(); }`
|
||||
- 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>');`.
|
||||
- there is no length limit on lines, but try to keep them short where suitable
|
||||
|
@ -3,44 +3,69 @@
|
||||
// REDEEMING /////////////////////////////////////////////////////////
|
||||
|
||||
window.handleRedeemResponse = function(data, textStatus, jqXHR) {
|
||||
if (data.error) {
|
||||
if(data.error) {
|
||||
var error = '';
|
||||
if (data.error === 'ALREADY_REDEEMED') {
|
||||
if(data.error === 'ALREADY_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.';
|
||||
} else if (data.error === 'INVALID_PASSCODE') {
|
||||
} else if(data.error === 'INVALID_PASSCODE') {
|
||||
error = 'This passcode is invalid.';
|
||||
} else {
|
||||
error = 'There was a problem redeeming the passcode. Try again?';
|
||||
}
|
||||
alert('<strong>' + data.error + '</strong>\n' + error);
|
||||
} else if (data.result) {
|
||||
var xmp_level = 0, xmp_count = 0;
|
||||
var res_level = 0, res_count = 0;
|
||||
var shield_rarity = '', shield_count = 0;
|
||||
} else if(data.result) {
|
||||
var tblResult = $('<table class="redeem-result" />');
|
||||
tblResult.append($('<tr><th colspan="2">Passcode accepted!</th></tr>'));
|
||||
|
||||
// This assumes that each passcode gives only one type of resonator/XMP/shield.
|
||||
// This may break at some point, depending on changes to passcode functionality.
|
||||
for (var i in data.result.inventoryAward) {
|
||||
if(data.result.apAward)
|
||||
tblResult.append($('<tr><td>+</td><td>' + data.result.apAward + 'AP</td></tr>'));
|
||||
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];
|
||||
if (acquired.modResource) {
|
||||
if (acquired.modResource.resourceType === 'RES_SHIELD') {
|
||||
shield_rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join('');
|
||||
shield_count++;
|
||||
if(acquired.modResource) {
|
||||
if(acquired.modResource.resourceType === 'RES_SHIELD') {
|
||||
var rarity = acquired.modResource.rarity.split('_').map(function (i) {return i[0]}).join('');
|
||||
if(!shields[rarity]) shields[rarity] = 0;
|
||||
shields[rarity] += 1;
|
||||
}
|
||||
} else if (acquired.resourceWithLevels) {
|
||||
if (acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') {
|
||||
xmp_level = acquired.resourceWithLevels.level;
|
||||
xmp_count++;
|
||||
} else if (acquired.resourceWithLevels.resourceType === 'EMITTER_A') {
|
||||
res_level = acquired.resourceWithLevels.level;
|
||||
res_count++;
|
||||
} else if(acquired.resourceWithLevels) {
|
||||
if(acquired.resourceWithLevels.resourceType === 'EMITTER_A') {
|
||||
var level = acquired.resourceWithLevels.level
|
||||
if(!resonators[level]) resonators[level] = 0;
|
||||
resonators[level] += 1;
|
||||
} else if(acquired.resourceWithLevels.resourceType === 'EMP_BURSTER') {
|
||||
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,
|
||||
function(response) {
|
||||
var extra = '';
|
||||
if (response && response.status) {
|
||||
if (response.status === 429) {
|
||||
if(response && response.status) {
|
||||
if(response.status === 429) {
|
||||
extra = 'You have been rate-limited by the server. Wait a bit and try again.';
|
||||
} else {
|
||||
extra = 'The server indicated an error.';
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="17" />
|
||||
android:targetSdkVersion="10" />
|
||||
|
||||
<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)
|
||||
|
||||
# [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" >
|
||||
<item android:id="@+id/reload_button"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/reload"></item>
|
||||
<item android:id="@+id/reload_button"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/reload"></item>
|
||||
|
||||
</menu>
|
@ -15,26 +15,26 @@ import android.widget.Toast;
|
||||
public class IITC_Mobile extends Activity {
|
||||
|
||||
private IITC_WebView iitc_view;
|
||||
private boolean back_button_pressed = false;
|
||||
private boolean back_button_pressed = false;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
// we do not want to reload our page every time we switch orientations...
|
||||
// so restore state if activity was already created
|
||||
if(savedInstanceState != null) {
|
||||
((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
|
||||
}
|
||||
else {
|
||||
// load new iitc web view with ingress intel page
|
||||
iitc_view= (IITC_WebView) findViewById(R.id.webview);
|
||||
iitc_view.setWebChromeClient(new WebChromeClient());
|
||||
iitc_view.loadUrl("https://www.ingress.com/intel");
|
||||
// we do not want to reload our page every time we switch orientations...
|
||||
// so restore state if activity was already created
|
||||
if(savedInstanceState != null) {
|
||||
((IITC_WebView)findViewById(R.id.webview)).restoreState(savedInstanceState);
|
||||
}
|
||||
else {
|
||||
// load new iitc web view with ingress intel page
|
||||
iitc_view= (IITC_WebView) findViewById(R.id.webview);
|
||||
iitc_view.setWebChromeClient(new WebChromeClient());
|
||||
iitc_view.loadUrl("https://www.ingress.com/intel");
|
||||
|
||||
// listen to touches (think we need this)
|
||||
iitc_view.setOnTouchListener(new OnTouchListener() {
|
||||
// listen to touches (think we need this)
|
||||
iitc_view.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
back_button_pressed = false;
|
||||
@ -43,50 +43,49 @@ public class IITC_Mobile extends Activity {
|
||||
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
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
iitc_view.saveState(outState);
|
||||
}
|
||||
// we want a self defined behavior on resume
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
this.back_button_pressed = false;
|
||||
}
|
||||
|
||||
// we want a self defined behavior on resume
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
this.back_button_pressed = false;
|
||||
}
|
||||
// we want a self defined behavior for the back button
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (this.back_button_pressed) {
|
||||
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
|
||||
public void onBackPressed() {
|
||||
if (this.back_button_pressed) {
|
||||
super.onBackPressed();
|
||||
return;
|
||||
}
|
||||
this.back_button_pressed = true;
|
||||
Toast.makeText(this, "Press twice to exit", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle item selection
|
||||
switch (item.getItemId()) {
|
||||
case R.id.reload_button:
|
||||
iitc_view.reload();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem 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();
|
||||
final String cookie = cm.getCookie("https://www.ingress.com/intel");
|
||||
if(cookie != null) {
|
||||
web.loadUrl("javascript: (function() { "
|
||||
+ "var script=document.createElement('script');"
|
||||
+ "script.type='text/javascript';"
|
||||
+ "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
|
||||
+ "document.getElementsByTagName('head').item(0).appendChild(script);"
|
||||
+ "})()");
|
||||
web.loadUrl("javascript: (function() { "
|
||||
+ "var script=document.createElement('script');"
|
||||
+ "script.type='text/javascript';"
|
||||
+ "script.src='https://iitcserv.appspot.com/iitc-nightly/iitc-nightly-latest.user.js';"
|
||||
+ "document.getElementsByTagName('head').item(0).appendChild(script);"
|
||||
+ "})()");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
style.css
12
style.css
@ -748,3 +748,15 @@ td {
|
||||
td + td {
|
||||
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