Permalink
Browse files

add inline install script

  • Loading branch information...
1 parent 999024a commit 574b9b80e205b8048448ea3f696a562434569a3c @zaach zaach committed Jan 2, 2013
Showing with 68 additions and 44 deletions.
  1. +3 −2 lib/views.js
  2. +57 −39 public/js/site.js
  3. +3 −3 views/download.html
  4. +5 −0 views/layout.html
View
@@ -31,8 +31,9 @@ function setup(app) {
app.get('/download', function(req, res) {
res.locals({
- logo: 'chrome-logo.png',
- agent: 'Chrome'
+ agent: 'chrome',
+ agentName: 'Chrome',
+ installUrl: 'https://chrome.google.com/webstore/detail/gombot-alpha/maeopofifamhhcdbejkfolecghncglll'
});
res.render('download.html');
});
View
@@ -1,41 +1,59 @@
(function() {
- var site = {
- platform: 'windows'
- };
-
- if(navigator.platform.indexOf("Win32") != -1 ||
- navigator.platform.indexOf("Win64") != -1) {
- site.platform = 'windows';
- }
- else if (navigator.platform.indexOf("armv7l") != -1) {
- site.platform = 'android';
- }
- else if(navigator.platform.indexOf("Linux") != -1) {
- site.platform = 'linux';
- }
- else if (navigator.userAgent.indexOf("Mac OS X") != -1) {
- site.platform = 'osx';
- }
- else if (navigator.userAgent.indexOf("MSIE 5.2") != -1) {
- site.platform = 'osx';
- }
- else if (navigator.platform.indexOf("Mac") != -1) {
- site.platform = 'mac';
- }
- else {
- site.platform = 'other';
- }
-
- function init() {
- // Add the platform as a classname on the html-element immediately to avoid lots
- // of flickering
- var h = document.documentElement;
- h.className = h.className.replace("windows", site.platform);
-
- // Add class to reflect javascript availability for CSS
- h.className = h.className.replace(/\bno-js\b/,'js');
- }
-
- init();
- window.site = site;
+ var site = {
+ platform: 'windows'
+ };
+
+ if (navigator.platform.indexOf("Win32") != -1 ||
+ navigator.platform.indexOf("Win64") != -1) {
+ site.platform = 'windows';
+ } else if (navigator.platform.indexOf("armv7l") != -1) {
+ site.platform = 'android';
+ } else if(navigator.platform.indexOf("Linux") != -1) {
+ site.platform = 'linux';
+ } else if (navigator.userAgent.indexOf("Mac OS X") != -1) {
+ site.platform = 'osx';
+ } else if (navigator.userAgent.indexOf("MSIE 5.2") != -1) {
+ site.platform = 'osx';
+ } else if (navigator.platform.indexOf("Mac") != -1) {
+ site.platform = 'mac';
+ } else {
+ site.platform = 'other';
+ }
+
+ function init() {
+ // Add the platform as a classname on the html-element immediately to avoid lots
+ // of flickering
+ var h = document.documentElement;
+ h.className = h.className.replace("windows", site.platform);
+
+ // Add class to reflect javascript availability for CSS
+ h.className = h.className.replace(/\bno-js\b/,'js');
+ }
+
+ init();
+ window.site = site;
+
+ $(document).ready(function() {
+
+ // set up inline install
+ var btn = $('#download-button');
+ var installUrl = $('#chrome-alpha-dl').attr('href');
+
+ btn.click(function(e) {
+ if (btn.hasClass('chrome') && typeof chrome !== 'undefined') {
+ e.preventDefault();
+ chrome.webstore.install(
+ installUrl,
+ function() {
+ console.log('install success');
+ },
+ function(err) {
+ console.log('install error:', err);
+ }
+ );
+ }
+ });
+
+ });
+
})();
View
@@ -13,9 +13,9 @@
<div id="splash-box">
<div class="download">
- <a href="/downloads/latest" class="button-blue download-button">
- <img src="/img/{{ logo }}" />
- Download Gombot <small>for {{ agent }}</small>
+ <a href="{{ installUrl }}" class="button-blue download-button {{ agent }}" id="download-button">
+ <img src="/img/{{ agent }}-logo.png" />
+ Download Gombot <small>for {{ agentName }}</small>
</a>
<span class="alts">coming soon for Firefox and Apple iPhone</span>
</div>
View
@@ -10,6 +10,9 @@
<link rel="shortcut icon" href="img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="//www.mozilla.org/tabzilla/media/css/tabzilla.css" media="screen" />
+ <!-- gombot alpha chrome store link -->
+ <link rel="chrome-webstore-item" id="chrome-alpha-dl" href="https://chrome.google.com/webstore/detail/maeopofifamhhcdbejkfolecghncglll">
+
<!--[if lte IE 8]>
<script src="js/libs/html5shiv.js"></script>
<![endif]-->
@@ -80,6 +83,8 @@
{% endblock %}
</div>
<script src="//www.mozilla.org/tabzilla/media/js/tabzilla.js"></script>
+ <script src="/js/libs/jquery-1.7.1.min.js"></script>
+ <script src="/js/site.js"></script>
{% block js %}{% endblock %}
</body>
</html>

0 comments on commit 574b9b8

Please sign in to comment.