Permalink
Browse files

Bug 820834: Add support for about:home v4.

  • Loading branch information...
1 parent e3928a7 commit 3e15635937a1e629cbef317c3c1f29be18e830fc @Osmose Osmose committed Dec 21, 2012
Showing with 12 additions and 5 deletions.
  1. +12 −5 standard-js/snippet.html
View
@@ -1,10 +1,18 @@
<script type="text/javascript">
//<![CDATA[
-(function() {
+(function(showDefaultSnippets) {
var SAMPLE_RATE = 0.1;
var STATS_URL = 'https://snippets-stats.mozilla.org/foo.html';
+ // showDefaultSnippets polyfill, available in about:home v4
+ if (typeof showDefaultSnippets !== 'function') {
+ showDefaultSnippets = function() {
+ localStorage['snippets'] = '';
+ showSnippets();
+ }
+ }
+
var snippets = (document.getElementById('snippetContainer')
.getElementsByClassName('snippet'));
if (snippets.length > 0) {
@@ -32,8 +40,7 @@
show_snippet_id);
modifyLinks(show_snippet.getElementsByTagName('a'), parameters);
} else {
- localStorage['snippets'] = '';
- showSnippets();
+ showDefaultSnippets();
}
// Notifies stats server that the given snippet ID
@@ -64,6 +71,6 @@
}
}
-})();
+})(window.showDefaultSnippets);
//]]>
-</script>
+</script>

0 comments on commit 3e15635

Please sign in to comment.