gamblelyn/html5 css js shiv shell ( HTML)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<!--******* CSS: ******-->
<link rel="stylesheet" href="css/basic.css" media="all" />
<link rel="stylesheet" href="css/style.css" media="screen" />
<title>HTML5 Basic Shell with js and css external and internal</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup, menu, nav, section { display: block; }
/*<article> For external content, like text from a news-article, blog, forum, or any other content from an external source*/
/*<figure> For grouping a section of stand-alone content, could be a video, images or diagrams, code etc*/
/*<section> For a section in a document. Such as chapters, headers, footers, or any other sections of the document*/
/*The <menu> tag defines a list or menu of commands. */
/*The <menu> tag is used for context menus, toolbars and for listing form controls and commands.*/
/* FONTS - to get other font kits visit: fontsquirrel.com then change name accordingly, and put fonts in fonts folder in the root*/
@font-face {
font-family: 'MisoLight';
src: url('fonts/miso-light-webfont.eot?') format('eot'),
url('fonts/miso-light-webfont.woff') format('woff'),
url('fonts/miso-light-webfont.ttf') format('truetype'),
url('fonts/miso-light-webfont.svg#webfontR7AhzoT1') format('svg');
}
html {
background: #4e4928 url(images/site-background.jpg) repeat-x;
width:100%;
height:100%;
}
/*UNIVERSAL*/
a:link{
color:#ffef70;
text-decoration:none;
}
a:visited{
color:#c6ba57;
text-decoration:none;
}
a:hover{
color:#fff;
text-decoration:underline;
}
body{
color:#bfc590;
font:13px Georgia, "Times New Roman", Times, serif;
text-align:center;
margin:0;
padding:0;
}
.main {margin: 0 auto;}
header {height: 30px;}
#pagewrapper{
width:760px;
text-align:left;
margin-left:auto;
margin-right:auto;
}
#contentwrapper{
clear:both;
float:left;
padding-bottom:20px;
}
figure{
}
h1{
padding:0;
margin:0;
}
h2{
padding:0;
margin:0;
}
h1.title {font-size: 18px;}
/*NAVIGATION*/
nav{ float:left; width:800px; }
nav a{ color:#ffe61d; }
nav a:hover{ color:#fff; }
nav ul{
float:left;
list-style:none;
margin:0;
padding:0;
width:630px;
height:57px;
}
nav ul li{
float:left;
margin:0;
padding:0;
}
nav ul li a{
float:left;
font:normal 16px Georgia, "Times New Roman", Times, serif;
display:block;
height:35px;
padding:15px 14px 0 14px;
margin:0;
}
nav ul li a:hover{
text-decoration:none;
color:#fff;
}
nav ul li.current a{
background: #555;
}
nav ul li.current a{
background: #777;
}
.fl {float: left;}
.fr {float: right;}
.clear {
overflow: auto;
width: 100%
}
</style>
</head>
<body class="main">
<div id="pagewrapper">
<header>
<h1 class="title"></h1>
</header>
<figure class="fl">
<img src="images/portfolio-logo.png" />
</figure>
<figure class="fr">
<img src="images/tablethome.png" />
</figure>
<div class="clear"></div>
<div id="contentwrapper">
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Clients</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
</nav>
<section id="content" class="homepage">
<article id="">
Article -For external content, like text from a news-article, blog, forum, or any other content from an external source
</article>
</section>
<aside>
Sidebar
</aside>
</div>
<!--End Contentwrapper begin footer-->
<footer>
Footer
</footer>
</div>
</body>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function() {
//alert('check')
});
</script>
</html>???
this has place for external styles and the css start for a button sprite. Also has some comments about new html5 markup.
Michael Robin/Compile-time regex's and pattern-based dispatching ( python)
import re Commands = \ [ [ 'description of pattern 1', r'X (?P<num>\d),(?P<name>.*)$', aClass.cmd1], [ 'pattern 2', r'Widget (?P<part>.*)$', aClass.cmd2] ] """ Clobber each regex str w/compiled version """ for cmd in Commands: try: cmd[1] = re.compile( cmd[1] ) except: print "Bad pattern for %s: %s" % ( cmd[0], cmd[1] ) assert 0, "Doh!" class myCommands: def _dispatch( self, cmdList, str): """ Find a match for str in the cmdList, and call the associated method with arguments that are the matching grouped sub-exprs from the regex. """ for cmd in cmdList: found = cmd[1].match( str) # or .search() if found: return cmd[2]( self, *found.groups() ) return None def runCommand( self, cmd): self._dispatch( Commands, cmd) def cmd1( self, num, name): print "The number for %s is %d" % (name, int(num)) return 42 def cmdWidget( self, partnum): print "Widget serial #: %d" % partnum ... """ Method 2 - instead of a disptatch table, use function attributes. Put these fn's in a modules called 'myCommands', for example. """ def cmdDoThis( name, num): print "The number for %s is %d" % (name, int(num)) return 42 cmdDoThis.patt = r'X (?P<num>\d),(?P<name>.*)$' def cmdWidget( partnum): print "Widget serial #: %d" % partnum cmdWidget.patt = r'Widget (?P<part>.*)$' # and later... import sys def autoDispatch( str, module=sys.modules[__name__] ): for entry in dir(module): # use whatever prefix you like, if desired if entry.startswith( 'cmd'): fn = cmds.__dict__[entry] if not fn.regobj: fn.regobj = re.compile( fn.cmd ) found = fn.regobj.match( str) if found: return fn( *found.groups() ) import myCommands ... autoDispatch( 'Widget 1234A', myCommands)
Although python has no literal representation for compiled regular expressions (which is good) you can compile them at Python read/compile-time. You can also use regexs to match strings and automatically call funtions with arguments that are based on the groups of the matched strings.
jonniespratley/JSON To SQL Generator (JQUERY) ( PHP)
<?php
/**
* I am a JSON Query builder
*
* Here is a inline example of how to create your json when sending it.
*
* <code>
* $flexJSON = '[{"table":"TABLENAME","objectName":"FIELDNAME","objectValue":"FIELDVALUE","database":"DATABASE","tableKey":"PRI KEY","objectKey":"RECORD KEY"}]';
* $j = new JSONQuery( 'host', 'user', 'pass' );
* $j->dump( $j->buildQuery( $flexJSON, 'INSERT' ), 'INSERT JSON ' );
* $j->dump( $j->buildQuery( $flexJSON, 'UPDATE' ), 'UPDATE JSON' );
* $j->dump( $j->buildQuery( $flexJSON, 'DELETE' ), 'DELETE JSON' );
* $j->setJSONString( $flexJSON );
* $j->dump( $j->getJSONString(), 'JSON STRING' );
* </code>
*
* @author Jonnie Spratley
* @copyright 2009 http://jonniespratley.com
* @version 0.7
*
*/
class JSONQuery
{
private $mysqli;
private $jsonArray;
private $jsonString;
private $jsonQuery;
/**
* Database Link
*
* @param [database] $link
*/
public function __construct( $link )
{
$this->mysqli = $link;
}
/**
* I build a INSERT/UPDATE/DELETE from a json string.
* I can either auto update the database, or return the sql.
* <code>
* [{"table":"TABLENAME","objectName":"FIELDNAME","objectValue":"FIELDVALUE","database":"DATABASE","tableKey":"PRI KEY","objectKey":"RECORD KEY"}]
* </code>
*
* @param [json] $json JSON string like [{"table":"TABLENAME","objectName":"FIELDNAME","objectValue":"FIELDVALUE","database":"DATABASE","tableKey":"PRI KEY","objectKey":"RECORD KEY"}]
* @param [string] $type INSERT/UPDATE/DELETE
* @param [boolean] $autoInsert = false Auto update database
* @return unknown
*/
public function buildQuery( $json, $type, $autoInsert = false )
{
$jsonString = str_replace ( "\\", "", $json );
$jsonArray = json_decode ( $jsonString, true );
$query = '';
$queryArray = array ();
switch ( $type )
{
case 'INSERT' :
//do insert statement
foreach ( $jsonArray as $record )
{
$query = sprintf ( 'INSERT INTO %s.%s SET %s = "%s"', $record [ 'database' ], $record [ 'table' ], $record [ 'objectName' ], $record [ 'objectValue' ] );
//echo $query;
$queryArray [] = $query;
}
break;
case 'UPDATE' :
foreach ( $jsonArray as $record )
{
$query = sprintf ( 'UPDATE %s.%s SET %s = "%s" WHERE %s = "%s"', $record [ 'database' ], $record [ 'table' ], $record [ 'objectName' ], $record [ 'objectValue' ], $record [ 'tableKey' ], $record [ 'objectKey' ] );
//echo $query;
$queryArray [] = $query;
}
break;
case 'DELETE' :
foreach ( $jsonArray as $record )
{
$query = sprintf ( 'DELETE FROM %s.%s WHERE %s = "%s"', $record [ 'database' ], $record [ 'table' ], $record [ 'tableKey' ], $record [ 'objectKey' ] );
//echo $query;
$queryArray [] = $query;
}
break;
default :
echo 'Specify a type of statement';
exit ();
break;
}
if ( $autoInsert )
{
return $this->_batchQuery ( $queryArray );
}
return $queryArray;
}
/**
* I take an array of sql statements and execute them in order to the database.
*
* @param [array] $sql array of sql statements
*/
private function _batchQuery( $sql )
{
foreach ( $sql as $q )
{
$result = $this->mysqli->query ( $q );
if ( $result )
{
printf ( "%d row affected.", $this->mysqli->affected_rows );
}
}
}
private function _filterTable( $s )
{
$tablename = stripos ( $s, 'table' );
return $tablename;
}
/**
* Escape SQL
*
* @param [string] $str
* @return escaped string
*/
private function _sqlQuote( $str )
{
if ( ! isset ( $str ) )
return ( "NULL" );
$func = function_exists ( "mysqli_escape_string" ) ? "mysqli_escape_string" : "addslashes";
return ( "'" . $func ( $str ) . "'" );
}
/**
* @return associative array
*/
public function getJSONArray()
{
return $this->jsonArray;
}
/**
* @return json string
*/
public function getJSONString()
{
return $this->jsonString;
}
/**
* @return sql query
*/
public function getQuery()
{
return $this->query;
}
/**
* @param associative $jsonArray
*/
public function setJSONArray( $json )
{
$jsonArray = json_decode ( $json, true );
$this->jsonArray = $jsonArray;
}
/**
* @param json $jsonString
*/
public function setJSONString( $jsonString )
{
$this->jsonString = $jsonString;
}
/**
* @param string $query
*/
public function setJSONQuery( $query )
{
$this->jsonQuery = $query;
}
/**
* I dump vars
*
* @param [var] $var
* @param [string] $name
*/
public function dump( $var, $name = 'Variable Dump' )
{
echo "<b>$name</b><br/>";
echo '<pre>';
print_r ( $var );
echo '</pre>';
}
}
?>
spark9/asp.net inline tags ( ASP)
<% ... %> The most basic inline tag, basically runs normal code:
<% if (User.IsInRole("admin")) { %> You can see this <% } else { %> You are no admin fool! <%} %>
http://msdn2.microsoft.com/en-us/library/ms178135(vs.80).aspx
<%= ... %> Used for small chunks of information, usually from objects and single pieces of information like a single string or int variable:
The Date is now <%= DateTime.Now.ToShortDateString() %> The value of string1 is <%= string1 %> http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx
note: <%= is the equivalent of Response.Write() - Courtesy of Adam from the US,thanks!
<%# .. %> Used for Binding Expressions; such as Eval and Bind, most often found in data controls like GridView, Repeater, etc.:
<asp:Repeater ID="rptMeetings" DataSourceID="meetings" runat="server"> <ItemTemplate> <%# Eval("MeetingName") %> </ItemTemplate> </asp:Repeater>
http://msdn2.microsoft.com/en-us/library/ms178366.aspx
<%$ ... %> Used for expressions, not code; often seen with DataSources:
<asp:SqlDataSource ID="party" runat="server" ConnectionString="<%$ ConnectionStrings:letsParty %>" SelectCommand="SELECT * FROM table" /> http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx
<%@ ... %> This is for directive syntax; basically the stuff you see at the top your your aspx pages like control registration and page declaration:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %> <%@ Register TagPrefix="wp" Namespace="CustomWebParts" %>
http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx
<% ... %> This is a server side comment, stuff you don't want anyone without code access to see:
<asp:Label ID="lblAwesome" runat="server" /> <% sometimes end users make me angry %> <asp:LinkButton ID="lbEdit" Text="Edit" OnClick="Edit_Click" runat="server" /> http://msdn2.microsoft.com/en-us/library/4acf8afk.aspx
paulgrenwood/Equal Height Columns ( CSS)
// HTML
<div class="equal">
<div class="row">
<div class="one">
<h2>This is a box</h2>
<p>This box has less content than the one next to it, but both boxes will still have equal height. No background-image trickery.</p>
</div>
<div class="two">
<h2>This is another box</h2>
<p>This box has more content than the others. If all boxes were table cells, the cell with the most content would decide the height of all cells. It works like that here too, but this is not a table.</p>
<p>Instead, display:table, display:table-row and display:table-cell are used to make divs behave like table cells. Excellent. Too bad it doesn&rsquo;t work in you-know-which-browser. It does, however, work in modern browsers like Mozilla, Opera, Safari, Firefox, OmniWeb, Camino, and Netscape.</p>
<p>Read the related blog entry for more info: <a href="/archive/200405/equal_height_boxes_with_css/">Equal height boxes with CSS</a>.</p>
</div>
<div class="three">
<p>This box has even less content. Anything in it is vertically centered.</p>
</div>
</div>
</div>
// CSS
/* Layout rules */
.equal {
display:table;
border-collapse:separate;
}
.row {
display:table-row;
}
.row div {
display:table-cell;
}
/* Styling rules to make the example look nicer */
html,body {
margin:0;
padding:0;
color:#000;
background:#fff;
}
body {
font:76%/140% "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
}
.equal {
margin:10px auto;
border-spacing:10px;
background:#898B60;
width:80%;
}
.row div {
background:#fff;
}
.row div.one {
width:40%;
}
.row div.two {
width:40%;
}
.row div.three {
vertical-align:middle;
}
.row div h2 {
margin:0 0 0.5em 0;
padding:0.5em 10px;
font-size:1.2em;
color:#fff;
background:#595B30;
}
.row div p {
font-size:0.94em;
margin:0.5em 0;
padding:0 10px;
}
#labfooter {
text-align:center;
}
Ed Blake/Win32com - Batch repathing of Autocad Xrefs ( python)
# Relative-refs.pyw
"""A short python script for repathing xrefs in Autocad."""
import win32com.client,os, os.path, tkFileDialog
from Tkinter import *
from tkMessageBox import askokcancel
from time import sleep
# Get a COM object for Autocad
acad = win32com.client.Dispatch("AutoCAD.Application")
def repath(filename):
print 'Repathing %s...' %filename
doc = acad.Documents.Open(filename)
blocks = doc.Database.Blocks # Internally xrefs are just blocks!
xrefs = [item for item in blocks if item.IsXRef]
if xrefs:
for xref in xrefs:
old_path = xref.Path
new_path = os.path.join('..\\x-ref\\',os.path.basename(old_path))
xref.Path = new_path
print 'Old path name was %s, new path name is %s.\n' %(old_path, new_path)
try:
doc.Close(True) # Close and save
except: # Something when wrong,
doc.Close(False) # close then report it
raise
class Logger:
"""A filelike object that prints its input on the screen."""
def __init__(self, logfile=None):
"""Takes one argument, a file like object for logging."""
print 'Starting logger...'
if not logfile:
self.logfile = open('relative-refs.log','w')
else:
self.logfile = logfile
sys.stderr = self # Super cheap logging facility...
sys.stdout = self # Just redirect output to a file.
print 'Logger running...'
def write(self, line):
sys.__stdout__.write(line)
self.logfile.write(line)
def close(self):
"""The close method restores stdout and stderr to normal."""
self.logfile.close()
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__
class Tktextfile:
"""A file like interface to the Tk text widget."""
def __init__(self, root):
"""Create a scrollable text widget to be written to."""
self.root = root
self.text = Text(root,width=40,height=20)
self.text.pack(side=LEFT, expand=True, fill=BOTH)
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT,fill=Y)
self.text.configure(yscrollcommand=scrollbar.set)
scrollbar.config(command=self.text.yview)
self.text.focus()
def write(self, line):
"""Write method for file like widget."""
self.text.insert(INSERT, line)
self.text.see(END)
def close(self):
"""Fake close method."""
pass
if __name__ == '__main__':
if acad.Visible:
acad.Visible = False
root = Tk()
text = Tktextfile(root)
logger = Logger(text)
dir = tkFileDialog.askdirectory()
answer = askokcancel('RePath','Re path all dwg files in ' + dir + '?')
if answer:
for dirpath, subdirs, files in os.walk(dir):
for name in files:
ext = name.split('.')[-1] or ''
# We want dwg files which are not in the x-ref directory
if ext.lower() == 'dwg' and 'x-ref' not in dirpath.lower():
drawing = os.path.join(dirpath, name)
try:
repath(drawing)
except:
print 'Unable to repath drawing %s!' %drawing
root.update()
acad.Visible = True
This script asks for a base directory and then changes all xrefs in all drawings in all subdirectories so that they use relative paths. To use it just copy it somewhere in your target directory structure and run.
Adnan Ilyas/Selecting ALL CheckBoxes in The GridView ( C#)
Introduction:
GridView is a new data bound control introduced by Microsoft in Visual Studio.NET 2005. Most of the operations like sorting, paging and selecting item from the GridView is already built in and you can use it through the design view. In this article I will explain that how you can select single as well as all the checkboxes which are inside the GridView control.
Selecting Checkboxes inside the GridView Control:
GridView has CheckboxField column which maps the checkbox to a field in the database. In this article we won't be using that, we will make a checkbox in a template column. Simply add a asp:checkbox control in the item template of the GridView control. If you are working with Datagrid control and want the same functionality than please check out my article Selecting Checkboxes inside the Datagrid control.
The html code looks something like this:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" DataKeyNames="PersonID" DataSourceID="mySource" Width="366px" CellPadding="4" ForeColor="#333333" GridLines="None">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="PersonID" HeaderText="PersonID" InsertVisible="False"
ReadOnly="True" SortExpression="PersonID" />
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderTemplate>
</HeaderTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Now in the button click event write this code:
// StringBuilder object
StringBuilder str = new StringBuilder();
// Select the checkboxes from the GridView control
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
bool isChecked = ((CheckBox) row.FindControl("chkSelect")).Checked;
if (isChecked)
{
// Column 2 is the name column
str.Append(GridView1.Rows[i].Cells[2].Text);
}
}
// prints out the result
Response.Write(str.ToString());
The code above just iterates through the GridView and selects the checked checkboxes. Later it appends the selected value to a StringBuilder object. In order to use StringBuilder you will need to add the System.Text namespace.
Making a CheckAll functionality:
To add a check all functionality in the GridView simply add a html checkbox to the header template of the checkbox column.
<HeaderTemplate>
<input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
</HeaderTemplate>
SelectAllCheckboxes JavaScript method:
<script language=javascript>
function SelectAllCheckboxes(spanChk){
// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;
elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
//elm[i].click();
if(elm[i].checked!=xState)
elm[i].click();
//elm[i].checked=xState;
}
}
</script>
This is it. I hope you like the article, happy coding!
You can make a checkbox to select or de-select all the checkboxes in the gridview saving yourself from clicking each one by one
ebukva/upgradeSearchOnWebkitBrowsers ( JavaScript)
/*
upgradeSearchOnWebkitBrowsers function makes the search
input boxes in an HTML form appear and behave like
search fields in Mac OS X applications.
The function first looks if the page contains any forms
then looks for an input field that has the name="search"
attribute. When such input is found, it injects three
new attributes that make Webkit browsers (such as Safari
and OmniWeb) show the goodie.
JavaScript is used to do this since these particular attributes
are not standard HTML and will break the validation.
All non-Webkit browsers should ignore the attributes
and display the regular input box.
Dependencies:
- addLoadEvent (http://snipplr.com/view/1679/addloadevent/)
*/
function upgradeSearchOnWebkitBrowsers() {
if (!document.getElementById) return false; // if the browser doesn't support this dom method, drop out
var forms = document.getElementsByTagName("form");
if (forms[0] == null) return false; // if there are no forms on this page, drop out
var form = forms[0];
for (var j=0; j < forms.length; j++) { // if there are multiple forms loop through them
form = forms[j];
inputs = form.getElementsByTagName("input");
for (var i=0; i < inputs.length; i++) { // loop through all inputs until we find the one named "search"
var inputName = inputs[i].getAttribute("name");
if (inputName == "search") {
inputs[i].setAttribute("type","search");
inputs[i].setAttribute("autosave","autoSaveSearches");
inputs[i].setAttribute("results","5");
return false;
}
}
}
}
addLoadEvent(upgradeSearchOnWebkitBrowsers);
weavermedia/Tweenlite timeline setup ( ActionScript 3)
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
OverwriteManager.init(OverwriteManager.AUTO);
TweenPlugin.activate([GlowFilterPlugin, TintPlugin]);
// create some variables used in tweens
var tweenTime:Number = 0.5;
var pauseTime:Number = 0.2;
// create timeline
var myTimeline:TimelineLite = new TimelineLite();
// .append adds tweens onto the end of existing ones - like TweenGroup.ALIGN_SEQUENCE
myTimeline.append(new TweenLite(mc1, tweenTime, {x:100}));
myTimeline.append(new TweenLite(mc2, tweenTime, {y:100}));
myTimeline.append(new TweenLite(nul, pauseTime, {})); // simple PAUSE - use any mc in the tween
myTimeline.append(new TweenLite(mc1, tweenTime, {x:150}));
myTimeline.append(new TweenLite(mc1, tweenTime, {x:250, delay:-tweenTime})); // use negative delays for simultaneous tweens
czterystaczwarty/Multilevel dropdown menu in puer CSS ( CSS)
/* DROPDOWN MENU */
/* !! dont insert fonts and colors here */
.dropdown-menu li{
float: left;
position: relative;
}
/* 2 level */
.dropdown-menu li ul{
display: none;
position: absolute;
top: 30px; /* height of first level bar */
left: 0px;
}
.dropdown-menu li ul li{
float: none;
}
.dropdown-menu li ul li ul{
left: 120px; /* width 2+ level */
top: 0;
}
.dropdown-menu li:hover ul {/*show 2+ level*/
display: block;
}
.dropdown-menu li:hover ul li ul{/*hide 3+ level*/
display: none;
}
.dropdown-menu li ul li:hover ul{
display: block;
}
.dropdown-menu li ul li:hover ul li ul{
display: none;
}
.dropdown-menu li ul li ul li:hover ul{
display: block;
}
.dropdown-menu li ul li ul li:hover ul li ul{
display: none;
}
/* DROPDOWN MENU - end */
/* view - like u wish */
#nav{
width: 950px;
height: 30px;
margin: 0 auto;
background: #ccc;
}
#nav ul li{
line-height: 30px;
height: 30px;
}
#nav ul ul{
background: #bbb;
}
#nav ul ul ul{
background: #aaa;
}
#nav ul ul ul ul{
background: #999;
}
#nav ul li ul li{
width: 120px;
}
container id: nav list class: dropdown-menu
prwhitehead/Wordpress: Create custom database tables ( PHP)
function create_stats(){
global $wpdb;
//create the name of the table including the wordpress prefix (wp_ etc)
$search_table = $wpdb->prefix . "stats";
//$wpdb->show_errors();
//check if there are any tables of that name already
if($wpdb->get_var("show tables like '$search_table'") !== $search_table)
{
//create your sql
$sql = "CREATE TABLE ". $search_table . " (
stat_id mediumint(12) NOT NULL AUTO_INCREMENT,
business_id mediumint(9),
time VARCHAR (20) NOT NULL,
user_ip text(20) NOT NULL,
user_id mediumint(9),
user_browser text NOT NULL,
referral_page text NOT NULL,
type text,
UNIQUE KEY stat_id (stat_id));";
}
//include the wordpress db functions
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);
//register the new table with the wpdb object
if (!isset($wpdb->stats))
{
$wpdb->stats = $search_table;
//add the shortcut so you can use $wpdb->stats
$wpdb->tables[] = str_replace($wpdb->prefix, '', $search_table);
}
}
//add to front and backend inits
add_action('init', 'create_stats');
Create custom database tables within wordpress. Just replace 'stats' with the name of your table, and then the $sql variable with your create table sql.
reyco1/ToolTip ( ActionScript)
MovieClip.prototype.toolTip = function(msg:String) {
this.onRollOver = function() {
timer = setInterval(showTip, 500);
theObject = this._name.toString();
function showTip() {
clearInterval(timer);
_root.createTextField("toolTip", 1000, _root._xmouse+10, _root._ymouse-30, 10, 10);
_root.toolTip.autoSize = true;
_root.toolTip.border = true;
_root.toolTip.background = true;
_root.toolTip.backgroundColor = 0xFFFFC9;
var myformat:TextFormat = new TextFormat();
myformat.font = "Arial";
myformat.size = 10;
_root.toolTip.text = msg;
_root.toolTip.setTextFormat(myformat);
onEnterFrame = function () {
_root.toolTip._x = _root._xmouse+10;
_root.toolTip._y = _root._ymouse-30;
};
}
};
this.onRollOut = function() {
_root.toolTip.removeTextField();
clearInterval(timer);
};
};
//-< use it like this >--\\
my_mc.toolTip("Hi there.");
add a tooltip to any object
xTraCD/Quick PHP Menu ( PHP)
1a. Make a folder for your new project (like php_menu or something) We will be making master.css, index.php, and body.php
;[FOLDER TREE]:
[HOST FOLDER]
-->inc [
--->body.php
]
-->css [
--->master.css
--->reset.css
]
-> index.php
2. Open your IDE, I'm using PHP Designer, but you can definitely use notepad, or some IDE like notepad++.
3. Create a new PHP Document, save it as index.php
[PHP for step 3]
[index.php]
<?php
require_once "inc/body.php";
?>
4. Create a new XHTML 1.01 transitional document. Enter the code from below
[HTML for step 4]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xht......dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Menu</title>
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<link href="css/reset.css" rel="stylesheet" type="text/css" />
</head>
<body>
<!-- Header Start --><div id="header">
<h1>xTraCD: Quick PHP / XHTML / CSS Menu</h1>
<!-- Navbar Start --><ul id="navbar">
<?php
/** We will put code here next */
?>
<!-- Navbar Start --></ul>
<!-- Header Start --></div>
</body>
</html>
save it as body.php
5. The PHP code needed (goes in body.php in the <?php ?> tags
[PHP for step 5]
<?php
$menu_items = array("home", "about", "art", "gallery", "contact"); // Menu items array
// Now we make the menu constructor
// with a foreach loop
foreach ($menu_items as $menu_listing) // for each menu_item, call it menu_listing
{
echo "<li><a href='$menu_listing.php'>$menu_listing</a></li> \n";
// put out a list tag, with a link tag going to the "menu item".php, end it
// and then make a new line.
};
// Loop ends here
?>
6. Now go to http://yourtestingaddress/php_menu
(ie. Mine is http://localhost/teaching_projects/php_menu)
you should see a list like this:
(# signs are bullet marks)
# home
# about
# art
# gallery
# contact
if not, check your code.
7. Styling the list.
Make a new CSS Document. Enter in the following code:
[css for step 6]
@charset "utf-8";
/* PHP List style */
body {
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:10pt;
}
#header {
height:105px;
width:1000px;
margin:0 auto;
border:1px solid #c0c0c0;
-moz-border-radius-bottomleft:8px;
-moz-border-radius-bottomright:8px;
-webkit-border-bottom-left-radius:8px;
-webkit-border-bottom-right-radius:8px;
}
#header h1 {
padding-top:30px;
padding-left:15px;
}
#navbar {
display:block;
position:relative;
width:1000px;
height:40px;
margin:0 auto;
margin-top:18px;
margin-left:-1px;
padding:0;
background-color:#eaeaea;
-moz-border-radius-bottomleft:8px;
-moz-border-radius-bottomright:8px;
-webkit-border-bottom-left-radius:8px;
-webkit-border-bottom-right-radius:8px;
border:1px solid #c0c0c0;
text-align:center;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
}
#navbar li a {
margin-left:80px;
display:block;
height:26px;
width:100px;
float:left;
background-color:#ccc;
margin:5px;
padding-top:8px;
-moz-border-radius-topleft:8px;
-moz-border-radius-topright:8px;
-webkit-border-top-left-radius:8px;
-webkit-border-top-right-radius:8px;
border:1px solid #c0c0c0;
color:#333;
font-size:10pt;
text-decoration:none;
}
#navbar li a:hover {
background-color:#aaa;
color:#111;
}
zhou chao/How to create the Google Suggest feature with ASP.NET 2.0 ( ASP.NET)
How to create the Google Suggest feature with ASP.NET 2.0
Google Suggest seems to be the topic du jour in the blogosphere. It is a cool feature, but what I really enjoy is that it is yet another real world example of a “chubby” client.
I gave a presentation at an NNUG meeting at Microsoft’s Oslo office two months ago on how to create features akin to the auto-complete feature on display over at Google. In this article I will answer the question “everybody” is asking – How do did the guys at Google do that?
Out-of-band calls
It all started when Netscape released Navigator 2.0 in 1996. This browser boosted two revolutionary new features; frames and JavaScript. Although Netscape had different intensions for these features, developers could exploit frames and JavaScript to set up an out-of-band communications channel between the browser and the web server. This made it possible to update forms data without posting back. The concept behind the communications channel was simple. You created a frameset made up of two frames. One of the frames had the height or width attribute set to zero, in practice making the frame “invisible”. The other frame contained the user interface. When the user clicked a button she triggered a JavaScript function which replaced the location property of the hidden frame with the URL for a CGI script that handled the request. The various parameters were passed thru the query string.
top.RPCFrm.location.replace("RPC.cgi?CustomerId="+CustomerId.value);
When the page in the “hidden” frame was refreshed, the BODY element’s onload event was used to pass the result from the CGI script to a callback function.
function callback(result) {
fields=result.split(',');
Firstname.value=fields[0];
MiddleName.value=fields[1];
Surname.value=fields[2];
Address.value=fields[3];
PostalCode.value=fields[4];
City.value=fields[5];
Country.value=fields[6];
}
At the end of the 1990ies Microsoft introduced a technology called remote scripting. This was a combination of JavaScript helper methods, a proxy implemented as a Java applet and some ASP code which enabled you to do both synchronous and asynchronous calls from client side script to functions in server side ASP pages. Now developers could call server side methods via the Java proxy using the RSExecute method.
function LookUpBtn_onclick() {
var callObject = RSExecute("RemoteScriptingFacade.aspx","GetCustomer",CustomerId.value);
fields=callObject.return_value.split(',');
Firstname.value=fields[0];
MiddleName.value=fields[1];
Surname.value=fields[2];
Address.value=fields[3];
PostalCode.value=fields[4];
City.value=fields[5];
Country.value=fields[6];
}
The above example shows a synchronous remote scripting method invocation. Remote scripting relied on Java, which is the key technology of Microsoft’s nemesis. On top of that even if the protocol was XML like, it was a proprietary protocol. Therefore when SOAP was introduced in 1998, Microsoft released the Web Service Behavior for Internet Explorer. The behavior leveraged the standardized SOAP protocol and Internet Explorer’s built-in XmlHttp support. As the name implies, the component enabled developers to invoke Web Service methods from JavaScript code. The example below shows how a Web Service can be invoked asynchronously from the browser.
function LookUpBtn_onclick() {
WebService.facade.callService(callback,"GetCustomer",CustomerId.value);
}
function callback(result) {
if (result.error) alert("WS Error:\nCode: "+result.errorDetail.code+"\nString:\n"+result.errorDetail.string+"\nRaw:\n"+result.errorDetail.raw);
else {
Firstname.value=result.raw.selectSingleNode("//FirstName").text;
MiddleName.value=result.raw.selectSingleNode("//MiddleName").text;
Surname.value=result.raw.selectSingleNode("//Surname").text;
Address.value=result.raw.s
How to create the Google Suggest feature with ASP.NET 2.0
thesmu/Pixels to Ems Conversion Table for CSS ( CSS)
Jon Tangerine / silo / CSS / Pixels to Ems Conversion Table for CSS
A companion reference to the article, The Incredible Em and Elastic Layouts With CSS.
The em values in the table assume that the generic browser default setting of 16px font size has not being changed. It also assumes that the <body> has font size set to 1em or 100%.
px font-size em equivalent * Rounded to 3dp 1px in ems Notes
11 0.689 * 0.091
12 0.750 0.083
13 0.814 * 0.077
14 0.875 0.071
15 0.938 * 0.067
16 1.000 0.063 Browser standard default
17 1.064 * 0.059
18 1.125 0.056
19 1.188 * 0.053
20 1.250 0.050
21 1.313 * 0.048
22 1.375 0.046
23 1.438 * 0.044
24 1.500 0.042
25 1.563 * 0.040
26 1.625 0.039
27 1.688 * 0.037
28 1.750 0.036
29 1.813 * 0.035
30 1.875 0.033
Formula to calculate em equivalent for any pixel value required
1 ÷ parent font size (px) × required pixels = em equivalent
Example: 770px wide, centred elastic layout using CSS and ems
N.B. This assumes the browser default font size is unchanged at 16px. body{} selector set to font-size:1em;. Using the forumla*:
1 ÷ 16 × 770 = 48.125em
CSS:
body{
font-size:1em;
text-align:center;
}
div{
width:48.125em;
margin;0 auto;
}
HTML:
<html>
<body>
<div>
…
</div>
</body>
</html>
*I deliberately hooked the formula for the tutorial around 1px, as a value that designers can easily relate to. However, there is a faster way of calculating an em value that I use. You need to be familliar with the sticky issue of CSS inheritance and know the font size of the parent, but it goes like this:
Required element pixel value ÷ parent font size in pixels = em value
So, our required width of 770px in ems can be calculated like this:
770 ÷ 16 = 48.125em
Jon Tan fecit, 2006–2008. download vCard (via X2V).