集成Qt Webkit 到cocos2d-x
前言
近期倒腾下客户端,想搞个cocos2d的工具。 之前的那个集成到Win32工具下的调试辅助工具是直接用的windows api。拓展起来巨麻烦。而且Windows默认的字符集是宽字符集,和cocos2d与lua交互起来得到utf-8之间转来转去,十分麻烦。所以干脆花点时间一口气搞完这货。
近期倒腾下客户端,想搞个cocos2d的工具。 之前的那个集成到Win32工具下的调试辅助工具是直接用的windows api。拓展起来巨麻烦。而且Windows默认的字符集是宽字符集,和cocos2d与lua交互起来得到utf-8之间转来转去,十分麻烦。所以干脆花点时间一口气搞完这货。
最近看了点typescript的东西,加上以前看过的一点点Node.js,所以就想把他们系统地整理一下。
这玩意搞过Web开发的应该都知道吧,Javascript的语法我就不废话了,挺简单的。这里总结几个Javascript的核心机制部分吧。
现在的web的js开发很方便啊,但是碰到iframe里的东西还是不方便看到变量的内容,所以就写了这么个看json内容的玩意,还可以当控制台输出用。
很简单,有需要以后开发新功能
/**
* Show json in a new page.(For debug)
*
* Licensed under the MIT or GPL Version 3 licenses.
* @version 1.3
* @author OWenT
* @link http://www.owent.net
* @history
* 2012.12.27
* 1. 改进JSON内对象循环引用时的导致的栈溢出问题
* 2. 引入层级路径
* 3. 引入锚点
*/
/**
* Object转为字符串
* @param {Object} json Object对象
* @param {Number} tab 缩进数量
* @param {Object} rules 应用规则
* @param {String} path 当前路径
* @return 生成的HTML
*/
function json2String(json, tab, rules, path) {
var tabStr = "", singleTab = " ", isClear = false;
var txt = "";
if (!rules) {
rules = {
id: "__json2string_process" + (new Date).getTime().toString() + (json2String.baseIndex ++),
objs: []
};
isClear = true;
}
tab = tab || 1;
if (!path) {
path = "{ROOT}";
txt += " ";
}
for (var i = 0; i < tab; i ++) {
tabStr += singleTab;
}
if (!json && json !== 0) {
txt += 'null';
} else if (typeof(json) == "object") {
var prefix = '{', suffix = '}';
try {
if (toString.call(json).match(/array/i)) {
prefix = '[';
suffix = ']';
}
} catch(e) {
// hoho ...
}
if (json[rules.id]) {
txt += prefix + "此处引用 " +
json[rules.id] + "" + suffix;
return txt;
}
json[rules.id] = path;
rules.objs.push(json);
txt += prefix + "
\r\n";
var first = true;
for (var key in json) {
if (key == rules.id)
continue;
if (first)
first = false;
else
txt += ",
\r\n";
txt += tabStr + " " + "" +
key + " : " + json2String(json[key], tab + 1, rules, path + "." + key);
}
txt += "
\r\n" + tabStr.substr(0, tabStr.length - singleTab.length) + suffix;
} else if (typeof(json) == "string") {
txt += '"' + json + '"';
} else if (typeof(json) == "number") {
txt += '' + json + '';
} else if (typeof(json) == "function") {
txt += '' + json + '';
} else {
txt += json.toString();
}
if (isClear) {
for (var i = 0; i < rules.objs.length; ++ i) {
delete rules.objs[i][rules.id];
}
rules.objs = [];
}
return txt;
}
function showJson(json, title, windowName, dlg_opt) {
json2String.baseIndex = json2String.baseIndex || 0;
title = title || "Json viewer";
windowName = windowName || "result" + (new Date()).toGMTString();
if (window.jQuery && jQuery.fn && jQuery.fn.dialog) {
$("").append(json2String(json)).css({
"text-align": "left"
}).dialog($.extend({
"modal": false,
"title": title,
"width": 640,
"height": 480,
"buttons": {
"关闭": function() {
$( this ).dialog( "close" );
}
}
}, dlg_opt));
} else {
var wnd = window.open("about:blank", "_blank", "height=600, width=800, toolbar=no, menubar=no, resizable=yes, location=no, status=no", true);
if (!wnd)
alert("窗口被拦截!");
wnd.document.write("" + title + " " + json2String(json) + "");
}
return wnd;
}Licensed under the MIT or GPL Version 3 licenses.
我们学校的资源列表(ECUST)
用Ubuntu的人,只要把有线和无线网络设置为IPV6自动,然后取消下面的需要IPV6
来建立连接就可以用校园网反问IPV6站点了。反正我就这么搞定了
all in http://ipv6.ecust.edu.cn
校内IPv6网络资源
学校做项目顺便写的,还是有点用的。
/***
* JQuery扩展插件--提示信息
*
* 本函数用于创建提示信息
*
* Example
*
* var t = $.noticeMessage(msg, a, b);
*
*
*
* function noticeMessage([msg, a,b])
* @Param {
* msg: 信息内容(默认: Notice Message!)
* a: 配置选项({expire: 过期时间(默认5秒), time: 过渡时间, from: {起始CSS样式}, to:{最终CSS样式}})
* b: 回调函数
* }
* @Return {jQuery(msgDiv): 产生的信息DOM组件的jQuery容器}
*
*
* Example:
*
* var t = $.noticeMessage("Hello World!");
*
*
*
* @Author OWenT
* @Version 1.0
* @Link http://www.owent.net
*/
jQuery.extend({
noticeMessage: function (msg, a, b) {
msg = msg || "Notice Message!";
var option = { "expire": 5000, "time": 500,
"from": { "background-color": "LightGreen", "opacity": "0", "position": "fixed", "bottom": "0px", "z-index": "1000",
"font-size": "24px", "color": "DarkGreen", "padding": "3px", "font-weight": "bold"
},
"to": { "opacity": "1", "bottom": "+5px" }
};
var callback = function () { };
if (a && jQuery.isFunction(a))
callback = a;
else {
a = a || {};
jQuery.extend(option, a);
callback = b || function () { };
}
var msgDiv = document.createElement("div");
jQuery(msgDiv).css(option.from).html(msg);
jQuery(document.body).append(msgDiv);
jQuery(msgDiv).stop().animate(option.to, option.time, callback);
if (option.expire > 0) {
setTimeout(function () {
if (msgDiv) {
jQuery(msgDiv).stop().animate({ "opacity": "0", "bottom": "-5px" }, option.time,
function () { callback(); jQuery(this).remove(); });
}
}, option.expire);
}
return jQuery(msgDiv);
}
});写在最后补充一下,这个动机基本没什么用了
这是学校USRP项目需要而写的一个类,但是既然写出来了,以后也可能用到,就共享出来吧。
这个类用于解析网页URL的QueryString参数,或者也可以当做操作一些其他设置的类库。
本类库支持任意类型的值的记录,支持JSON语法,支持类似“a=b&c=d”作为设置参数,支持对数组和JSON的转换。