Tag Archive for dynamic

jQuery dynamic loader – load jquery using pure js javascript if jQ is undefined or does not exist

// jQuery dynamic loader - load jQuery using pure javascript js
// if jQuery is undefined or does not exist, then load it

if ( !window.jQuery ) {
	var jqscript = document.createElement('script');
	jqscript.setAttribute("type", "text/javascript");
	jqscript.setAttribute("src", "<a href="http://code.jquery.com/jquery.min.js");" >http://code.jquery.com/jquery.min.js");</a>
	document.getElementsByTagName("head")[0].appendChild(jqscript);
};

source

AS3 Loading and Using an External CSS File

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	public class CSSFormattingExample extends Sprite {
		var loader:URLLoader;
		var field:TextField;
		var exampleText:String = "<h1>This is a headline</h1>" +
		"<p>This is a line of text. <span class='bluetext'>" +
		"This line of text is colored blue.</span></p>";

		public function CSSFormattingExample():void {
			field = new TextField();
			field.width=300;
			field.autoSize=TextFieldAutoSize.LEFT;
			field.wordWrap=true;
			addChild(field);

			var req:URLRequest=new URLRequest("example.css");

			loader = new URLLoader();
			loader.addEventListener(Event.COMPLETE, onCSSFileLoaded);
			loader.load(req);
		}

		public function onCSSFileLoaded(event:Event):void {
			var sheet:StyleSheet = new StyleSheet();
			sheet.parseCSS(loader.data);
			field.styleSheet=sheet;
			field.htmlText=exampleText;
		}
	}
}


// THE 'example.css' FILE SHOULD LOOK LIKE THIS ...
//p {
//	font-family: Times New Roman, Times, _serif;
//	font-size: 14;
//}
//
//h1 {
//	font-family: Arial, Helvetica, _sans;
//	font-size: 20;
//	font-weight: bold;
//}
//
//.bluetext {
//	color: #0000CC;
//}

source

AS3 Draw a Simple Rectangular Mask

import flash.display.Shape;

var rectMask:Shape = new Shape();
rectMask.graphics.beginFill(0xFF0000, 1);
rectMask.graphics.drawRect(0, 0, 320, 240);
rectMask.graphics.endFill();

displayObjectToBeMasked.mask = rectMask;

source

Retrieve the physical location of a dynamic dataset, file or folder in SAS

data mydata.class;
set sashelp.class;
run;
 
libname mydat6 v6 "%sysfunc(pathname(mydata))";
 
data mydat6.class6;
set mydata.class;
run;

source

Dynamic PHP Properties

class AbstractModel {
        private $data = array();
       
      protected function __set($name, $value) {
        $this->data[$name] = $value;
      }
       
      protected function __get($name) {
        if (array_key_exists($name, $this->data)) {
           return $this->data[$name];
        }
        return null;
      }
       
      protected function __isset($name) {
        return isset($this->data[$name]);
      }
       
      protected function __unset($name) {
        unset($this->data[$name]);
       }
    
    public function printOut()
    {
        echo "<pre>";
        print_r($this);
        echo "</pre>";
    }
}
class User extends AbstractModel {

}

// how to use

$person = new User();

$person->name = 'John';
$person->age = 26;
$person->address = "217 Ziller's road brooklyn NY 11553";
$person->printOut();

$car = new User();
$car->make = 'Honda';
$car->model = 'Civic';
$car->cylinder = 6;
$car->transmission = 'Automatic';
$car->year = 2006;

$truck = new User();
$truck->make = 'Ford';
$truck->model = 'F-150';
$truck->cylinder = 12;
$truck->transmission = 'Manual';
$truck->year = 2006;


$person->car = array('honda' =>$car, 'Ford' => $truck);

$person->printOut();


//output
User Object
(
    [data:private] => Array
        (
            [name] => John
            [age] => 26
            [address] => 217 Ziller's road brooklyn NY 11553
        )

)

User Object
(
    [data:private] => Array
        (
            [name] => John
            [age] => 26
            [address] => 217 Ziller's road brooklyn NY 11553
            [car] => Array
                (
                    [honda] => User Object
                        (
                            [data:private] => Array
                                (
                                    [make] => Honda
                                    [model] => Civic
                                    [cylinder] => 6
                                    [transmission] => Automatic
                                    [year] => 2006
                                )

                        )

                    [Ford] => User Object
                        (
                            [data:private] => Array
                                (
                                    [make] => Ford
                                    [model] => F-150
                                    [cylinder] => 12
                                    [transmission] => Manual
                                    [year] => 2006
                                )

                        )

                )

        )

)

source

The difference between &lt%= and &lt%# in ASP.NET

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" >http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></a>

<html xmlns="<a href="http://www.w3.org/1999/xhtml"" >http://www.w3.org/1999/xhtml"</a> >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p>Equals: <%= this.TestValue %></p>
        <p>Pound: <%# this.TestValue %></p>
        <p>Equals label: <asp:Label runat="server" ID="_equals" Text="<%= this.TestValue %>" /></p>
        <p>Pound label: <asp:Label runat="server" ID="_pound" Text="<%# this.TestValue %>" /></p>
    </div>
    </form>
</body>
</html>

//And the code behind is:

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        _testValue = "2";
    }

    protected void Page_PreRenderComplete(object sender, EventArgs e)
    {
        // DataBind();
        _testValue = "3";
    }

    public string TestValue
    {
        get { return _testValue; }
    }

    private string _testValue = "1";
}

source

Cross-Browser Auto Vertical/Horizontal Centering (Chrome & Forms Compatible)

<style type="text/css">	
        html,body,form {height:100%;margin:0px;padding:0px;}
	html{height:100%;}
	body{height:96%;text-align:center;}/*height 96% fixes scrollbar problems*/
					   /*remove text-align for left justification*/
	form{display:block;}/*chrome & forms*/
	#page{display:table;overflow:hidden;margin:0px auto;padding:0px;min-height:100%;}

	*:first-child+html #page {position:relative;}/*ie7*/
	* html #page{position:relative;}/*ie6*/

	#content_container{display:table-cell;vertical-align: middle;}
	*:first-child+html #content_container{position:absolute;top:50%;}/*ie7*/
	* html #content_container{position:absolute;top:50%;}/*ie6*/

	*:first-child+html #content{position:relative;top:-50%;left:-50%;}/*ie7*/
	* html #content{position:relative;top:-50%;left:-50%;}/*ie6*/

	#page{height:100%;width:100%;}
</style>

<body>
<div id="page">
       <div id="content_container">
               <div id="content">

<!-- centered content here -->

		</div>
       </div>
</div> 
</body>

source

Display Dynamic Copyright Year

echo date(’Y') == ‘2007′ ? ‘2007′ : ‘2007 – ‘.date(’Y');

source

Dynamic age

$birth_date = getdate(strtotime("August 1st 1988"));
$current_date = getdate(time());
echo ($current_date['mday'] >= $birth_date['mday'] AND $current_date['mmonth'] >= $birth_date['mmonth']) ? ($current_date['year'] - $birth_date['year']) : (($current_date['year'] - $birth_date['year']) - 1);

source

php gallery

<?
$dir = 'graphics/images/gallery/tn/';
$files = scandir($dir);
foreach ($files as &$file) {
if ($file!='.' && $file!='..' && $file!='.DS_Store') {
echo "<li><img src="{$dir}{$file}" width="72" height="48" alt="" /></li>";
}
}
?>

source