作者: zhongdaiqi

  • 加载非规范的模块

    官方示例:

    http://www.requirejs.org/jqueryui-amd/example/webapp/app.html

    /**
      * Ask for 'require', 'jquery' and 'jqueryui/tabs' as dependencies.
      *
      * 'require' is asked for as best practice, since it used inside the
      * require callback to dynamically load the datepicker. Since 'require'
      * is a module (provided by RequireJS), it is passed as the first argument
      * to the require callback. "req" is used as the function argument name
      * so the RequireJS optimizer will not pick up the dynamic load of
      * the 'jqueryui/datepicker', 'jqueryui/datepicker-fr' modules and
      * include them in the optimized build for main.js (see app.build.js
      * for more information on the optimized main.js build profile.)
      *
      * The require-jquery.js file registers jQuery as a module,
      * so this require callback will receive it as the second function
      * argument, since 'jquery' is the second dependency in the
      * dependency array.
      *
      * 'jquery/ui/tabs' does not export a module
      * value (it just augments jQuery), so it will not have a value for it
      * passed to the require callback. No need to assign a function argument
      * for it.
      */
    require({
        //Set config for finding 'jqueryui'. The path is relative
        //to the location of require-jquery.js.
        paths: {
            jqueryui: 'jqueryui-1.8.13/jqueryui'
        }
    }, ['require', 'jquery', 'jqueryui/tabs'], function (req, $) {
    
        //Wait for dom ready before setting up widgets.
        $(function () {
    
            //Make the tabs.
            $('#tabs')
                .tabs({
                    load: function (event, ui) {
                        //If the second tab is clicked, dynamically load
                        //the datepicker.
                        if (ui.index === 1) {
                            //Load the datepicker in French, on demand.
                            req(['jqueryui/datepicker', 'jqueryui/datepicker-fr'],
                                function () {
                                    $('#datepicker').datepicker();
                                }
                            );
                        }
                    }
                })
                //Make the tabs visible now that the widget has been instantiated.
                .removeClass('invisible');
        });
    });

     

    网上帖子:

    理论上,require.js加载的模块,必须是按照AMD规范、用define()函数定义的模块。但是实际上,虽然已经有一部分流行的函数库(比如jQuery)符合AMD规范,更多的库并不符合。那么,require.js是否能够加载非规范的模块呢?

    回答是可以的。

    这样的模块在用require()加载之前,要先用require.config()方法,定义它们的一些特征。

    举例来说,underscore和backbone这两个库,都没有采用AMD规范编写。如果要加载它们的话,必须先定义它们的特征。

    require.config({     shim: {       ‘underscore’:{         exports: ‘_’       },       ‘backbone’: {         deps: [‘underscore’, ‘jquery’],         exports: ‘Backbone’       }     }   });

     

     

    require.config()接受一个配置对象,这个对象除了有前面说过的paths属性之外,还有一个shim属性,专门用来配置不兼容的模块。具体来说,每个模块要定义(1)exports值(输出的变量名),表明这个模块外部调用时的名称;(2)deps数组,表明该模块的依赖性。

    比如,jQuery的插件可以这样定义:

    shim: {
        'jquery.scroll': {
          deps: ['jquery'],
          exports: 'jQuery.fn.scroll'
        }
      }

    转自:http://www.ruanyifeng.com/blog/2012/11/require_js.html

  • jqueryui datepicker 选择中文年月时错误换行的解决办法

    jQueryUI的datepicker日期选择控件有中文换行问题,看起来很不爽的。网上找到两个修正方案试了试。修正了一下这个bug。

    先睹为快,先看看修正后的效果

    image

     

    解决办法,在jquery-ui-1.8.16.custom.css中找到 .ui-datepicker select.ui-datepicker-year { width: 49%;} 改成 .ui-datepicker select.ui-datepicker-year { width: 45%;}  

    网上写的改成35%,看起来比较别扭的,经测试,45%看起来比较爽~ 

    其他版本的jQueryUI问题也适用!

    参考:http://blog.csdn.net/yzhai/article/details/7013730   +1


    台湾的一位亲写到:

    jQuery UI Datepicker繁體中文年月選單換行的小修正

    解決方法很簡單,用編輯器打開 e:\TEMP\jqueryui\development-bundle\themes[theme name] 底下的 jquery.ui.datepicker.css 或 jquery-ui-1.8.1.custom.css ,找到 .ui-datepicker .ui-datepicker-title 的 class,加上 white-space: nowrap; 存檔修正。

    尝试此方法发现,到是真没有换行了,只是下拉框挤到边上来了,效果不是很好。见下图:

    image

    参考:http://blog.tenyi.com/2010/05/jquery-ui-datepicker.html

  • common_member_count’ is marked as crashed and should be repaired

    Discuz报common_member_count’ is marked as crashed and should be repaired

  • 使用Web方式刷新应用程度池

     protected void Button1_Click(object sender, EventArgs e)
            {
                // 调用代码
                string[] cmd = new string[] { "appcmd recycle apppool /apppool.name: DQSite(8000)" };
                //MessageBox.Show(Cmd(cmd));
                TextBox1.Text = Cmd(cmd);
                CloseProcess("cmd.exe");
            }
    
            /// <summary>
            /// 运行CMD命令
            /// </summary>
            /// <param name="cmd">命令</param>
            /// <returns></returns>
            public static string Cmd(string[] cmd)
            {
                Process p = new Process();
                p.StartInfo.FileName = "cmd.exe";
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.CreateNoWindow = true;
                p.Start();
                p.StandardInput.AutoFlush = true;
                for (int i = 0; i < cmd.Length; i++)
                {
                    p.StandardInput.WriteLine(cmd[i].ToString());
                }
                p.StandardInput.WriteLine("exit");
                string strRst = p.StandardOutput.ReadToEnd();
                p.WaitForExit();
                p.Close();
                return strRst;
            }
    
            /// <summary>
            /// 关闭进程
            /// </summary>
            /// <param name="ProcName">进程名称</param>
            /// <returns></returns>
            public static bool CloseProcess(string ProcName)
            {
                bool result = false;
                System.Collections.ArrayList procList = new System.Collections.ArrayList();
                string tempName = "";
                int begpos;
                int endpos;
                foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses())
                {
                    tempName = thisProc.ToString();
                    begpos = tempName.IndexOf("(") + 1;
                    endpos = tempName.IndexOf(")");
                    tempName = tempName.Substring(begpos, endpos - begpos);
                    procList.Add(tempName);
                    if (tempName == ProcName)
                    {
                        if (!thisProc.CloseMainWindow())
                            thisProc.Kill(); // 当发送关闭窗口命令无效时强行结束进程
                        result = true;
                    }
                }
                return result;
            }
    .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; }

    使用网页形式来刷新应用程序池可以防止多人抢线远程登陆,也更方便,可以在一个页面上完成刷新,测试

    扩展应用:

    用于以web方式管理站点,可开通、删除、设置,做主机管理软件

    参考:

    http://www.cnblogs.com/njnudt/archive/2009/12/03/1616135.html

  • help main site learn.knockoutjs.com

    http://learn.knockoutjs.com/#/?tutorial=intro 直接在线学习

    <!– This is a view – HTML markup that defines the appearance of your UI –> <p>First name: <strong data-bind="text: firstName"></strong></p> <p>Last name: <strong data-bind="text: lastName"></strong></p> <p>Full name: <strong data-bind="text: fullName"></strong></p> <p>First name: <input data-bind="value: firstName"/></p> <p>Last name: <input data-bind="value: lastName"/></p>

    // This is a simple viewmodel – JavaScript that defines the data and behavior of your UI function AppViewModel() { this.firstName = ko.observable("Bert"); this.lastName = ko.observable("Bertington2121"); this.fullName = ko.computed(function(){ return this.firstName()+" "+ this.lastName(); },this); } // Activates knockout.js ko.applyBindings(new AppViewModel());

    knockoutjs 练习界面:

    image