Vihan Company
Kiến thức là vô biên, vì vậy hãy chia sẻ nó. Trên đây là một số công cụ và source mình sưu tầm được. Mong là nó sẽ hữu ích đối với bạn !
Code Google
Thứ Tư, 12 tháng 8, 2015
Chủ Nhật, 29 tháng 3, 2015
Debug php console chrome
<?php
require APPPATH . '/third_party/PhpConsole/__autoload.php';
function d($title="",$content=""){
switch (ENVIRONMENT){
case 'development':
$handler = PhpConsole\Handler::getInstance();
$handler->debug($title,$content);
break;
}
}
require APPPATH . '/third_party/PhpConsole/__autoload.php';
function d($title="",$content=""){
switch (ENVIRONMENT){
case 'development':
$handler = PhpConsole\Handler::getInstance();
$handler->debug($title,$content);
break;
}
}
Thứ Sáu, 23 tháng 1, 2015
Thứ Tư, 14 tháng 1, 2015
Thứ Tư, 24 tháng 12, 2014
Keymap sublime text
[
{ "keys": ["f1"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } },
{ "keys": ["f2"], "command": "insert_snippet", "args": {"contents": "<?php ${0:$SELECTION} ?>"}},
{ "keys": ["f3"], "command": "insert_snippet", "args": {"contents": " ?> ${0:$SELECTION} <?php "}},
{ "keys": ["f4"], "command": "insert_snippet", "args": {"contents": " // Đánh dấu phần này "}},
{ "keys": ["ctrl+m"], "command": "sftp_browse" },
{ "keys": ["ctrl+u"], "command": "sftp_upload_file" },
{ "keys": ["shift+f4"], "command": "toggle_side_bar" }
]
{ "keys": ["f1"], "command": "insert_snippet", "args": { "name": "Packages/XML/long-tag.sublime-snippet" } },
{ "keys": ["f2"], "command": "insert_snippet", "args": {"contents": "<?php ${0:$SELECTION} ?>"}},
{ "keys": ["f3"], "command": "insert_snippet", "args": {"contents": " ?> ${0:$SELECTION} <?php "}},
{ "keys": ["f4"], "command": "insert_snippet", "args": {"contents": " // Đánh dấu phần này "}},
{ "keys": ["ctrl+m"], "command": "sftp_browse" },
{ "keys": ["ctrl+u"], "command": "sftp_upload_file" },
{ "keys": ["shift+f4"], "command": "toggle_side_bar" }
]
Thứ Hai, 15 tháng 12, 2014
Dialog jquery
function show_dialog(mes){
if(!$(".dialog_jquery").width())
$("body").append('<div class="dialog_jquery"></div>');
$(".dialog_jquery").text(mes);
$(".dialog_jquery").fadeIn(200).delay(1000).fadeOut(200);
var width_b=$(window).width()/2 - ($(".dialog_jquery").width()/2);
$(".dialog_jquery").css({top:"10px",left:width_b+"px"});
}.dialog_jquery {
background: none repeat scroll 0 0 white;
border: 5px solid rgba(80, 78, 78, 0.58);
border-radius: 5px;
color: black;
left: 0;
padding: 18px;
position: fixed;
top: 0;
z-index: 444;
}
if(!$(".dialog_jquery").width())
$("body").append('<div class="dialog_jquery"></div>');
$(".dialog_jquery").text(mes);
$(".dialog_jquery").fadeIn(200).delay(1000).fadeOut(200);
var width_b=$(window).width()/2 - ($(".dialog_jquery").width()/2);
$(".dialog_jquery").css({top:"10px",left:width_b+"px"});
}.dialog_jquery {
background: none repeat scroll 0 0 white;
border: 5px solid rgba(80, 78, 78, 0.58);
border-radius: 5px;
color: black;
left: 0;
padding: 18px;
position: fixed;
top: 0;
z-index: 444;
}
Thứ Hai, 29 tháng 9, 2014
Thứ Sáu, 8 tháng 8, 2014
convert_time($time) mysql_format to timestamp
Convert_time($time) mysql_format to timestamp
function convert_time($time){
if(!$time) return false;
$array1=explode(" ",$time);
$array2["date"]=explode("-",$array1[0]);
$array2["time"]=explode(":",$array1[1]);
$int_time=mktime($array2["time"][0],$array2["time"][1],$array2["time"][2],$array2["date"][1],$array2["date"][2],$array2["date"][0]);
if($int_time)
return $int_time;
else
return false;
}
Thứ Ba, 29 tháng 7, 2014
Function check table có tồn tại không !
function table_exist($nametable){
$nametable=trim($nametable);
if($this->sql_numrows($this->sql_query("SHOW TABLES LIKE '".$nametable."'"))==1)
return true;
else
return false;
}
$nametable=trim($nametable);
if($this->sql_numrows($this->sql_query("SHOW TABLES LIKE '".$nametable."'"))==1)
return true;
else
return false;
}
Thứ Sáu, 25 tháng 7, 2014
Resize scale png transparent !!
$source = "".$inpath."/".$inimg."";
$source = imagecreatefrompng($source);
$newImg=resizePng($source , 50, 50);
imagepng($newImg, "".$inpath."/".$inimg."");
ImageDestroy($newImg);
function resizePng($im, $dst_width, $dst_height) {
$width = imagesx($im);
$height = imagesy($im);
$dst_height = $height/($width/$dst_width);
$newImg = imagecreatetruecolor($dst_width, $dst_height);
imagealphablending($newImg, false);
imagesavealpha($newImg, true);
$transparent = imagecolorallocatealpha($newImg, 255, 255, 255, 127);
imagefilledrectangle($newImg, 0, 0, $width, $height, $transparent);
imagecopyresampled($newImg, $im, 0, 0, 0, 0, $dst_width, $dst_height, $width, $height);
return $newImg;
}
Thứ Năm, 24 tháng 7, 2014
Thứ Tư, 23 tháng 7, 2014
Show tất cả biến global !!! Thật là nguy hiểm !
echo "<pre>";
print_r($GLOBALS);
echo "</pre>";
die;
Thứ Ba, 22 tháng 7, 2014
Thứ Sáu, 18 tháng 7, 2014
Mở chế độ chạy .htaccess trên Appserv
Bước 1: Vào thư mục cài đặt (thông thường C:\AppServ\Apache2.2\conf\)
Mở file httpd.conf tìm đến
#LoadModule rewrite_module modules/mod_rewrite.so
Bỏ dấu # ở phía trước, trở thành
LoadModule rewrite_module modules/mod_rewrite.so
Bước 2: Không cần thiết lắm, mục đích là để server nhận đúng tên file htaccess, vì trong windows khó đặt tên file có dấu . ở trước nên ta thêm vào x cho thuận tiện thôi.
Tìm AccessFileName.htaccess
Thay bằng: AccessFileName x.htaccess
Save all.
Bước 3. Khởi động lại Apache
Thường thì vào: C:\Appserv\Apache2.2\bin chạy file ApacheMonitor.exe click Restart Hoặc click Start>>All Programs>> … tìm trong đó. Enjoy
Sưu tầm: Al0nex’s blog
Mở file httpd.conf tìm đến
#LoadModule rewrite_module modules/mod_rewrite.so
Bỏ dấu # ở phía trước, trở thành
LoadModule rewrite_module modules/mod_rewrite.so
Bước 2: Không cần thiết lắm, mục đích là để server nhận đúng tên file htaccess, vì trong windows khó đặt tên file có dấu . ở trước nên ta thêm vào x cho thuận tiện thôi.
Tìm AccessFileName.htaccess
Thay bằng: AccessFileName x.htaccess
Save all.
Bước 3. Khởi động lại Apache
Thường thì vào: C:\Appserv\Apache2.2\bin chạy file ApacheMonitor.exe click Restart Hoặc click Start>>All Programs>> … tìm trong đó. Enjoy
Sưu tầm: Al0nex’s blog
Thứ Ba, 15 tháng 7, 2014
Thứ Bảy, 12 tháng 7, 2014
Thứ Bảy, 21 tháng 6, 2014
Thứ Hai, 12 tháng 5, 2014
Get full url
function url_origin($s, $use_forwarded_host=false)
{
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
$sp = strtolower($s['SERVER_PROTOCOL']);
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
$port = $s['SERVER_PORT'];
$port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port;
$host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
return $protocol . '://' . $host;
}
function full_url($s, $use_forwarded_host=false)
{
return url_origin($s, $use_forwarded_host) . $s['REQUEST_URI'];
}
Thứ Bảy, 10 tháng 5, 2014
Function get content Liric or dic
case "loibaihat_zing":
?>
<form method="get" role="form">
<legend>Form title</legend>
<div class="form-group">
<label for="">name</label>
<input name="word" type="text" class="form-control" id="" placeholder="">
</div>
<input type="hidden" name="name" value="Your_Account">
<input type="hidden" name="case" value="loibaihat_zing">
<input type="hidden" name="op" value="MyDomain">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<?php
$lik= str_replace(" ", "+", ($_GET["word"])) ;
$url="http://mp3.zing.vn/tim-kiem/bai-hat.html?q=".$lik;
$html=get_page($url);
foreach ($html->find(".content-item h3 a._trackLink") as $value) {
if(strpos($value->href,"bai-hat")===false) {
continue;
}
echo "<h1>".$value->innertext."</h1>";
$url="http://mp3.zing.vn".$value->href."";
$html2=get_page($url);
foreach ($html2->find("._lyricItem") as $value2) {
$array_of_id_or_class=array("oLyric");
$name = implode('|', $array_of_id_or_class);
$regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name .
')[\'"][^>]*>.*</\\1>#isU';
echo (preg_replace($regex, '', $value2->innertext));
}
}
die;
break;
case "loibaihat":
?>
<form method="get" role="form">
<legend>Form title</legend>
<div class="form-group">
<label for="">name</label>
<input name="word" type="text" class="form-control" id="" placeholder="">
</div>
<input type="hidden" name="name" value="Your_Account">
<input type="hidden" name="case" value="loibaihat">
<input type="hidden" name="op" value="MyDomain">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<?php
$lik= str_replace(" ", "+", unicode($_GET["word"])) ;
$url="http://loibaihat.mobi/tim-kiem/loi-bai-hat.html?search=".$lik;
$html=get_page($url);
foreach ($html->find(".item a") as $value) {
echo "<h1>".$value->innertext."</h1>";
echo "<h5>http://loibaihat.mobi".$value->href."</h5>";
// $url="http://loibaihat.mobi".$value->href."";
// $html2=get_page($url);
// foreach ($html2->find(".lyric") as $value2) {
// echo $value2->innertext;
// }
// echo "<pre>";
// print_r($value);
// echo "</pre>";
}
die;
break;
case "dict":
?>
<form method="get" role="form">
<legend>Form title</legend>
<div class="form-group">
<label for="">name</label>
<input name="word" type="text" class="form-control" id="" placeholder="">
</div>
<input type="hidden" name="name" value="Your_Account">
<input type="hidden" name="case" value="dict">
<input type="hidden" name="op" value="MyDomain">
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<?php
$url="http://vdict.com/".$_GET["word"].",1,0,0.html";
$html=get_page($url);
foreach ($html->find(".word_title") as $value) {
echo "<h1>".$value->innertext."</h1>";
// echo "<pre>";
// print_r($value);
// echo "</pre>";
}
foreach ($html->find(".pronounce") as $value) {
echo "<p>".$value->innertext."</p>";
// echo "<pre>";
// print_r($value);
// echo "</pre>";
}
foreach ($html->find(".phanloai") as $value) {
echo "<h3>".$value->innertext."</h3>";
// echo "<pre>";
// print_r($value);
// echo "</pre>";
}
foreach ($html->find(".list1") as $value) {
echo "<p>".$value->innertext."</p>";
// echo "<pre>";
// print_r($value);
// echo "</pre>";
}
die;
break;
Thứ Sáu, 25 tháng 4, 2014
REgister wordpress
if(function_exists('register_nav_menus')){
register_nav_menus(
array(
'main_nav' => 'Main Navigation Menu'
)
);
register_nav_menus(
array(
'main_nav2' => 'Main Navigation Menu2'
)
);
}
/**
* Creates a sidebar
* @param string|array Builds Sidebar based off of 'name' and 'id' values.
*/
$args = array(
'name' => __( '1' ),
'id' => 'unique-sidebar-id',
'description' => '',
'class' => '',
'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
register_sidebar( $args );
$args = array(
'name' => __( '2' ),
'id' => 's',
'description' => '',
'class' => '',
'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
register_sidebar( $args );
get_sidebar("1");
get_sidebar("2");
register_nav_menus(
array(
'main_nav' => 'Main Navigation Menu'
)
);
register_nav_menus(
array(
'main_nav2' => 'Main Navigation Menu2'
)
);
}
/**
* Creates a sidebar
* @param string|array Builds Sidebar based off of 'name' and 'id' values.
*/
$args = array(
'name' => __( '1' ),
'id' => 'unique-sidebar-id',
'description' => '',
'class' => '',
'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
register_sidebar( $args );
$args = array(
'name' => __( '2' ),
'id' => 's',
'description' => '',
'class' => '',
'before_widget' => '<li id="%1" class="widget %2">ffffffffffs',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>'
);
register_sidebar( $args );
Call
dynamic_sidebar( 'sidebar-1' );get_sidebar("1");
get_sidebar("2");
Thứ Năm, 24 tháng 4, 2014
Thứ Ba, 22 tháng 4, 2014
Thứ Hai, 14 tháng 4, 2014
Hai cái này mò cả 1 buổi ^^ Bây chừ đã xong và rất là vui !
///////////////////
$params = array('scope' => 'read_stream, friends_likes,email,user_birthday,read_stream,read_friendlists,publish_actions');
///////////////////
$response = $facebook->api(
"/me/feed",
"POST",
array (
'message' => 'Không có gì quý hơn độc lập tự do - Tôi viết cái này trong app của facebook ^_^ '.rand(0,10000)
)
);
///////////////////
Thứ Sáu, 7 tháng 3, 2014
Confirm action link by jquery
$('.delete_row').click(function(){
return confirm("Are you sure you want to delete?");
});
Thứ Tư, 5 tháng 3, 2014
Thứ Ba, 25 tháng 2, 2014
Xóa tag có tên class tùy biến
$array_of_id_or_class=array("oLyric");
$name = implode('|', $array_of_id_or_class);
$regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name .
')[\'"][^>]*>.*</\\1>#isU';
echo (preg_replace($regex, '', $value2->innertext));
$name = implode('|', $array_of_id_or_class);
$regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name .
')[\'"][^>]*>.*</\\1>#isU';
echo (preg_replace($regex, '', $value2->innertext));
Thứ Năm, 23 tháng 1, 2014
Shortkey sublimetext
[
{ "keys": ["ctrl+shift+u"], "command": "sftp_upload_file" },
{ "keys": ["ctrl+shift+m"], "command": "sftp_browse" },
{ "keys": ["f4"], "command": "toggle_side_bar" },
]
{ "keys": ["ctrl+shift+u"], "command": "sftp_upload_file" },
{ "keys": ["ctrl+shift+m"], "command": "sftp_browse" },
{ "keys": ["f4"], "command": "toggle_side_bar" },
]
Thứ Bảy, 18 tháng 1, 2014
something in sql
Boolean full-text searches have these characteristics:
- They do not use the 50% threshold.
- They do not automatically sort rows in order of decreasing relevance. You can see this from the preceding query result: The row with the highest relevance is the one that contains “MySQL” twice, but it is listed last, not first.
-
They can work even without a
FULLTEXT
index, although a search executed in this fashion would be quite slow. - The minimum and maximum word length full-text parameters apply.
- The stopword list applies.
-
+
A leading plus sign indicates that this word must be present in each row that is returned. -
-
A leading minus sign indicates that this word must not be present in any of the rows that are returned.
Note: The-
operator acts only to exclude rows that are otherwise matched by other search terms. Thus, a boolean-mode search that contains only terms preceded by-
returns an empty result. It does not return “all rows except those containing any of the excluded terms.” -
(no operator)
By default (when neither+
nor-
is specified) the word is optional, but the rows that contain it are rated higher. This mimics the behavior ofMATCH() ... AGAINST()
without theIN BOOLEAN MODE
modifier. -
> <
These two operators are used to change a word's contribution to the relevance value that is assigned to a row. The>
operator increases the contribution and the<
operator decreases it. See the example following this list. -
( )
Parentheses group words into subexpressions. Parenthesized groups can be nested. -
~
A leading tilde acts as a negation operator, causing the word's contribution to the row's relevance to be negative. This is useful for marking “noise” words. A row containing such a word is rated lower than others, but is not excluded altogether, as it would be with the-
operator. -
*
The asterisk serves as the truncation (or wildcard) operator. Unlike the other operators, it should be appended to the word to be affected. Words match if they begin with the word preceding the*
operator.
If a word is specified with the truncation operator, it is not stripped from a boolean query, even if it is too short (as determined from theft_min_word_len
setting) or a stopword. This occurs because the word is not seen as too short or a stopword, but as a prefix that must be present in the document in the form of a word that begins with the prefix. Suppose thatft_min_word_len=4
. Then a search for'+
will likely return fewer rows than a search forword
+the*''+
:word
+the'
-
The former query remains as is and requires both
word
andthe*
(a word starting withthe
) to be present in the document. -
The latter query is transformed to
+
(requiring onlyword
word
to be present).the
is both too short and a stopword, and either condition is enough to cause it to be ignored.
-
The former query remains as is and requires both
-
"
A phrase that is enclosed within double quote (“"
”) characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words and performs a search in theFULLTEXT
index for the words. Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example,"test phrase"
matches"test, phrase"
.
If the phrase contains no words that are in the index, the result is empty. For example, if all words are either stopwords or shorter than the minimum length of indexed words, the result is empty.
-
'apple banana'
Find rows that contain at least one of the two words. -
'+apple +juice'
Find rows that contain both words. -
'+apple macintosh'
Find rows that contain the word “apple”, but rank rows higher if they also contain “macintosh”. -
'+apple -macintosh'
Find rows that contain the word “apple” but not “macintosh”. -
'+apple ~macintosh'
Find rows that contain the word “apple”, but if the row also contains the word “macintosh”, rate it lower than if row does not. This is “softer” than a search for'+apple -macintosh'
, for which the presence of “macintosh” causes the row not to be returned at all. -
'+apple +(>turnover <strudel)'
Find rows that contain the words “apple” and “turnover”, or “apple” and “strudel” (in any order), but rank “apple turnover” higher than “apple strudel”. -
'apple*'
Find rows that contain words such as “apple”, “apples”, “applesauce”, or “applet”. -
'"some words"'
Find rows that contain the exact phrase “some words” (for example, rows that contain “some words of wisdom” but not “some noise words”). Note that the “"
” characters that enclose the phrase are operator characters that delimit the phrase. They are not the quotation marks that enclose the search string itself.
SELECT name, description, ...
FROM ...
WHERE id IN([ids, any order])
ORDER BY FIELD(id, [ids in order])
FIELD() will return the index of the first parameter that is equal to
the first parameter (other than the first parameter itself).FIELD('a', 'a', 'b', 'c')
will return 1
FIELD('a', 'c', 'b', 'a')
Thứ Sáu, 17 tháng 1, 2014
class get pagerank
class PR {
public function get_google_pagerank($url) {
$query="http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=".$this->CheckHash($this->HashURL($url)). "&features=Rank&q=info:".$url."&num=100&filter=0";
$data=file_get_contents($query);
$pos = strpos($data, "Rank_");
if($pos === false){} else{
$pagerank = substr($data, $pos + 9);
return $pagerank;
}
}
public function StrToNum($Str, $Check, $Magic)
{
$Int32Unit = 4294967296; // 2^32
$length = strlen($Str);
for ($i = 0; $i < $length; $i++) {
$Check *= $Magic;
if ($Check >= $Int32Unit) {
$Check = ($Check - $Int32Unit * (int) ($Check / $Int32Unit));
$Check = ($Check < -2147483648) ? ($Check + $Int32Unit) : $Check;
}
$Check += ord($Str{$i});
}
return $Check;
}
public function HashURL($String)
{
$Check1 = $this->StrToNum($String, 0x1505, 0x21);
$Check2 = $this->StrToNum($String, 0, 0x1003F);
$Check1 >>= 2;
$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 & 0x3F);
$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 & 0x3FF);
$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 & 0x3FFF);
$T1 = (((($Check1 & 0x3C0) << 4) | ($Check1 & 0x3C)) <<2 ) | ($Check2 & 0xF0F );
$T2 = (((($Check1 & 0xFFFFC000) << 4) | ($Check1 & 0x3C00)) << 0xA) | ($Check2 & 0xF0F0000 );
return ($T1 | $T2);
}
public function CheckHash($Hashnum)
{
$CheckByte = 0;
$Flag = 0;
$HashStr = sprintf('%u', $Hashnum) ;
$length = strlen($HashStr);
for ($i = $length - 1; $i >= 0; $i --) {
$Re = $HashStr{$i};
if (1 === ($Flag % 2)) {
$Re += $Re;
$Re = (int)($Re / 10) + ($Re % 10);
}
$CheckByte += $Re;
$Flag ++;
}
$CheckByte %= 10;
if (0 !== $CheckByte) {
$CheckByte = 10 - $CheckByte;
if (1 === ($Flag % 2) ) {
if (1 === ($CheckByte % 2)) {
$CheckByte += 9;
}
$CheckByte >>= 1;
}
}
return '7'.$CheckByte.$HashStr;
}
}
Lay rank alexa
<?
$url
=
"toolspot.org"
;
$xml
= simplexml_load_file(
'http://data.alexa.com/data?cli=10&dat=snbamz&url='
.
$url
);
$rank
=isset(
$xml
->SD[1]->POPULARITY)?
$xml
->SD[1]->POPULARITY->attributes()->TEXT:0;
$web
=(string)
$xml
->SD[0]->attributes()->HOST;
echo
$web
.
" has Alexa Rank "
.
$rank
;
?>
Thứ Tư, 15 tháng 1, 2014
Thứ Ba, 7 tháng 1, 2014
Chủ Nhật, 5 tháng 1, 2014
tab basic using jquery
<!DOCTYPE html>
<html>
<body>
<style>
.title_tab li {
float: left;
list-style: none outside none;
}
.content_tab li {
display: none;
list-style: none outside none;
}
.title_tab ul {
height: 30px;
margin: 0;
padding: 0;
}
.title_tab li a {
background: none repeat scroll 0 0 #D7D7D7;
border-radius: 5px 5px 0 0;
border-top: 1px solid #CCCCCC;
color: #666161;
display: block;
font-family: arial;
margin-left: 10px;
padding: 5px 33px;
text-decoration: none;
}
.content_tab li {
}
.content_tab li.active {
display: block;
}
.content_tab > ul {
background: none repeat scroll 0 0 #EDEDED;
border-radius: 4px;
margin: 0;
padding: 10px;
}
.title_tab li.active a {
background: none repeat scroll 0 0 #EDEDED;
color: #060606;
font-weight: bold;
}
</style>
<div class="title_tab">
<ul class="">
<li data-class-child="1" class="active"> <a href="#">1</a></li>
<li data-class-child="2"> <a href="#">2</a></li>
<li data-class-child="3"> <a href="#">3</a></li>
</ul>
</div>
<div class="content_tab">
<ul class="">
<li class="active"> <a href="#">a</a></li>
<li> <a href="#">b</a></li>
<li> <a href="#">c</a></li>
</ul>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.title_tab li').click(function(event) {
var pos_li=$(this).attr('data-class-child');
$('.title_tab ul>li').removeClass('active');
$(this).addClass('active');
$('.content_tab ul>li').removeClass('active');
$('.content_tab ul>li:nth-child('+pos_li+')').addClass('active');
return false;
});;
});
</script>
</body>
</html>
<html>
<body>
<style>
.title_tab li {
float: left;
list-style: none outside none;
}
.content_tab li {
display: none;
list-style: none outside none;
}
.title_tab ul {
height: 30px;
margin: 0;
padding: 0;
}
.title_tab li a {
background: none repeat scroll 0 0 #D7D7D7;
border-radius: 5px 5px 0 0;
border-top: 1px solid #CCCCCC;
color: #666161;
display: block;
font-family: arial;
margin-left: 10px;
padding: 5px 33px;
text-decoration: none;
}
.content_tab li {
}
.content_tab li.active {
display: block;
}
.content_tab > ul {
background: none repeat scroll 0 0 #EDEDED;
border-radius: 4px;
margin: 0;
padding: 10px;
}
.title_tab li.active a {
background: none repeat scroll 0 0 #EDEDED;
color: #060606;
font-weight: bold;
}
</style>
<div class="title_tab">
<ul class="">
<li data-class-child="1" class="active"> <a href="#">1</a></li>
<li data-class-child="2"> <a href="#">2</a></li>
<li data-class-child="3"> <a href="#">3</a></li>
</ul>
</div>
<div class="content_tab">
<ul class="">
<li class="active"> <a href="#">a</a></li>
<li> <a href="#">b</a></li>
<li> <a href="#">c</a></li>
</ul>
</div>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.title_tab li').click(function(event) {
var pos_li=$(this).attr('data-class-child');
$('.title_tab ul>li').removeClass('active');
$(this).addClass('active');
$('.content_tab ul>li').removeClass('active');
$('.content_tab ul>li:nth-child('+pos_li+')').addClass('active');
return false;
});;
});
</script>
</body>
</html>
Thứ Tư, 25 tháng 12, 2013
Plugin sublime text : Bracket Highlighter Đánh dấu
Plugin sublime text : Bracket Highlighter Đánh dấu
Thứ Ba, 17 tháng 12, 2013
Thứ Hai, 16 tháng 12, 2013
Thứ Bảy, 14 tháng 12, 2013
jquery ajax + php
Lấy database với ajax
$(document).delegate("#json", "pageinit", function() { $(".manda").click(function(e) { $.ajax({ url : "json1.php", dataType : "json", data : '{"opc":"sim"}', success : function(data){ var html = ""; for($i=0; $i < data.length; $i++){ html += "<strong>Nome:</strong> "+data[$i].nome +" "+ data[$i].sobreNome; html += " <strong>Cidade:</strong> "+data[$i].cidade html += "<br />"; } $("#mostra").html(html); } }); return false; }); });
<?php if ($_POST['opc'] == "sim"){ $var = Array( array( "nome"=>"João", "sobreNome"=>"Silva", "cidade"=>"Maringá" ), array( "nome"=>"Ana", "sobreNome"=>"Rocha", "cidade"=>"Londrina" ), array( "nome"=>"Véra", "sobreNome"=>"Valério", "cidade"=>"Cianorte" )); echo json_encode($var); } ?>
Upload file với ajax
<!DOCTYPE html>
<html>
<head>
<title>File Upload</title>
</head>
<body>
<form id="form" method="post" action="post.php" enctype="multipart/form-data">
<input type="file" name="img"/>
<input type="submit" value="Upload" />
</form>
<script src="jquery.js"></script>
<script src="upload.js"></script>
</body>
</html>
<?php
if($_FILES['img']['error'] > 0) die('Error ' . $_FILES['file']['error']);
if(empty($_FILES['img']['name'])) die('No file sent.');
$tmp = $_FILES['img']['tmp_name'];
if(is_uploaded_file($tmp))
{
if(!move_uploaded_file($tmp, 'img.png')) echo 'error !';
}
else echo 'Upload failed !';
?>
$(function() {
$('#form').submit(function(e) {
e.preventDefault();
data = new FormData($('#form')[0]);
console.log('Submitting');
$.ajax({
type: 'POST',
url: 'post.php',
data: data,
cache: false,
contentType: false,
processData: false
}).done(function(data) {
console.log(data);
}).fail(function(jqXHR,status, errorThrown) {
console.log(errorThrown);
console.log(jqXHR.responseText);
console.log(jqXHR.status);
});
});
});
Thứ Ba, 10 tháng 12, 2013
Button top jquery
=========== HTML ===========
<div class="button_top"></div>
=========== CSS ===========
.button_top {
background: url("../images/top_png.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
bottom: 70px;
height: 70px;
position: fixed;
right: 22px;
width: 70px;
display: none;
cursor: pointer;
}
=========== JS ===========
var offset = 220;
var duration = 500;
$(window).scroll(function() {
console.log($(window).width());
if($(window).width()<1190){
$(".button_top").remove();
}
if ($(this).scrollTop() > offset) {
$('.button_top').fadeIn(duration);
} else {
$('.button_top').fadeOut(duration);
}
});
$(".button_top").click(function(event){
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
});
<div class="button_top"></div>
=========== CSS ===========
.button_top {
background: url("../images/top_png.png") no-repeat scroll 0 0 rgba(0, 0, 0, 0);
bottom: 70px;
height: 70px;
position: fixed;
right: 22px;
width: 70px;
display: none;
cursor: pointer;
}
=========== JS ===========
var offset = 220;
var duration = 500;
$(window).scroll(function() {
console.log($(window).width());
if($(window).width()<1190){
$(".button_top").remove();
}
if ($(this).scrollTop() > offset) {
$('.button_top').fadeIn(duration);
} else {
$('.button_top').fadeOut(duration);
}
});
$(".button_top").click(function(event){
event.preventDefault();
$('html, body').animate({scrollTop: 0}, duration);
return false;
});
Đăng ký:
Bài đăng (Atom)