This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //reference: http://stackoverflow.com/questions/5438760/generate-random-5-characters-string | |
function get_token( $length ) { | |
$seed = str_split( | |
'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
); // and any other characters | |
shuffle($seed); // probably optional since array_is randomized; this may be redundant | |
$rand = ''; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // 參考資料來源 http://stackoverflow.com/questions/1193500/php-truncate-html-ignoring-tags | |
function memo_desc_excerpt($str) { | |
$len = 100; | |
//find all tags | |
$tagPattern = '/(<\/?)([\w]*)(\s*[^>]*)>?|&[\w#]+;/i'; //match html tags and entities | |
preg_match_all($tagPattern, $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER ); | |
//WSDDebug::dump($matches); exit; | |
$i = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//程式碼 | |
var url = "http://yourdomain.com/yourpage.html"; | |
$("#elementName").load(url+" #elementName>*",""); | |
//應用 | |
$('#button1').click(function() { | |
var url = "http:www.your-url.com?ID=" + Math.random(); //create random number | |
setTimeout(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//reference from http://stackoverflow.com/questions/10636779/jquery-date-sorting | |
//But this version not working. don't know why. | |
function parseDate(input) { | |
var parts = input.match(/(\d+)/g); | |
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]]) | |
return new Date(parts[0], parts[1]-1, parts[2], parts[3], parts[4], parts[5]); // months are 0-based | |
} | |
var elems = $.makeArray($(".dateDiv")); | |
elems.sort(function(a, b) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
$('.alphabet').click(function(){ | |
$(this).addClass('active').siblings().removeClass('active'); | |
abc = $(this).data('abc'); | |
$('.xxx').each(function(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.listSorter = function(options) { | |
var that = this; | |
var settings = { | |
order: 'asc' | |
}; | |
options = $.extend(settings, options); | |
var items = $('li', that).get(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery("#myiframe").contents().find("#myContent"); | |
//重點在於加上 contents(),便能搜尋然後抓出 iframe 裡面的內容 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Source: http://www.deluxeblogtips.com/2012/04/search-all-custom-fields.html | |
*/ | |
global $wpdb; | |
// If you use a custom search form | |
// $keyword = sanitize_text_field( $_POST['keyword'] ); | |
// If you use default WordPress search form |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Tournament Bracket Generator</title> | |
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script src="http://underscorejs.org/underscore-min.js"></script> | |
<script> | |
$(document).on('ready', function() { | |
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function example_ajax_request() { | |
// The $_REQUEST contains all the data sent via ajax | |
if ( isset($_REQUEST) ) { | |
$fruit = $_REQUEST['fruit']; | |
// Let's take the data that was sent and do something with it | |
if ( $fruit == 'Banana' ) { |