Permalink
Browse files

Update index.html

  • Loading branch information...
1 parent 8be59f6 commit e18c01d47945df6463f1d100f7eaac4b6ebabdd3 @autonome committed Feb 11, 2013
Showing with 33 additions and 5 deletions.
  1. +33 −5 index.html
View
@@ -5,6 +5,35 @@
<title>Google Search Widget</title>
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script language="Javascript" type="text/javascript">
+// Install app
+if (navigator.mozApps) {
+ document.querySelector('.installButton').style.display = 'block'
+ var checkIfInstalled = navigator.mozApps.getSelf();
+ checkIfInstalled.onsuccess = function () {
+ if (checkIfInstalled.result) {
+ // Already installed
+ }
+ else {
+ document.querySelector('.installButton').style.display = 'block'
+ var install = document.querySelector("#install"),
+ manifestURL = location.href.substring(0, location.href.lastIndexOf("/")) + "/manifest.webapp";
+ install.className = "show-install";
+ install.onclick = function () {
+ var installApp = navigator.mozApps.install(manifestURL);
+ installApp.onsuccess = function(data) {
+ install.style.display = "none";
+ };
+ installApp.onerror = function() {
+ alert("Install failed\n\n:" + installApp.error.name);
+ };
+ };
+ }
+ };
+}
+else {
+ console.log("Open Web Apps not supported");
+}
+
google.load(
'search',
'1',
@@ -51,11 +80,9 @@
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 9pt;
margin: 0 auto;
- /*
- background-image: url('berlin.jpg');
- background-color: #fff;
- background-size: cover;
- */
+ }
+ .installButton {
+ display: none;
}
TABLE.gsc-resultsHeader,
INPUT.gsc-search-button,
@@ -87,5 +114,6 @@
</head>
<body>
<div id="searchcontrol">Loading</div>
+ <div class='installButton'><button>Install</button></div>
</body>
</html>

0 comments on commit e18c01d

Please sign in to comment.