среда, 13 февраля 2013 г.

хак для firefox или как применить стиль только для firefox

/* Target all Firefox */
#selector[id=selector] { color: red; }
 
/* Target all Firefox */
@-moz-document url-prefix() { .selector { color: red; } } 
 
/* Target all Gecko (includes Firefox) */
*>.selector { color: red; }

создание многоуровневых раскрывающихся списков на jquery




	
	
	 
      ‹script type="text/javascript">
      $(function(){
        $('li:has(ul.li-slider)')
          .click(function(event){
            if (this == event.target) {
              if ($(this).children().is(':hidden')) {
                $(this)
                  .css('list-style-image','url(minus.gif)')
                  .children().slideDown();
              }
              else {
                $(this)
                  .css('list-style-image','url(plus.gif)')
                  .children().slideUp();
              }
            }
            return false;
          })
          .css({cursor:'pointer',
                'list-style-image':'url(plus.gif)'})
          .children().hide();
        $('li:not(:has(ul.li-slider))').css({
          cursor: 'default',
          'list-style-image':'none'
        });
      });
    ‹/script>



	
  • Авто
    • 1
    • 2
    • 3
    • 4
    • ul ниже не будет раскрываться для того чтобы он мог раскрываться добавьте ему class="li-slider"
      • 1
      • 2
      • 3
      • 4
      • 5
пример
  • Авто
    • 2
      • 1
        • 1
        • 2
        • 3
        • 4
        • 5
      • 2
        • 1
        • 2
        • 3
        • 4
        • 5
      • 3
        • 1
        • 2
        • 3
        • 4
        • 5
      • 4
        • 1
        • 2
        • 3
        • 4
        • 5
      • 5
        • 1
        • 2
        • 3
        • 4
        • 5

будни веб разработки



пятница, 8 февраля 2013 г.

сделать подсветку синтаксиса на вашем сайте

часто возникает необходимость встроить полсветку сетаксиса на ваш блок вставте с ваш блог следующие скрипты

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'></script>
а затем вставте в нужном месте ваш код следующим способом
<pre class="brush:php"> 
//ваш код
<pre>

четверг, 7 февраля 2013 г.

jquery на гугле

очень удобно грузить jquery не с локала а из исходников google как миниум по тому что она может скрипт может быть закеширован как следствие снижение времени на загрузку
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"> < /script> 
проверяем доступность jquery если не доступно то грузим с локала
<script type="text/javascript">window.jQuery || document.write('<script src="js/jquery-1.8.1.min.js"><\/script>') </script> 

понедельник, 4 февраля 2013 г.

RewriteEngine

содержимое .htaccess


Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

воскресенье, 3 февраля 2013 г.

виртуальная секция


<VirtualHost *:80>
ServerAdmin mail@mail.mail
ServerName oop
DocumentRoot /home/user/www/oop
<Directory /home/user/www/oop>
        Options FollowSymLinks
        AllowOverride ALL
</Directory>
</VirtualHost>

паттерн command php

паттерн command php

реализация



";
//////////////////////////////////////////////

abstract class Command {
	abstract function execute( CommandContext $context );
}

class LoginCommand extends Command{
	function execute( CommandContext $context ){
		$user = $context->get('username');
		$pass = $context->get('pass');
                Loger::write("enter user: ".$user);
		return true;
	}
}

class CommandContext {
	private $params=array();
	private $error="";
	
	function __construct() {
		$this->params = $_REQUEST;
	}
	function addParam($key, $val){
		$this->params[$key] = $val;
	}
	function get($key){
		return $this->params[$key];
	}
	function setError($error){
		$this->$error = $error;
	}
	function getError(){
		return $this->error;
	}
}

class CommandNotFoundException extends Exception {}

class CommandFactory {
	private static $dir = "commands";
	static function getCommand($action = 'default'){
		if (preg_match('/\W/', $action )){
			throw new CommandNotFoundExceptioin('Недопустимые символы в комманде'); 
		}
		$class=$action."Command";
		/*//времено
		//возможен иклюдинг предусмотреть
		$class = $action.".ph
		$file = self::$dir.DIRECTORY_SEPARATOR
		if (!file_exists($file)){
			throw new CommandNotFoundExceptioin('не найден файл '.$file); 
		}
		require_once( $file );
		*/
		if(!class_exists($class)){
			throw new CommandNotFoundExceptioin('не найден класс '.$class); 
		}
		$cmd = new $class();
		return $cmd;
	}
}

class Controller {
	private $context;
	function __construct(){
		$this->context = new CommandContext();
	}
	function getContext(){
		return $this->context;
	}
	function process(){
                //var_dump( $this->context->get('action') );
		$cmd = CommandFactory::getCommand( $this->context->get('action') );
		if ( !$cmd->execute($this->context) ){
			//обработка ошибок
		}else{
			//все прошло успешно
			//Теперь отобразим результаты
		}
	}	
}


$controler = new Controller();
//эмулируем действия пользователя
$context = $controler->getContext();
$context->addParam('action', 'Login');
$context->addParam('username', 'jo');
$context->addParam('pass', '1');
$controler->process();


?>
PHP: The Right Way блог програмышки
Яндекс.Метрика