ma rick
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Visual Studio安裝工具 * *Web Compiler(SCSS -> CSS) 專案有在使用, 需安裝(或是自行安裝scss->css 的complier) 已把檔案加在jira(http://jira.evervictory-it.com:8080/browse/TKCMS-336) * AnkhSVN(非必要) # MVC簡易概要 一開始由Global.asax(後端MVC)當作進入點, 1. 瀏覽器像伺服器發出request 2. IIS接收封包 3. 轉給Route(Global.asax裡面的RegisterRoutes) 4. Route在決定要交給HttpHandler or MVCHandler來處理 ![](https://i.imgur.com/SjQzNHU.png) 專案裡會先由HomeController解析到App.cshtml 然後由於_ViewStart裡面有寫@layout 所以APP.cshtml裡面使用@Renderbody渲染index.cshtml ![](https://i.imgur.com/OddJKLt.png) 可參考: https://dotblogs.com.tw/dog0416/2016/06/09/205427 # FE(前端框架帮助文档) ## 框架设计依据 由于BC(博彩)类的web站点的展示形式,如下图所示,一般为一级导航加二级导航,且都是触发某一导航后,替换某一区域内的html片段,故该框架的核心方法为: ``` js option = { html: "", //html字符串,如某个<script type="text/html" id="tpl">中的内容 json: "", //服务端取数据地址 param: {}, //请求的参数 bd: $("#div"), //通过模板引擎生成好的html放到一个容器中 ... // 其它請直接翻代碼 }; loadModule(option); ``` ![](https://i.imgur.com/ViUStZw.png) ## 框架文件详解 * `template.js` // 模板引擎 全名ARTtemplate,第三方文件 可參考:https://aui.github.io/art-template/zh-cn/docs/ * `framework-init.js` // 框架核心文件 详细:该文件中产生两个对象,一个是 `Loader` 构造函数,`loadModule` 这个全局方法调用的就是这个构造函数,一个是 `G.util` 的静态方法,用于添加一些常用的静态方法,如生成`guid(G.util.guid)`,编译模板 `G.util.compile` * `framework-mapping.js` // 框架配置文件 配置每个模块,如导航切换需要用到的html模板地址和从服务端地址,如下 1. 第一種寫法 ```javascript G.map = { ssc: { rule: ["/Htmls/ssc/rule.html"], betdetail: ["/Htmls/betdetail.html", '/Bet/GetBettingSuccess/'], history: { history: ["/Htmls/history.html", "/Report/GetBetSummary/", format_history('history')], date: ["Htmls/history.html", "/Report/GetBetDateSummary/", format_history('date')], detail: ["Htmls/history.html", "/Report/GetBetDetail/", format_history('detail')] } }, pk10: { ... }, "lottery name": { "module name": ["template URL", "GET API URL", "callback function"] } }; ``` 2. 第二種寫法 ```javascript G.map = { betdetail: { html: { betdetail: "/Htmls/betdetail.html" //html }, json: { betdetail: "/Member/GetMemberBetRecord" // api }, format: { betdetail: format_betdetail //api回來的值, 再做處理(Ex: 可能畫面跟資料排序不同等等) } }, tema: { html: { tema: "/Htmls/playtype/tema.html" }, json: { tema: G.action_odds }, format: { tema: format_tema } } ``` * 设置页面初始需要加载哪个模块 ```javascript G.InitHash = "#!kuaida?pagesize=10"; ``` * 设置模板引擎的辅助函数 ```javascript template.helper("format_time", function(){}); ``` * 设置 `jquery.validate` 插件一些默认配置 ```javascript $.validator.setDefaults({}); ``` * 设置路由的回调函数 ```javascript G.hashFn = { supper: (function () { var nav = $("#nav a"); return function (hash_module) { var module = hash_module.module; G.util.load({ bd: main, module: module, param: hash_module.param || {}, html: hash_module.html, json: hash_module.json, hash: hash_module.hash, refresh: hash_module.refresh }); nav.removeClass("on").filter("[name=" + module + "]").addClass("on"); } })() }; $.each(G.map.ssc, function (module) { G.hashFn[module] = G.hashFn.supper; }); ``` 注意:导航中添加的模块名,需要添加到这里,才会执行模块加载方法。 * `jquery.hashchange.js` 浏览器url hash值变化后,调用hashchange事件,单页面浏览器前进后退时用到,第三方插件,调用已集成到`framework-init.js`中 * `jquery.dialog.js` //弹出框的插件 提供: ` $.alert("text", fn) //提示框 ` ` $.confirm("text", fn) //确认框 ` ` $.dialog(option) //弹出框 ` 弹出框分两种情况: 1. 普通的用法 ``` js $.dialog({ html : "<div>aaa</div>" //html片段 }); ``` 1. 加载服务器模板 ``` js $.dialog({ module: "" //framework-mapping.js 中配置的 G.map[name]中的name值 html: "" //远程模板地址 G.map[name].html[ name2 ] 中 name2的值 json: "" //远程模板地址 G.map[name].json[ name3 ] 中 name3的值 param: {} //需要用到的参数 }); ``` * `jquery.validate.js` //表单验证插件,第三方 ```javascript $("form").validate({ submitHandler: function (form) { _this.doSave(form); } }); ``` 現多以 `initialize.call(this);` 取代。 * `jquery.tooltip.js` //错误冒泡提示 ``` javascript $("input").tooltip({ html: "这是必填字段" //冒泡显示的内容 isFocus: true 是否获取焦点 isSelect: true 是否选中 }); ``` * `module-*.js` 对应模块的业务处理文件 ``` javascript function A (d) { //该形参 d 为一个Html片段中 `<div name="module" id=’a’></div>` 的元素引用 this.d = d; } ``` * module-* 玩法的命名規則通常是以拼音為主 Ex: module-tema(tema為特碼拼音) * `A.prototype.init = function(){}` //模块加载完成后会自动执行 init 方法 * `G.modules[moduleid] = A;` 建立 html 与 js 之间的关联 module id 为 div标签且name="module"的id值 * `module-pager.js` //分页模块 ```html <div name="module" id="pager" class="pager" action="account.account" hash="#!account" format="callback_function_name" param="a=123&b=567"> <select name="pagesize" class="pagesize"> {{pages = [10,20,30,60,100]}} {{each pages as page}} <option value="{{page}}" {{if Data.PageSize == page}}selected{{/if}}>{{page}}</option> {{/each}} </select> 第 <span class="pageindex red">{{Data.PageIndex}}</span> 页 共 <span class="pagecount red">{{Data.PageCount}}</span> 页 共 <span class="recordcount red">{{Data.RecordCount}}</span> 条 <a href="javascript:void(0)" class="fn-first">首页</a> <a href="javascript:void(0)" class="fn-prev">上一页</a> <a href="javascript:void(0)" class="fn-next">下一页</a> <a href="javascript:void(0)" class="fn-last">尾页</a> <input type="text" class="input w30 fn-index"> <input type="button" class="btn w30 fn-go" value="GO" /> </div> ``` 以上为一段分页 html 代码 當一頁有多個pager的話,記得在module.pager.js最下方多輸出 ``` javascript G.modules.pager = Pager G.modules.pager2 = Pager G.modules.pager3 = Pager G.modules.pager4 = Pager ``` `action: //需要请求的服务器地址` `pagebody: //需要将分页处理好的html片段放到哪个容器中,值为容器的id` `template: //需要用到哪个<script type="text/html" id="tpl">中的值作为分页的模板` `param: //分页需要用到的参数,格式 a=1&b=2` ## 完整url解析 当一个导航加上A链接,如 `href=" #!aaa.bbb|ccc?ddd=1 "` 解析成的格式 ``` javascript loadModule({ module: "aaa", html: "bbb", json:"ccc", param: {ddd : 1} }); ``` 當loadModule中有使用到param的話, 對應的html 裡面就可以使用到該資料 例: module-tema.js ```javasript loadModule({ module:"aaa", html: "bbb", json: "ccc", param: {ddd : 1} }) ``` bbb.html ```htmlmixed <div name="module"> <div> // Param要用大寫P // Param.ddd = 1 {{Param.ddd}} </div> </div> ``` `module-tema.js` //特碼的邏輯代码 先定义一个tema的构造函数 ``` javascript function Tema(d) { this.d = $(d); } ``` 一些事件绑定添加到其中,其中扩展方法自由发挥,如 ``` javascript Tema.prototype.init = function () { var _this = this; this.d.on("click", "#selectAll", function () { // do something }); this.d.on("click", ".fn-cancelbet", function () { _this.cancelBet(); }); } Tema.prototype.cancelBet = function () { // do something }; ``` 绑定html与js的关联 ``` js G.module.tema = Tema; * 框架內使用*javascript prototype*的寫法 ![](https://i.imgur.com/bnTBZdV.png) * 共用模塊 有些module-*.js裡面可能包含不同的html, 使用相同的模組 , 甚至不同的html, 不同的模組 舉例(marksix2 > Scripts > module-tema.js) ```javascript ... Tema.prototype.destroy = function () { if (this.id == 'zhengtema') { doc.triggerHandler("showZheng", [false]); } if (this.timer_oddsloop) { clearInterval(this.timer_oddsloop); } }; G.modules.tema = Tema; // 特碼 G.modules.zhengma = Tema; // 正碼 G.modules.zhengtema = Tema; // 正特碼 function QuickBet(d) { this.d = $(d); this.UseLastOdds = false; this.data = [d.json.Param]; } QuickBet.prototype.init = function () { initialize.call(this); this.BetMoney = $("#BetMoney").on("focus", function () { this.value = G.pre_set ? G.pre_money : this.value; }).val(G.pre_set ? G.pre_money : this.value).input_digits(); }; ... QuickBet.prototype.doFailBet = function (message) { var data = {}, param = { "List": this.data }; data.Message = message; $.extend(data, param); doc.triggerHandler("betfailed", [data]); }; G.modules.quickbet = QuickBet; ``` * html、json兩者互相如何傳遞資料? 以六平台為例 ```javascript G.map = { company: { html: { company: "/Htmls/company/company.html", }, json: { company: "/Company/GetCompanyList", } ``` 簡單來說,讀取company.html後會打GetCompanyList的api, 然後會進入到在framwork-init.js裡面的Loader, 其中 ```javascript Loader.prototype.getJSON = function(){ var _this = this; jsonurl = /^\/.+/.test(option.json) ? option.json : option.json ? G.map[option.module].json[option.json] : option.module && !option.html ? G.map[option.module].json[option.module] : null; if (!jsonurl) { this.flag += 1; this.flashHTML(option); return; } G.get({ url: jsonurl, data: option.param, success: function (json) { _this.flag += 1; _this.jsondata = json; **會把值塞到jsondata裡面** if (option.jsonSuccess) { _this.jsondata = option.jsonSuccess(json) || json; } else { if (!option.html && !option.json) { _this.jsondata = G.map[option.module].format && G.map[option.module].format[option.module] ? G.map[option.module].format[option.module](json) || json : json; } else if (option.module && option.json) { _this.jsondata = G.map[option.module].format && G.map[option.module].format[option.json] ? G.map[option.module].format[option.json](json) || json : json; } } if(!option.hash || option.hash == G.util.getHash()){ _this.flashHTML(option); } }, } ``` 最後在Loader.prototype.flashHTML裡的 ```javascript this.jsondata.LoginAccount = LOGIN_ACCOUNT; **其他要共用的東西可參照此寫法 strHTML = G.util.compile(this.template, this.jsondata); ``` 再把jsondata跟template compile ,html就會拿到資料 * HTML標籤內驗證 ```html= <input type="text" class="w60 ime-dis" id="pre_money" lessthan="100"> ``` lessthan 是設定值小於100,相關設定在framework-mapping.js內 ```javascript $.validator.addMethod("lessthan", function (value, element, param) { var val = $.trim($(param).val()); val = val ? parseFloat(val) : null; value = parseFloat(value); return this.optional(element) || !val || value <= val; }, "搜索的最小值不能超过最大值!"); ``` 其他驗證有positive(正數)positivedigits(正整數)nonnegative(非負數)...等

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully