分类目录归档:玩技术

一个十分不错的返回页面顶部的代码ScrollUp

如何使用

引入 jquery.scrollUp.min.js

下载:scrollup-master

快捷设定

$(function () {
    $.scrollUp();
});

默认配置示例

$(function () {
    $.scrollUp({
        scrollName: 'scrollUp', // Element ID
        scrollDistance: 300, // Distance from top/bottom before showing element (px)
        scrollFrom: 'top', // 'top' or 'bottom'
        scrollSpeed: 300, // Speed back to top (ms)
        easingType: 'linear', // Scroll to top easing (see http://easings.net/)
        animation: 'fade', // Fade, slide, none
        animationInSpeed: 200, // Animation in speed (ms)
        animationOutSpeed: 200, // Animation out speed (ms)
        scrollText: 'Scroll to top', // Text for element, can contain HTML
        scrollTitle: false, // Set a custom <a> title if required. Defaults to scrollText
        scrollImg: false, // Set true to use image
        activeOverlay: false, // Set CSS color to display scrollUp active point, e.g '#00FFFF'
        zIndex: 2147483647 // Z-Index for the overlay
    });
});

Bootstrap基本模版

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>TITLE</title>
<meta name="description" content="description" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 最新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="/static/bootstrap/3.0.3/css/bootstrap.min.css">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>




<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script  type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> 
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</body>
</html>

Discuz_X3.1扩展模块相关备忘

入口页面


<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: sample.php 24842 2011-10-12 09:51:37Z zhengqingpeng $
 */

define('APPTYPEID', 2140);
define('CURSCRIPT', 'sample');


require './source/class/class_core.php';

$discuz = C::app();

$modarray = array('mod1','mod2','mod3','mod4');

$mod = !in_array($discuz->var['mod'], $modarray) ? 'mod1' : $discuz->var['mod'];

$discuz->init();

define('CURMODULE', $mod);
runhooks();


require DISCUZ_ROOT.'./source/module/'.CURSCRIPT.'/'.$mod.'.php';

?>


mod页面


<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: mod.php 2011/8/10 15:31 fuqingrong $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

$actionarray = array('ac1','ac2');
$action = getgpc('ac');
$action = in_array($action,$actionarray) ? $action : 'ac1';

if($action == 'ac1'){
	
	
//some code....	
	
}elseif($action == 'ac2'){
	
	
//some code....
	
}


	include template('diy:'.CURSCRIPT.'/'.$mod.'_'.$action);

?>

终于找到了discuz 伪静态功能失效的原因所在!

近日为某事业单位做一门户网站,选用了discuz x3.1作为门户程序,自制风格模板,而当要进行伪静态时,发现页面上的动态链接仍然保持原样。后来一一排除了各种可能性,依然无果。就在刚刚,查看discuz 默认模板文件时,发现上方有一段

<!--{eval output();}-->

,立刻眼前一亮,原来很久以前也遇到过类似问题,而罪魁祸首就是自制的模板文档末尾未加上这段代码!

对汉字进行Unicode编码

/**
 * 对汉字进行Unicode编码 (#21704;&#21704;)
 * @param $str 汉字字符串
 * @param $code 汉字字符串的编码,默认utf-8
 */
function uni_encode ($str, $code = 'utf-8'){
    if($code != 'utf-8'){
        $str = iconv($code, 'utf-8', $str);
    }
    $str = json_encode($str);
    $str = preg_replace_callback('/\\\\u(\w{4})/', create_function('$hex', 'return \'&#\'.hexdec($hex[1]).\';\';'), substr($str, 1, strlen($str)-2));
    return $str;
}

/**
 * 对Unicode编码进行解码
 * @param $str Unicode编码的字符串
 * @param $code 返回汉字字符串的编码,默认utf-8
 */
function uni_decode ($str, $code = 'utf-8'){
    $str = json_decode(preg_replace_callback('/&#(\d{5});/', create_function('$dec', 'return \'\\u\'.dechex($dec[1]);'), '"'.$str.'"'));
    if($code != 'utf-8'){
        $str = iconv('utf-8', $code, $str);
    }
    return $str;
}