Tag Archive for events

WordPress post expiration code

***PUT THIS INSIDE THE LOOP, FIRST THING***
<?php  //to check against expiration date;

$currentdate = date("Ymd");
$expirationdate = get_post_custom_values('expiration');
if (is_null($expirationdate)) {
$expirestring = '30005050'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP;
} else {

if (is_array($expirationdate)) {
$expirestringarray = implode($expirationdate);
}
$expirestring = str_replace("/","",$expirestringarray);
} //else
if ( $expirestring > $currentdate ) { ?>

***THEN PUT THE FOLLOWING LINE AT THE VERY END OF THE LOOP***

<?php } //end if for expiration; ?>

source

CiviCRM recent events

<?php

function cmp_date($a,$b) {
if ($a['start_date'] > $b['start_date']) return 1;
if ($a['start_date'] < $b['start_date']) return -1;
return 0;
}

if (module_exists('civicrm')) {
civicrm_initialize(TRUE);
require_once 'api/v2/Event.php';
$params = array ();
$myEvents = civicrm_event_search( $params );
if ($myEvents) {
$count = 0;
$last = '';
usort($myEvents,'cmp_date');
foreach ($myEvents as $event) {
$now = date('Y-m-d H:i:s');
if ($now > $event['start_date']) continue;
$startdate = date('D M j Y',strtotime($event['start_date']));
$enddate = date('D M j Y',strtotime($event['end_date']));

$eventid = $event['id'];
list($title_place, $title_desc) = split(":",$event['title'],2);
if ($last != $startdate) {
$display = '<br /><b>'.$startdate.'</b><br />';
}
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
echo $display;
$count++;
$last = $startdate;
if ($count > <img src='http://www.snippetsmania.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> break;
// this limits the number of events to 8 - put in whatever number suits you
}
if ($count > 0) {

} else {
echo 'No events found.';
}
} else {
echo 'No events found.';
}
}
?>

source

List of Events from CiviCRM

<?php

function cmp_date($a,$b) {
if ($a['start_date'] > $b['start_date']) return 1;
if ($a['start_date'] < $b['start_date']) return -1;
return 0;
}

if (module_exists('civicrm')) {
civicrm_initialize(TRUE);
require_once 'api/v2/Event.php';
$params = array ();
$myEvents = civicrm_event_search( $params );
if ($myEvents) {
$count = 0;
$last = '';
usort($myEvents,'cmp_date');
foreach ($myEvents as $event) {
$now = date('Y-m-d H:i:s');
if ($now > $event['start_date']) continue;
$startdate = date('D M j Y',strtotime($event['start_date']));
$enddate = date('D M j Y',strtotime($event['end_date']));

$eventid = $event['id'];
list($title_place, $title_desc) = split(":",$event['title'],2);
if ($last != $startdate) {
$display = '<br /><b>'.$startdate.'</b><br />';
}
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
echo $display;
$count++;
$last = $startdate;
if ($count > <img src='http://www.snippetsmania.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> break;
// this limits the number of events to 8 - put in whatever number suits you
}
if ($count > 0) {

} else {
echo 'No events found.';
}
} else {
echo 'No events found.';
}
}
?>

source

List of Events from CiviCRM

<?php

function cmp_date($a,$b) {
if ($a['start_date'] > $b['start_date']) return 1;
if ($a['start_date'] < $b['start_date']) return -1;
return 0;
}

if (module_exists('civicrm')) {
civicrm_initialize(TRUE);
require_once 'api/v2/Event.php';
$params = array ();
$myEvents = civicrm_event_search( $params );
if ($myEvents) {
$count = 0;
$last = '';
usort($myEvents,'cmp_date');
foreach ($myEvents as $event) {
$now = date('Y-m-d H:i:s');
if ($now > $event['start_date']) continue;
$startdate = date('D M j Y',strtotime($event['start_date']));
$enddate = date('D M j Y',strtotime($event['end_date']));

$eventid = $event['id'];
list($title_place, $title_desc) = split(":",$event['title'],2);
if ($last != $startdate) {
$display = '<br /><b>'.$startdate.'</b><br />';
}
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
echo $display;
$count++;
$last = $startdate;
if ($count > <img src='http://www.snippetsmania.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> break;
// this limits the number of events to 8 - put in whatever number suits you
}
if ($count > 0) {

} else {
echo 'No events found.';
}
} else {
echo 'No events found.';
}
}
?>

source

Mouse Events a simple drawing application using AS3

package {
import flash.display.Sprite;
import flash.events.MouseEvent;

public class ExampleApplication extends Sprite{
private var _sprite:Sprite;

public function ExampleApplication(){
_sprite = new Sprite();
addChild(_sprite);
_sprite.graphics.beginFill(0xFFFFFF);
_sprite.graphics.drawRect(0, 0, 400, 400);
_sprite.graphics.endFill();

_sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
_sprite.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);

}
private function onMouseDown(event:MouseEvent):void{
_sprite.graphics.lineStyle(1, 0, 1);
_sprite.graphics.moveTo(mouseX, mouseY);
_sprite.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
private function onMouseUp(event:MouseEvent):void{
_sprite.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
}
private function onMouseMove(event:MouseEvent):void{
_sprite.graphics.lineTo(mouseX, mouseY);
}
}
}

source

Stop event propagation (stop an event from bubbling up)

function doSomething (e) {
var event = e || window.event;

[body of event handler function goes here]

if (event.stopPropagation) {
event.stopPropagation();
} else {
event.cancelBubble = true;
}
}

source

Which element was clicked?

<html>
<head>
<script>
/* <a href="http://quirksmode.org" >http://quirksmode.org</a> */
function getEvent (e) {
var event = e || window.event;
if( ! event.target ) {
event.target = event.srcElement
}
return event;
}
</script>

</head>
<body>
<a href="#fred" id="fred" onclick="alert(getEvent(event).target)">foo</a>
</body>
</html>

source

Macromedia Flash – Click para activar el control – Click to activate the control

fix.js:
/*******************************************/
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
var fixObjects = function() {
objects = document.getElementsByTagName("object");
for (var i = 0; i < objects.length; i++)
{
objects[i].outerHTML = objects[i].outerHTML;
}
};
addLoadEvent(fixObjects);
/*******************************************/

index.html:
/*******************************************/
<html>

<head>
<title></title>
<script>
function aler()
{
alert('a ver si anda');
}
</script>
</head>

<body onLoad="aler();"> <!-- si tiene o no una funcion en el OnLoad, el script funciona igual -->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="760" height="100">
<param name=movie value="http://dsnet.com.ar/intro3.swf">
<param name=quality value=high>
<embed src="http://dsnet.com.ar/intro3.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="100"></embed>
</object>

<!--**************EN ALGUN "include" de php por ejemplo**********************-->
<script language="JavaScript" src="fix.js"></script>
<!--*********************************************************************-->

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="760" height="100">
<param name=movie value="http://dsnet.com.ar/intro3.swf">
<param name=quality value=high>
<embed src="http://dsnet.com.ar/intro3.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="760" height="100"></embed>
</object>

</body>

</html>
/*******************************************/

source

event information

/*
Input, textarea, select
-> onclick, onkeydown, onkeyup, onkeypress, onchange, onfocus, onblur, etc.
form
-> onsubmit, onreset
a
-> onclick, onmouseover, onmouseout, onfocus, onblur
body
-> onload, onunload
*/

// ------------------------------
//     reacting to an event

<a onmouseover="name_of_function(params)" href="somepage.html">
<input onkeypress="myVariable = 2;startTest();">
<select onchange="self.location.href = this.options[this.selectedIndex].value;">
<body onunload="window.alert('bye')">

// ------------------------------
//     Executing a function

<a href="javascript:name_of_function(params)">

// ------------------------------
//     Accommodating Netscape 4

//Only Netscape 4 and Escape 4 need this first line
if( document.captureEvents && Event.KEYUP ) { document.captureEvents( Event.KEYUP ); }
document.onkeyup = alertkey;
//where alertKey is a function that will handle the event

// ------------------------------
//     Detecting the keyup event over the page and extracting
//     the key code.

/*
-> iCab only passes key code information in input boxes.
-> Blazer (a version of NetFront) detects limited key events (due to the keyboard handling on the device) and returns nonsense key codes (such as -1987304).
-> WebTV and Escape 4 can only detect key events on text boxes, and may be a little unreliable.
-> OmniWeb 4.2- and Opera 5 for Mac do not pass key code information.
-> Netscape 4 on Linux does not detect any key events properly.
-> Clue browser cannot detect key events.
I am unsure of the capabilities of NetBox, iPanel MicroBrowser and OpenTV here.

*/

// first, tell the browsers to react to the event
if( document.captureEvents && Event.KEYUP ) {
//remove this part if you do not need Netscape 4 to work
document.captureEvents( Event.KEYUP );
}
/* this next line tells the browser to detect a keyup
event over the whole document and when it detects it,
it should run the event handler function 'alertkey' */
document.onkeyup = alertkey;

//now create the event handler function to process the event
function alertkey(e) {
if( !e ) {
//if the browser did not pass the event information to the
//function, we will have to obtain it from the event register
if( window.event ) {
//Internet Explorer
e = window.event;
} else {
//total failure, we have no way of referencing the event
return;
}
}
if( typeof( e.keyCode ) == 'number'  ) {
//DOM
e = e.keyCode;
} else if( typeof( e.which ) == 'number' ) {
//NS 4 compatible
e = e.which;
} else if( typeof( e.charCode ) == 'number'  ) {
//also NS 6+, Mozilla 0.9+
e = e.charCode;
} else {
//total failure, we have no way of obtaining the key code
return;
}
window.alert('The key pressed has keycode ' + e +
' and is key ' + String.fromCharCode( e ) );
}

// ------------------------------
//     Detecting the mouse coordinates when it moves
//     over a positioned element </h3>

if( myReference.captureEvents && Event.MOUSEMOVE ) {
//remove this part if you do not need Netscape 4 to work
myReference.captureEvents( Event.MOUSEMOVE );
}
myReference.onmousemove = alertCoord;

function alertCoord(e) {
if( !e ) {
if( window.event ) {
//Internet Explorer
e = window.event;
} else {
//total failure, we have no way of referencing the event
return;
}
}
if( typeof( e.pageX ) == 'number' ) {
//most browsers
var xcoord = e.pageX;
var ycoord = e.pageY;
} else if( typeof( e.clientX ) == 'number' ) {
//Internet Explorer and older browsers
//other browsers provide this, but follow the pageX/Y branch
var xcoord = e.clientX;
var ycoord = e.clientY;
var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
( navigator.vendor == 'KDE' )
if( !badOldBrowser ) {
if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
//IE 4, 5 & 6 (in non-standards compliant mode)
xcoord += document.body.scrollLeft;
ycoord += document.body.scrollTop;
} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
//IE 6 (in standards compliant mode)
xcoord += document.documentElement.scrollLeft;
ycoord += document.documentElement.scrollTop;
}
}
} else {
//total failure, we have no way of obtaining the mouse coordinates
return;
}
window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
}

source

addEvent() by John Resig

// addEvent() by John Resig
// <a href="http://ejohn.org/projects/flexible-javascript-events/" >http://ejohn.org/projects/flexible-javascript-events/</a>
function addEvent ( obj, type, fn ) {
if ( obj.addEventListener ) {
obj.addEventListener ( type, fn, false );
} else if ( obj.attachEvent ) {
obj["e"+type+fn] = fn;
obj[type+fn] = function ( ) { obj["e"+type+fn] ( window.event ); }
obj.attachEvent ( "on"+type, obj[type+fn] );
}
}

source