Skip to content
Permalink
Browse files
- added a conditional to check if the badge is running on the same do…
…main as where the config.xml is hosted; if not, the app will use PHP/cURL to get at that XML file, to avoid sandboxing issues;

- introduced 2 sizes of the badge, so the embedding page (using an iframe) can decide how to present the app: regular or small (check README for instructions on how to embed);

git-svn-id: https://svn.apache.org/repos/asf/incubator/flex/utilities/trunk@1376607 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
erikdebruin committed Aug 23, 2012
1 parent 0a63644 commit ada1b257bed009611241804ecc2cbffb10dbb569
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 104 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -49,6 +49,31 @@ public class InternetUtil
return _instance;
}

//--------------------------------------------------------------------------
//
// Class methods
//
//--------------------------------------------------------------------------

//----------------------------------
// getTLDFromURL
//----------------------------------

public static function getTLDFromURL(url:String):String
{
var array:Array;

var result:String = url;

if (result.indexOf(Constants.URL_PREFIX) > -1)
result = result.split("/")[2];

array = result.split(".");
array.shift();

return array.join(".");;
}

//--------------------------------------------------------------------------
//
// Constructor
@@ -132,7 +157,7 @@ public class InternetUtil
// fetch
//----------------------------------

public function fetch(fetchURL:String, fetchCompleteHandler:Function):void
public function fetch(fetchURL:String, fetchCompleteHandler:Function, args:String = null):void
{
_callback = fetchCompleteHandler;

@@ -144,7 +169,7 @@ public class InternetUtil
_urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
_urlLoader.addEventListener(Event.COMPLETE, fetchResultHandler);
_urlLoader.addEventListener(IOErrorEvent.IO_ERROR, fetchResultHandler);
_urlLoader.load(new URLRequest(fetchURL));
_urlLoader.load(new URLRequest(fetchURL + ((args) ? "?" + args : "")));
}

}
@@ -0,0 +1,7 @@
The code implements functionality to be viewed through an iframe on another domain. Please use one of these to embed the badge on your site or communications:

Regular size (302 x 302)
<iframe name="afSDKInstallBadgeRegular" src="[domain + path to]/InstallApacheFlexBadge.html" frameborder="0" height="302" marginheight="0" marginwidth="0" scrolling="no" width="302"></iframe>

Small size (402 x 84)
<iframe name="afSDKInstallBadgeSmall" src="[domain + path to]/InstallApacheFlexBadge.html" frameborder="0" height="84" marginheight="0" marginwidth="0" scrolling="no" width="402"></iframe>
@@ -0,0 +1,8 @@
<?php

$ch = curl_init($_GET["url"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
curl_close($ch);

?>
@@ -14,84 +14,78 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>

<title>${title}</title>
<!DOCTYPE html>

<meta name="google" value="notranslate" />
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css" media="screen">
html, body { height: 100%; }
body { background-color: ${bgcolor}; margin: 0; overflow: auto; padding: 0; text-align: center; }
<title>${title}</title>

<style type="text/css">
body { margin: 0; padding: 0; }
object:focus { outline: none; }
#flashContent { display: none; }
#${application} { border: 1px solid #172647; }
</style>

<!--
SWFObject v2.2 <http://code.google.com/p/swfobject/>
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>

<script type="text/javascript">
var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
var xiSwfUrlStr = "";
var flashvars = {};
var params = {};
params.quality = "high";
params.bgcolor = "${bgcolor}";
params.allowscriptaccess = "sameDomain";
params.allowfullscreen = "true";
var attributes = {};
attributes.id = "${application}";
attributes.name = "${application}";
attributes.align = "middle";
swfobject.embedSWF("${swf}.swf", "flashContent", "${width}", "${height}", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
swfobject.createCSS("#flashContent", "display: block; text-align: left;");
/* use strict */

var swfVersionStr, params, attributes;

function displayType() {
if ((window.top != window.self) && window.parent)
return window.name;

return "";
}

function init() {
var prefix, theElement, theHeight, theWidth, widget;

if (typeof window.innerWidth === 'number') {
theHeight = window.innerHeight;
theWidth = window.innerWidth;
} else {
theElement = window.document.documentElement;

theHeight = theElement.clientHeight;
theWidth = theElement.clientWidth;
}

widget = document.getElementById("${application}");
widget.style.height = (theHeight - 2) + "px";
widget.style.width = (theWidth - 2) + "px";
}

swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
params = { quality: "high", bgcolor: "${bgcolor}", allowscriptaccess: "sameDomain",
allowfullscreen: "true" };
attributes = { id: "${application}", name: "${application}" };

swfobject.embedSWF("${swf}.swf", "flashContent", "0", "0",
swfVersionStr, "", {}, params, attributes);

swfobject.createCSS("#flashContent", "display: block;");
</script>

</head>
<body>
<body onload="init();">
<div id="flashContent">
<p>
To view this page ensure that Adobe Flash Player version
${version_major}.${version_minor}.${version_revision} or greater is installed.
</p>
<script type="text/javascript">
var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
+ pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
</script>
</div>

<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<!--<![endif]-->
<!--[if gte IE 6]>-->
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
${version_major}.${version_minor}.${version_revision} or greater is not installed.
</p>
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</noscript>
</body>
</html>

0 comments on commit ada1b25

Please sign in to comment.