Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first working version of a share widget.... I say working, barely wor…

…king
  • Loading branch information...
commit 5f57e84f268512aa3324719297a98243cb37d1a7 1 parent 3798814
Paul Kinlan authored
View
9 run.sh
@@ -17,10 +17,15 @@ case $1 in
python -m SimpleHTTPServer 9000 &
echo $! > experiments.pid
)
+ (
+ cd widgets
+ python -m SimpleHTTPServer 9001 &
+ echo $! > widgets.pid
+ )
;;
'stop')
- kill $(cat server/server.pid) $(cat examples/examples.pid) $(cat experiments/experiments.pid)
- rm server/server.pid examples/examples.pid experiments/experiments.pid
+ kill $(cat server/server.pid) $(cat examples/examples.pid) $(cat experiments/experiments.pid widgets/widgets.pid)
+ rm server/server.pid examples/examples.pid experiments/experiments.pid widgets/widgets.pid
;;
'restart')
$0 stop ; $0 start
View
32 widgets/embed/share.html
@@ -0,0 +1,32 @@
+<! doctype html>
+<html>
+ <head>
+ <script>
+ document.addEventListener("DOMContentLoaded", function() {
+ var share = document.getElementById("share");
+ share.addEventListener("click", function() {
+ var parentUrl = parent.location.href;
+ var i = new Intent("http://webintents.org/share", "text/uri-list", parentUrl);
+ window.navigator.startActivity(i, function(data) {
+ // The data returned by the request.
+ });
+ });
+
+ // We don't have the webintents, download the framework.
+ if(!!window.Intent == false) {
+
+ // In this imlementation there might be a race.
+ var script = document.createElement("script");
+ script.src = "http://webintents.org/webintents.min.js";
+
+ document.head.appendChild(script);
+ }
+ });
+ </script>
+ <script>
+ </script>
+ </head>
+ <body>
+ <a href="#" id="share"><img src="/images/share.png"><span>Share</span></a>
+ </body>
+</html>
View
BIN  widgets/images/share.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2  widgets/index.html
@@ -36,7 +36,7 @@
<p>
</p>
<ul>
- <li><a href="share">Share</a></li>
+ <li><a href="share.html">Share</a></li>
</ul>
</section>
</body>
View
6 widgets/lib/base.js
@@ -1,7 +1,5 @@
(function(intentName) {
intentName = document.encodeURIComponent(intentName);
- if(!!window.intent == false) {
- // Download the script
- document.writeln("<ifrmae src='" + intentName + ".html' class='intent_widget' />"
- }
+ var baseScript = "";
+ document.writeln("<iframe src='" baseScript + "/" + intentName + ".html' class='intent_widget'></iframe>");
})(/*__EMBED__*/);
View
16 widgets/lib/share.html
@@ -1,16 +0,0 @@
-<! doctype html>
-<html>
- <head>
- <script src="http://webintents.org/webintents.min.js"></script>
- <script>
- var share = document.getElementById("share");
- share.addEventListener("click", function() {
- var i = new Intent("http://webintents.org/share", "text/uri-list", "");
- window.navigator.startActivity(i);
- });
- </script>
- </head>
- <body>
- <a href="#" id="share"><img src="/images/share.png"><span>Share</span></a>
- </body>
-</html>
View
9 widgets/share → widgets/share.html
@@ -19,9 +19,14 @@
</header>
<section>
+ <h2>Example</h2>
+ <div>
+ <script src="/share.js"></script>
+ </div>
<h2>Code</h2>
- <p>
- </p>
+ <pre>
+ <script src="http://widgets.webintents.org/share.js"></script>
+ </pre>
</section>
</body>
</html>
View
3  widgets/share.js
@@ -0,0 +1,3 @@
+(function(intentName) {
+ document.writeln("<iframe src='/embed/share.html' class='intent_widget'></iframe>");
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.