Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Aug 1, 2016
1 parent 3692395 commit 1297569
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 207 deletions.
2 changes: 1 addition & 1 deletion app.js
Expand Up @@ -73,7 +73,7 @@ app.use(function(err, req, res, next) {

module.exports = app;

var debug = require('debug')('allcast-site');
var debug = require('debug')('vysor-site');

app.set('port', process.env.PORT || 3000);

Expand Down
1 change: 1 addition & 0 deletions public/app/friendly-names.js
@@ -0,0 +1 @@
// Nothing to see here. Uglified.
40 changes: 32 additions & 8 deletions public/app/list.html
Expand Up @@ -5,18 +5,20 @@
<title>
Vysor
</title>
<script src='common/jquery-2.1.1.min.js' type="text/javascript">
</script>
<script src='common/jquery-2.1.1.min.js' type="text/javascript"></script>

<link href='font-awesome/css/font-awesome.min.css' rel='stylesheet' type='text/css'>

<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">

<script src="bootstrap/js/bootstrap.min.js" type="text/javascript">
</script>
<script src="bootstrap/js/bootstrap.min.js" type="text/javascript"></script>

<script src='list.js' type="text/javascript">
</script>
<script src='farm-access.js' type="text/javascript"></script>
<script src='friendly-names.js' type="text/javascript"></script>
<script src='util.js' type="text/javascript"></script>
<script src='list.js' type="text/javascript"></script>

<script src='uglify-list.js' type="text/javascript"></script>

<link href="list.css" rel="stylesheet" type="text/css">
</head>
Expand Down Expand Up @@ -57,7 +59,7 @@ <h4 class="modal-title">Connect to Network Device (adb connect)</h4>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">IP Address of Android Device</span>
<input type="text" class="form-control" placeholder="192.168.1.100" aria-describedby="basic-addon1" id='connect-address'>
<input type="text" class="form-control" placeholder="192.168.1.100[:5555]" aria-describedby="basic-addon1" id='connect-address'>
</div>

</div>
Expand All @@ -69,6 +71,28 @@ <h4 class="modal-title">Connect to Network Device (adb connect)</h4>
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<div class="modal fade" id="renameModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4>Rename Android</h4>
</div>
<div class="modal-body">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">New Display Name</span>
<input type="text" class="form-control" placeholder="" aria-describedby="basic-addon1" id='new-display-name'>
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" id='rename-cancel'>Cancel</button>
<button type="button" class="btn btn-primary" id='rename-ok'>Rename</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<h5 id='choose-header' class='list-header'>
Choose a device
Expand Down Expand Up @@ -140,7 +164,7 @@ <h5>
</div>
<div id='login-container'>
<p id='login-line'>
<a id='login' name="login">Login</a> to use your purchase offline.
<a id='login' name="login">Login</a> for offline usage and Vysor Share.
</p>
<p id='logging-in'>
Logging in...
Expand Down
83 changes: 1 addition & 82 deletions public/app/list.js
@@ -1,82 +1 @@
function selectDevices() {
chrome.usb.getUserSelectedDevices({
multiple: true,
filters: [
{
interfaceClass: 0xff,
interfaceSubclass: 0x42,
interfaceProtocol: 0x1,
}
]
}, function(devices) {
$.each(devices, function(key, device) {
var vidpid = device.vendorId.toString(16) + ':' + device.productId.toString(16);
tracker.sendEvent('select-device', vidpid);

adbServer.refreshDevice(device, function(adb) {
if (adb) {
tracker.sendEvent('connect-device', adb.properties['ro.product.name'], device.vendorId.toString(16) + ':' + device.productId.toString(16), vidpid);
}
else {

var appName = chrome.runtime.getManifest().name;
chrome.notifications.create("reload", {
type: "basic",
iconUrl: "/icon.png",
title: appName,
message: "An error occurred while connecting to the Android device. Restarting the Vysor app, or disconnecting and reconnecting the Android may resolve this issue.",
buttons: [
{
title: "Reload"
}
]
});
}
});
})
});
}

$(document).ready(function() {
$('#logging-in').hide();
$('#login-container').hide();
$('#connect-android').click(selectDevices);
$('#vysor-version').text('Vysor Version ' + chrome.runtime.getManifest().version)
$('#reload-vysor').click(function() {
chrome.runtime.reload();
})

function checkUsage() {
chrome.storage.local.get(['vysorUsage'], function(d) {
var vysorUsage = d.vysorUsage;
if (!vysorUsage)
vysorUsage = 0;
var hoursUsed = vysorUsage / (60 * 60 * 1000);
// half hour
hoursUsed = Math.round(hoursUsed * 2) / 2;
console.log('hours used', hoursUsed);
$('#used').html("You've used Vysor for " + hoursUsed + " hours. Support Vysor. Go Pro.")
});

setTimeout(checkUsage, 60 * 60 * 1000)
}

checkUsage();
});

function goModal() {
$('#notificationModal').modal();
}

function hideModal() {
$('#notificationModal').modal('hide');
}

function showConnect() {
$('#connectModal').modal();

}

function hideConnect() {
$('#connectModal').modal('hide');
}
// Nothing to see here. Uglified.
3 changes: 2 additions & 1 deletion public/app/manifest.json
Expand Up @@ -2,7 +2,7 @@
"name": "Vysor",
"short_name": "Vysor",
"description": "A window to your Android",
"version": "1.1.2.4",
"version": "1.1.3.1",
"minimum_chrome_version": "48",
"sockets": {
"tcp": {
Expand Down Expand Up @@ -73,6 +73,7 @@
"client_id": "64148182473-mmrruv55po0sjb7ghlnmhgkkuk2u8eou.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/chromewebstore.readonly"
]
},
Expand Down
1 change: 1 addition & 0 deletions public/app/purchase.html
Expand Up @@ -9,6 +9,7 @@
<script src='common/jquery-2.1.1.min.js'></script>
<script src='util.js'></script>
<script src='purchase.js'></script>
<script src='uglify-purchase.js'></script>
<style>
.blue-icon {
color: #4A98E5;
Expand Down
111 changes: 1 addition & 110 deletions public/app/purchase.js
@@ -1,110 +1 @@
$(document).ready(function() {
$('#purchase-options').hide();
chrome.storage.local.get(['vysorUsage'], function(d) {
var vysorUsage = d.vysorUsage;
if (!vysorUsage)
vysorUsage = 0;
var hoursUsed = vysorUsage / (60 * 60 * 1000);
// half hour
hoursUsed = Math.round(hoursUsed * 2) / 2;
$('#used').html("<span class='time-highlight'>You've used Vysor for " + hoursUsed + " hours. Support Vysor. Go Pro.</span>")
});

function onSkuDetails(response) {
$.each(response.response.details.inAppProducts, function(index, product) {
var sku = product.sku;
var name = product.localeData[0].title;
var price = product.prices[0];
var priceText = (price.valueMicros / 1000000) + ' ' + price.currencyCode;
var ele = $('<tr><td id="sub"></td><td id="price"></td><td><a id="purchase" class="green-icon fa fa-shopping-cart"> Google Wallet</a></td></tr>');
ele.find('#sub').text(name)
ele.find('#price').text(priceText);
ele.find('#purchase').click(function() {
google.payments.inapp.buy({
'parameters': {'env': 'prod'},
'sku': sku,
'success': function() {
refreshLicenseManager();
console.log('success', arguments);
},
'failure': function() {
refreshLicenseManager();
console.log('failure', arguments);
}
});
})
$('#prices').append(ele);
});

var ele = $('<tr><td id="sub"></td><td id="price"></td><td></td></tr>');
$('#prices').append(ele);
addPaypal();
addEnterprise();
$('#purchase-options-loading h4').hide();
$('#purchase-options').show();
}

function addPaypal() {

var ele = $('<tr><td id="sub"></td><td id="price"></td><td><a id="purchase" class="green-icon fa fa-shopping-cart"> PayPal</a></td></tr>');
ele.find('#sub').text('Lifetime Pass')
ele.find('#price').text('39.99 USD');
ele.find('#purchase').click(function() {
chrome.identity.getAuthToken({
interactive: true,
scopes: ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email']
}, function(token) {
if (!token) {
showNotification('Unable to retrieve Google auth token. Are you behind a firewall or using a VPN?')
return;
}
var url = 'https://clockworkbilling.appspot.com/api/v1/paypalorder/koushd@gmail.com/vysor.lifetime?return_url=https://vysor.clockworkmod.com/purchase&sandbox=false&token=' + token;
chrome.browser.openTab({url: url});
chrome.app.window.current().close();
}.bind(this));
})
$('#prices').append(ele);
}

function addEnterprise() {
var ele = $('<tr><td id="sub"></td><td id="price"></td><td><a id="purchase">Learn More</a></td></tr>');
ele.find('#sub').text('Enterprise Licensing')
ele.find('#price').text('$2 per user per month');
ele.find('#purchase').click(function() {
var url = 'https://billing.vysor.io/';
chrome.browser.openTab({url: url});
chrome.app.window.current().close();
})
$('#prices').append(ele);
}

function onSkuDetailsFail() {
console.log(arguments);
$('#purchase-options-loading h4').html('Chrome Web Store subscription pricing unavailable.<br/>This may be caused when behind a VPN or firewall.<br/>Please make ensure you are <a href="https://www.google.com/chrome/browser/signin.html" target="_blank">logged into Chrome</a><br/>and <a href="https://developer.chrome.com/webstore/pricing#seller" target="_blank">your country supports Chrome Web Store payments</a>.<br/>Alternatively, you may purchase the Lifetime Pass through PayPal.')
$('#purchase-options').show();

addPaypal();
addEnterprise();
}

google.payments.inapp.getSkuDetails({
'parameters': {'env': 'prod'},
'success': onSkuDetails,
'failure': onSkuDetailsFail
});

$('#retrieve').click(function() {
chrome.identity.getAuthToken({
interactive: true,
// must use the exact same scopes used to submit the license or the token shits
scopes: ['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email']
}, function(token) {
if (!token) {
console.log('Unable to get token for retrieve?')
return;
}

refreshLicenseManager();
});
})
})
// Nothing to see here. Uglified.
1 change: 1 addition & 0 deletions public/app/uglify-list.js

Large diffs are not rendered by default.

0 comments on commit 1297569

Please sign in to comment.