作者: zhongdaiqi

  • SharePoint 2013 App 介绍3 —应用程序宿主类型和品牌化

    SharePoint 2013 应用程序模型提供了两种类型的宿主环境:

  • 内网环境下安装Sharepoint

    坑太多,小伙伴无力吐槽 1.内网不能在线安装必备组件,需要一个一个去下载 2.AppFabric安装失败,环境变量有问题

    1. 官方说明不够明确,埋了坑 安装AppFabric失败,需要将环境变量-系统变量的PSModulePath中尾部多余的双引号去掉 所以逐一下载必备组件,官方文档里的命令说明写得不明确。 下载必备组件(直接包含在安装包里多方便,还搞得这么麻烦),假设下载到了C:\Software\sp_require 在cmd定位到Sharepoint安装目录下跑命令: prerequisiteinstaller.exe /sqlncli:"C:\Software\sp_require\sqlncli.msi" /PowerShell:"C:\Software\sp_require\Windows6.1-KB2506143-x64.msu" /NETFX:"C:\Software\sp_require\dotNetFx45_Full_x86_x64.exe" /IDFX:"C:\Software\sp_require\Windows6.1-KB974405-x64.msu" /Sync:"C:\Software\sp_require\Synchronization.msi" /AppFabric:"C:\Software\sp_require\WindowsServerAppFabricSetup_x64.exe"  /IDFX11:"C:\Software\sp_require\MicrosoftIdentityExtensions-64.msi" /MSIPCClient:"C:\Software\sp_require\setup_msipc_x64.msi" /WCFDataServices:"C:\Software\sp_require\WcfDataServices.exe" /KB2671763:"C:\Software\sp_require\AppFabric1.1-RTM-KB2671763-x64-CHS.exe" 提示成功,不要高兴太早。此时是接着安装Sharepoint 2013会提示 AppFabric安装错误的。 需要单独到命令行,跑:WindowsServerAppFabricSetup_x64.exe /i  CacheClient,CachingService,CacheAdmin /gac 执行完之后就可以正常安装了。 下载必备组件可以到: http://www.zhongdaiqi.com/sharepoint-2013-installation/ (里面转载了一份清单,方便下载)
  • OSChina年度热门第二的代码赏析

    image

    <
    html
    >
    <
    head
    >
    <
    title
    >DZ新闻中心----DZ是世界上最牛的人!</
    title
    >
    
    <
    script type
    ="text/javascript"
    >
        var str = ["D","Z","新","闻","中","心","----","D","Z","是","世","界","上","最","牛","的","人","!"," "," "," "];
    var len = str.length;
    
    var index = 0;
    function rollTitle(){
        var title = "";
        if(index == len){
            index = 0;
        }else{
            index ++;
        }
        for(var i = 0; i < len; ++i){
            var j = i + index;
            if(j >= len){
                title += str[j - len];
            }else{
                title += str[j];
            }
        }
        document.getElementsByTagName("title")[0].innerText=title;
    
        setTimeout(rollTitle,500);
    }
    
    (function(){    
        setTimeout(rollTitle,500);
    }());
    </
    script
    >
    
    <
    style
    >
        p{
            padding-left:20px;
            font-size:35px;
        }
        A{
            COLOR:BLUE;
            text-decoration:none;
        }
    </
    style
    >
    
    </
    head
    >
    
    <
    body
    >
    <
    p
    >
        <
    a target
    ="_blank" href
    ="http://news.baidu.com/"
    >百度新闻</
    a
    >
    </
    p
    >
    <
    p
    >
        <
    a target
    ="_blank" href
    ="http://www.sina.com.cn/"
    >新浪门户</
    a
    >
        <
    a target
    ="_blank" href
    ="http://news.sina.com.cn/"
    >新浪新闻</
    a
    >
    </
    p
    >
    <
    p
    >
        <
    a target
    ="_blank" href
    ="http://www.qq.com/"
    >腾讯门户</
    a
    >    
        <
    a target
    ="_blank" href
    ="http://news.qq.com/"
    >腾讯新闻</
    a
    >
    </
    p
    >
    <
    p
    >
        <
    a target
    ="_blank" href
    ="http://cn.msn.com/"
    >MSN资讯</
    a
    >
    </
    p
    >
    <
    p
    >
        <
    a target
    ="_blank" href
    ="http://www.ifeng.com/"
    >凤凰网</
    a
    >
        <
    a target
    ="_blank" href
    ="http://news.ifeng.com/"
    >凤凰资讯</
    a
    >    
    </
    p
    >
    <
    p
    >
    <
    a target
    ="_blank" href
    ="http://www.chinanews.com/"
    >中国新闻网</
    a
    >
    </
    p
    >
    <
    p
    >
    <
    a target
    ="_blank" href
    ="http://www.huanqiu.com/"
    >环球网</
    a
    >
    </
    p
    >
    </
    body
    >
    
    </
    html
    >
    .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

    欣赏评论:KAO

  • WeixinApi.js

    /**!
     * 微信内置浏览器的Javascript API,功能包括:
     *
     * 1、分享到微信朋友圈
     * 2、分享给微信好友
     * 3、分享到腾讯微博
     * 4、隐藏/显示右上角的菜单入口
     * 5、隐藏/显示底部浏览器工具栏
     * 6、获取当前的网络状态
     * 7、调起微信客户端的图片播放组件
     *
     * @author zhaoxianlie(http://www.baidufe.com)
     */
    var WeixinApi = (function () {
    
        /**
         * 分享到微信朋友圈
         * @param       {Object}    data       待分享的信息
         * @p-config    {String}    appId      公众平台的appId(服务号可用)
         * @p-config    {String}    imageUrl   图片地址
         * @p-config    {String}    link       链接地址
         * @p-config    {String}    desc       描述
         * @p-config    {String}    title      分享的标题
         *
         * @param       {Object}    callbacks  相关回调方法
         * @p-config    {Boolean}   async                   ready方法是否需要异步执行,默认false
         * @p-config    {Function}  ready(argv)             就绪状态
         * @p-config    {Function}  dataLoaded(data)        数据加载完成后调用,async为true时有用,也可以为空
         * @p-config    {Function}  cancel(resp)    取消
         * @p-config    {Function}  fail(resp)      失败
         * @p-config    {Function}  confirm(resp)   成功
         * @p-config    {Function}  all(resp)       无论成功失败都会执行的回调
         */
        function weixinShareTimeline(data, callbacks) {
            callbacks = callbacks || {};
            var shareTimeline = function (theData) {
                WeixinJSBridge.invoke('shareTimeline', {
                    "appid":theData.appId ? theData.appId : '',
                    "img_url":theData.imgUrl,
                    "link":theData.link,
                    "desc":theData.title,
                    "title":theData.desc, // 注意这里要分享出去的内容是desc
                    "img_width":"120",
                    "img_height":"120"
                }, function (resp) {
                    switch (resp.err_msg) {
                        // share_timeline:cancel 用户取消
                        case 'share_timeline:cancel':
                            callbacks.cancel && callbacks.cancel(resp);
                            break;
                        // share_timeline:fail 发送失败
                        case 'share_timeline:fail':
                            callbacks.fail && callbacks.fail(resp);
                            break;
                        // share_timeline:confirm 发送成功
                        case 'share_timeline:confirm':
                        case 'share_timeline:ok':
                            callbacks.confirm && callbacks.confirm(resp);
                            break;
                    }
                    // 无论成功失败都会执行的回调
                    callbacks.all && callbacks.all(resp);
                });
            };
            WeixinJSBridge.on('menu:share:timeline', function (argv) {
                if (callbacks.async && callbacks.ready) {
                    if(!callbacks.__dataLoadedFuncInited) {
                        var loadedCb = callbacks.dataLoaded || new Function();
                        callbacks.dataLoaded = function (newData) {
                            loadedCb(newData);
                            shareTimeline(newData);
                        };
                        callbacks.__dataLoadedFuncInited = true;
                    }
                    // 然后就绪
                    callbacks.ready && callbacks.ready(argv);
                } else {
                    // 就绪状态
                    callbacks.ready && callbacks.ready(argv);
                    shareTimeline(data);
                }
            });
        }
    
        /**
         * 发送给微信上的好友
         * @param       {Object}    data       待分享的信息
         * @p-config    {String}    appId      公众平台的appId(服务号可用)
         * @p-config    {String}    imageUrl   图片地址
         * @p-config    {String}    link       链接地址
         * @p-config    {String}    desc       描述
         * @p-config    {String}    title      分享的标题
         *
         * @param       {Object}    callbacks  相关回调方法
         * @p-config    {Boolean}   async                   ready方法是否需要异步执行,默认false
         * @p-config    {Function}  ready(argv)             就绪状态
         * @p-config    {Function}  dataLoaded(data)        数据加载完成后调用,async为true时有用,也可以为空
         * @p-config    {Function}  cancel(resp)    取消
         * @p-config    {Function}  fail(resp)      失败
         * @p-config    {Function}  confirm(resp)   成功
         * @p-config    {Function}  all(resp)       无论成功失败都会执行的回调
         */
        function weixinSendAppMessage(data, callbacks) {
            callbacks = callbacks || {};
            var sendAppMessage = function (theData) {
                WeixinJSBridge.invoke('sendAppMessage', {
                    "appid":theData.appId ? theData.appId : '',
                    "img_url":theData.imgUrl,
                    "link":theData.link,
                    "desc":theData.desc,
                    "title":theData.title,
                    "img_width":"120",
                    "img_height":"120"
                }, function (resp) {
                    switch (resp.err_msg) {
                        // send_app_msg:cancel 用户取消
                        case 'send_app_msg:cancel':
                            callbacks.cancel && callbacks.cancel(resp);
                            break;
                        // send_app_msg:fail 发送失败
                        case 'send_app_msg:fail':
                            callbacks.fail && callbacks.fail(resp);
                            break;
                        // send_app_msg:confirm 发送成功
                        case 'send_app_msg:confirm':
                        case 'send_app_msg:ok':
                            callbacks.confirm && callbacks.confirm(resp);
                            break;
                    }
                    // 无论成功失败都会执行的回调
                    callbacks.all && callbacks.all(resp);
                });
            };
            WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                if (callbacks.async && callbacks.ready) {
                    if(!callbacks.__dataLoadedFuncInited) {
                        var loadedCb = callbacks.dataLoaded || new Function();
                        callbacks.dataLoaded = function (newData) {
                            loadedCb(newData);
                            sendAppMessage(newData);
                        };
                        callbacks.__dataLoadedFuncInited = true;
                    }
                    // 然后就绪
                    callbacks.ready && callbacks.ready(argv);
                } else {
                    // 就绪状态
                    callbacks.ready && callbacks.ready(argv);
                    sendAppMessage(data);
                }
            });
        }
    
        /**
         * 分享到腾讯微博
         * @param       {Object}    data       待分享的信息
         * @p-config    {String}    imageUrl   图片地址
         * @p-config    {String}    link       链接地址
         * @p-config    {String}    desc       描述
         * @p-config    {String}    title      分享的标题
         *
         * @param       {Object}    callbacks  相关回调方法
         * @p-config    {Boolean}   async                   ready方法是否需要异步执行,默认false
         * @p-config    {Function}  ready(argv)             就绪状态
         * @p-config    {Function}  dataLoaded(data)        数据加载完成后调用,async为true时有用,也可以为空
         * @p-config    {Function}  cancel(resp)    取消
         * @p-config    {Function}  fail(resp)      失败
         * @p-config    {Function}  confirm(resp)   成功
         * @p-config    {Function}  all(resp)       无论成功失败都会执行的回调
         */
        function weixinShareWeibo(data, callbacks) {
            callbacks = callbacks || {};
            var shareWeibo = function (theData) {
                WeixinJSBridge.invoke('shareWeibo', {
                    "content":theData.desc,
                    "link":theData.link,
                    "img_url":theData.imgUrl,
                    "title":theData.title,
                    "img_width":"120",
                    "img_height":"120"
                }, function (resp) {
                    switch (resp.err_msg) {
                        // share_weibo:cancel 用户取消
                        case 'share_weibo:cancel':
                            callbacks.cancel && callbacks.cancel(resp);
                            break;
                        // share_weibo:fail 发送失败
                        case 'share_weibo:fail':
                            callbacks.fail && callbacks.fail(resp);
                            break;
                        // share_weibo:confirm 发送成功
                        case 'share_weibo:confirm':
                        case 'share_weibo:ok':
                            callbacks.confirm && callbacks.confirm(resp);
                            break;
                    }
                    // 无论成功失败都会执行的回调
                    callbacks.all && callbacks.all(resp);
                });
            };
            WeixinJSBridge.on('menu:share:weibo', function (argv) {
                if (callbacks.async && callbacks.ready) {
                    if(!callbacks.__dataLoadedFuncInited) {
                        var loadedCb = callbacks.dataLoaded || new Function();
                        callbacks.dataLoaded = function (newData) {
                            loadedCb(newData);
                            shareWeibo(newData);
                        };
                        callbacks.__dataLoadedFuncInited = true;
                    }
                    // 然后就绪
                    callbacks.ready && callbacks.ready(argv);
                } else {
                    // 就绪状态
                    callbacks.ready && callbacks.ready(argv);
                    shareWeibo(data);
                }
            });
        }
    
        /**
         * 调起微信Native的图片播放组件。
         * 这里必须对参数进行强检测,如果参数不合法,直接会导致微信客户端crash
         * 
         * @param {String} curSrc 当前播放的图片地址
         * @param {Array} srcList 图片地址列表
         */
        function imagePreview(curSrc,srcList) {
            if(!curSrc || !srcList || srcList.length == 0) {
                return;
            }
            WeixinJSBridge.invoke('imagePreview', {
                'current' : curSrc,
                'urls' : srcList
            });
        }
    
        /**
         * 显示网页右上角的按钮
         */
        function showOptionMenu() {
            WeixinJSBridge.call('showOptionMenu');
        }
    
        /**
         * 隐藏网页右上角的按钮
         */
        function hideOptionMenu() {
            WeixinJSBridge.call('hideOptionMenu');
        }
    
        /**
         * 显示底部工具栏
         */
        function showToolbar() {
            WeixinJSBridge.call('showToolbar');
        }
    
        /**
         * 隐藏底部工具栏
         */
        function hideToolbar() {
            WeixinJSBridge.call('hideToolbar');
        }
    
        /**
         * 返回如下几种类型:
         *
         * network_type:wifi     wifi网络
         * network_type:edge     非wifi,包含3G/2G
         * network_type:fail     网络断开连接
         * network_type:wwan     2g或者3g
         *
         * 使用方法:
         * WeixinApi.getNetworkType(function(networkType){
         *
         * });
         *
         * @param callback
         */
        function getNetworkType(callback) {
            if (callback && typeof callback == 'function') {
                WeixinJSBridge.invoke('getNetworkType', {}, function (e) {
                    // 在这里拿到e.err_msg,这里面就包含了所有的网络类型
                    callback(e.err_msg);
                });
            }
        }
    
        /**
         * 当页面加载完毕后执行,使用方法:
         * WeixinApi.ready(function(Api){
         *     // 从这里只用Api即是WeixinApi
         * });
         * @param readyCallback
         */
        function wxJsBridgeReady(readyCallback) {
            if (readyCallback && typeof readyCallback == 'function') {
                var Api = this;
                var wxReadyFunc = function () {
                    readyCallback(Api);
                };
                if (typeof window.WeixinJSBridge == "undefined"){
                    if (document.addEventListener) {
                        document.addEventListener('WeixinJSBridgeReady', wxReadyFunc, false);
                    } else if (document.attachEvent) {
                        document.attachEvent('WeixinJSBridgeReady', wxReadyFunc);
                        document.attachEvent('onWeixinJSBridgeReady', wxReadyFunc);
                    }
                }else{
                    wxReadyFunc();
                }
            }
        }
    
        return {
            version         :"1.4",
            ready           :wxJsBridgeReady,
            shareToTimeline :weixinShareTimeline,
            shareToWeibo    :weixinShareWeibo,
            shareToFriend   :weixinSendAppMessage,
            showOptionMenu  :showOptionMenu,
            hideOptionMenu  :hideOptionMenu,
            showToolbar     :showToolbar,
            hideToolbar     :hideToolbar,
            getNetworkType  :getNetworkType,
            imagePreview    :imagePreview
        };
    })();

    转自:https://github.com/zxlie/WeixinApi/blob/master/WeixinApi.js