Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts
Tuesday, December 2, 2008
jQuery Resource Links
Plugins and other Javascript resources for jQuery.
Time Entry plugin for jQuery
String manipulation examples and plugin
http://www.stilldesigning.com/dotstring/
Time Entry plugin for jQuery
String manipulation examples and plugin
http://www.stilldesigning.com/dotstring/
Labels:
javascript,
jquery,
links,
methods,
programming,
resources
Friday, November 14, 2008
Prototype JSON Evaluation Method
A simple function showing how Prototype can parse JSON
Sample Prototype Ajax Function using JSON
function parse_json()
{
var data = '{"name":"value", "array_names":["Violet","June"], "key_array": {"red":"opens back door","blue":"opens front door"} }'.evalJSON();
//json is the shiznit
alert(data.name);
alert(data.array_names[1]);
alert(data.key_array['blue']);
}
Sample Prototype Ajax Function using JSON
Javascript:
function php_json()
{
var url = 'json';
var id = 0;
var arrParams =
{
id: id,
}
var hash = $H(arrParams);
var params = hash.toQueryString();
var myAjax = new Ajax.Request(url,
{
parameters: params,
//$('id_of_form_element').serialize(true),
method:'post',
onSuccess: function(transport)
{
strResponse = transport.responseText || "empty";
strResponse = strResponse.replace(/[\r\n]+/g, "");
if(strResponse != 'empty')
{
data = strResponse.evalJSON();
alert(data.key_array.red);
}
else
{
alert('strResponse is empty');
}
},
onFailure: function()
{
alert('Something went wrong with changing the canceled status');
}
});
}
php:
public function json()
{
$this->render = false;
$red = 'opens side door';
$id = $_POST['id'];
$json=END needs 3 < before END though, won't allow this in the editor
{
"name":"value",
"array_names":["Violet","June"],
"key_array": {
"red":"{$red} {$id}",
"blue":"opens front door"
}
}
END;
echo $json;
}
Labels:
evalJSON,
javascript,
JSON,
parse JSON,
prototype
Monday, September 15, 2008
Prototype Resources
Web Developer Resources for Prototype Javascript Framework
Using Prototype
Reorder fields in a table:
http://talkingcode.co.uk/2007/11/14/drag-and-drop-table-rows-with-ajax-scriptaculous-and-prototype/
Free scripts based on prototype
http://www.downloadjavascripts.com/PrototypeJS.aspx
Using Prototype
Reorder fields in a table:
http://talkingcode.co.uk/2007/11/14/drag-and-drop-table-rows-with-ajax-scriptaculous-and-prototype/
Free scripts based on prototype
http://www.downloadjavascripts.com/PrototypeJS.aspx
Labels:
javascript,
prototype,
scriptaculous,
web resources
Tuesday, May 13, 2008
Programming Snippets
http://snipplr.com/search.php
Should build Snippets Table in MYSQL
programming_language
section
title
description
keywords
content
Javascript
FORM
select box controls
get selected value
document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value
change selected option in select box by value
document.getElementById('placement').value="mediaplayer";
change selected option in select box by index number
document.getElementById('adSequence').selectedIndex = 0;
function handler_form1()
{
handler_mode();
placement_value();
}
function handler_mode()
{
//getEl = document.getElementById('mode').options
thisSelectBox = document.getElementById('mode');
selected_mode = document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value;
alert(selected_mode);
switch(selected_mode)
{
case "marquee":
document.getElementById('placement').value="mediaplayer";
document.getElementById('skip_upload').value = 'no';
document.getElementById('ad_width').style.display = 'block';
break;
case "interactive":
document.getElementById('skip_upload').value = 'yes';
document.getElementById('ad_width').style.display = 'none';
break;
}
alert(document.getElementById('skip_upload').value);
}
function placement_value()
{
selected_placement = document.getElementById('placement').options[document.getElementById('placement').selectedIndex].value;
alert(selected_placement);
}
visibility methods
document.getElementById('ad_width').style.visibility = 'visible';
document.getElementById('ad_width').style.visibility = 'hidden';
document.getElementById('ad_width').style.display = 'block';
document.getElementById('ad_width').style.display = 'none';
document.getElementById('ad_width').style.display = 'inline';
//inline
inline will make the element act as an inline element—it will be composed into the output flow as if it were a >, even if it were normally a block element such as a
Prevalidation
onkeyup="javascript:limit_characters_field(this.id,5);numbers_only_field(this.id);"
function limit_characters_field(ID,intMax)
{
thisID = document.getElementById(ID);
if(thisID.value.length > intMax)
{
alert('no more than ' + intMax +' characters');
}
thisID.value = thisID.value.slice(0, intMax);
}
function numbers_only_field(ID)
{
thisID = document.getElementById(ID);
original_str = thisID.value;
var pattern = new RegExp(/\D/);
newStr = original_str.replace(pattern,'');
thisID.value = newStr;
//var result = patt1.test(str);
if(pattern.test(original_str) == true)
{
alert('numbers only');
}
}
AJAX
XMLHttpRequest
properties
FLASH
AS2
Multidimensional Associative Array
info = new Array();
info["fast"] = "peugoet 306";
info["sporty"] = "citreon saxo";
info["old"] = "ford fiesta";
info["types"] = {gold:"24k",silver:"sterling"};//new Array({gold:"24k",silver:"sterling"});
info["material"] = {gems:{diamond:"pretty diamond",silver:"sterling"},wood:"sterling"};
function getData(info)
{
trace("test " + info['old']);
trace("test " + info["types"].silver);
trace("material " + info["material"].gems.diamond);
}
function symbol_htmlNumber_conversion(str)
{
if(!char_symbol_array)
{
var intX:Number = 0;
char_symbol_array = new Array();
char_symbol_array['symbol'] = new Array();
char_symbol_array['htmlNumber'] = new Array();
char_symbol_array['symbol'][intX] = " ";
char_symbol_array['htmlNumber'][intX] = " ";
intX++;
char_symbol_array['symbol'][intX] = "!";
char_symbol_array['htmlNumber'][intX] = "!";
intX++;
char_symbol_array['symbol'][intX] = '"';
char_symbol_array['htmlNumber'][intX] = """;
intX++;
char_symbol_array['symbol'][intX] = "#";
char_symbol_array['htmlNumber'][intX] = "#";
intX++;
char_symbol_array['symbol'][intX] = "$";
char_symbol_array['htmlNumber'][intX] = "$";
intX++;
char_symbol_array['symbol'][intX] = "%";
char_symbol_array['htmlNumber'][intX] = "%";
intX++;
char_symbol_array['symbol'][intX] = "&";
char_symbol_array['htmlNumber'][intX] = "&";
intX++;
char_symbol_array['symbol'][intX] = "'";
char_symbol_array['htmlNumber'][intX] = "'";
intX++;
char_symbol_array['symbol'][intX] = "(";
char_symbol_array['htmlNumber'][intX] = "(";
intX++;
char_symbol_array['symbol'][intX] = ")";
char_symbol_array['htmlNumber'][intX] = ")";
intX++;
char_symbol_array['symbol'][intX] = "*";
char_symbol_array['htmlNumber'][intX] = "*";
intX++;
char_symbol_array['symbol'][intX] = "+";
char_symbol_array['htmlNumber'][intX] = "+";
intX++;
//not finished, still needs more symbols
}
Combo Box Listener
playerEvent_cb.addItem({data:"playing_video",txt:"txt",param2:"param2", label:"playing video"});
playerEvent_cb.addItem({data:"idle",txt:"txt",param2:"param2", label:"idle"});
playerEvent_cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});
cb.addItem({data:"0 param",txt:"txt",param2:"param2", label:"playing video"});
cb.addItem({data:"1 param",txt:"txt",param2:"param2", label:"idle"});
cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});
//cb listener handler
var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {
var item_obj:Object = evt_obj.target.selectedItem;
var i:String;
for (i in item_obj) {
trace(i + ":\t" + item_obj[i]);
}
trace("");
};
playerEvent_cb.addEventListener("change", cbListener);
cb.addEventListener("change", cbListener);
Submit.onPress = function()
{
info.playerEvent = playerEvent_cb.selectedItem['txt'];
trace(info.playerEvent);
}
PHP
Form functions
function mk_option($selectID,$value,$text,$data_arr){
if($data_arr[$selectID])
{
$selected = $data_arr[$selectID] == $value ? ' SELECTED' : '';
}
$option =
''.$text.'';
return $option;
}
sample mk_option:
function getPageDD($data_arr){
//'Home'.
$out =
'';
return $out;
}
BATCH
Basic Commands
md - make directory
Should build Snippets Table in MYSQL
programming_language
section
title
description
keywords
content
Javascript
FORM
select box controls
get selected value
document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value
change selected option in select box by value
document.getElementById('placement').value="mediaplayer";
change selected option in select box by index number
document.getElementById('adSequence').selectedIndex = 0;
function handler_form1()
{
handler_mode();
placement_value();
}
function handler_mode()
{
//getEl = document.getElementById('mode').options
thisSelectBox = document.getElementById('mode');
selected_mode = document.getElementById('mode').options[document.getElementById('mode').selectedIndex].value;
alert(selected_mode);
switch(selected_mode)
{
case "marquee":
document.getElementById('placement').value="mediaplayer";
document.getElementById('skip_upload').value = 'no';
document.getElementById('ad_width').style.display = 'block';
break;
case "interactive":
document.getElementById('skip_upload').value = 'yes';
document.getElementById('ad_width').style.display = 'none';
break;
}
alert(document.getElementById('skip_upload').value);
}
function placement_value()
{
selected_placement = document.getElementById('placement').options[document.getElementById('placement').selectedIndex].value;
alert(selected_placement);
}
visibility methods
document.getElementById('ad_width').style.visibility = 'visible';
document.getElementById('ad_width').style.visibility = 'hidden';
document.getElementById('ad_width').style.display = 'block';
document.getElementById('ad_width').style.display = 'none';
document.getElementById('ad_width').style.display = 'inline';
//inline
inline will make the element act as an inline element—it will be composed into the output flow as if it were a >, even if it were normally a block element such as a
Prevalidation
onkeyup="javascript:limit_characters_field(this.id,5);numbers_only_field(this.id);"
function limit_characters_field(ID,intMax)
{
thisID = document.getElementById(ID);
if(thisID.value.length > intMax)
{
alert('no more than ' + intMax +' characters');
}
thisID.value = thisID.value.slice(0, intMax);
}
function numbers_only_field(ID)
{
thisID = document.getElementById(ID);
original_str = thisID.value;
var pattern = new RegExp(/\D/);
newStr = original_str.replace(pattern,'');
thisID.value = newStr;
//var result = patt1.test(str);
if(pattern.test(original_str) == true)
{
alert('numbers only');
}
}
AJAX
XMLHttpRequest
properties
- readyState
- 0-uninitialized - contains no data
- 1-loading - data is loading
- 2-loaded
- 3-interactive - may interact, but data hasn't finished loading
- 4- complete - object IS initialized
- responseText
- responseXML
- status
- 200 -ok
- 400 - bad request
- 401 - unauthorized
- 403 - forbidden
- 404 - not found
- 500 - internal server error
- statusText
- onreadystatechange
- abort();
- getAllResponseHeaders()
- getResponseHeader("headername")
- open("method","url",async,["user","pword"])
- open("GET","myFile.xml",true)
- send(content)
- setRequestHeader("label","value")
FLASH
AS2
Multidimensional Associative Array
info = new Array();
info["fast"] = "peugoet 306";
info["sporty"] = "citreon saxo";
info["old"] = "ford fiesta";
info["types"] = {gold:"24k",silver:"sterling"};//new Array({gold:"24k",silver:"sterling"});
info["material"] = {gems:{diamond:"pretty diamond",silver:"sterling"},wood:"sterling"};
function getData(info)
{
trace("test " + info['old']);
trace("test " + info["types"].silver);
trace("material " + info["material"].gems.diamond);
}
function symbol_htmlNumber_conversion(str)
{
if(!char_symbol_array)
{
var intX:Number = 0;
char_symbol_array = new Array();
char_symbol_array['symbol'] = new Array();
char_symbol_array['htmlNumber'] = new Array();
char_symbol_array['symbol'][intX] = " ";
char_symbol_array['htmlNumber'][intX] = " ";
intX++;
char_symbol_array['symbol'][intX] = "!";
char_symbol_array['htmlNumber'][intX] = "!";
intX++;
char_symbol_array['symbol'][intX] = '"';
char_symbol_array['htmlNumber'][intX] = """;
intX++;
char_symbol_array['symbol'][intX] = "#";
char_symbol_array['htmlNumber'][intX] = "#";
intX++;
char_symbol_array['symbol'][intX] = "$";
char_symbol_array['htmlNumber'][intX] = "$";
intX++;
char_symbol_array['symbol'][intX] = "%";
char_symbol_array['htmlNumber'][intX] = "%";
intX++;
char_symbol_array['symbol'][intX] = "&";
char_symbol_array['htmlNumber'][intX] = "&";
intX++;
char_symbol_array['symbol'][intX] = "'";
char_symbol_array['htmlNumber'][intX] = "'";
intX++;
char_symbol_array['symbol'][intX] = "(";
char_symbol_array['htmlNumber'][intX] = "(";
intX++;
char_symbol_array['symbol'][intX] = ")";
char_symbol_array['htmlNumber'][intX] = ")";
intX++;
char_symbol_array['symbol'][intX] = "*";
char_symbol_array['htmlNumber'][intX] = "*";
intX++;
char_symbol_array['symbol'][intX] = "+";
char_symbol_array['htmlNumber'][intX] = "+";
intX++;
//not finished, still needs more symbols
}
Combo Box Listener
playerEvent_cb.addItem({data:"playing_video",txt:"txt",param2:"param2", label:"playing video"});
playerEvent_cb.addItem({data:"idle",txt:"txt",param2:"param2", label:"idle"});
playerEvent_cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});
cb.addItem({data:"0 param",txt:"txt",param2:"param2", label:"playing video"});
cb.addItem({data:"1 param",txt:"txt",param2:"param2", label:"idle"});
cb.addItem({data:"video_ended",txt:"txt",param2:"param2", label:"idle"});
//cb listener handler
var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object) {
var item_obj:Object = evt_obj.target.selectedItem;
var i:String;
for (i in item_obj) {
trace(i + ":\t" + item_obj[i]);
}
trace("");
};
playerEvent_cb.addEventListener("change", cbListener);
cb.addEventListener("change", cbListener);
Submit.onPress = function()
{
info.playerEvent = playerEvent_cb.selectedItem['txt'];
trace(info.playerEvent);
}
PHP
Form functions
function mk_option($selectID,$value,$text,$data_arr){
if($data_arr[$selectID])
{
$selected = $data_arr[$selectID] == $value ? ' SELECTED' : '';
}
$option =
''.$text.'';
return $option;
}
sample mk_option:
function getPageDD($data_arr){
//'Home'.
$out =
'';
return $out;
}
BATCH
Basic Commands
md - make directory
Wednesday, January 30, 2008
ajax window layer popup
Great links for z-index dragable windows.
http://prototype-window.xilinus.com/
http://prototype-window.xilinus.com/PWC-OS/
Download it here:
http://prototype-window.xilinus.com/download.html
http://prototype-window.xilinus.com/
http://prototype-window.xilinus.com/PWC-OS/
Download it here:
http://prototype-window.xilinus.com/download.html
Subscribe to:
Posts (Atom)