Group Blog
 
<<
ตุลาคม 2552
 
 123
45678910
11121314151617
18192021222324
25262728293031
 
12 ตุลาคม 2552
 
All Blogs
 
ปรับปรุง Longman Dictionary of Contemporary English 2009 แก้หน้าต่าง practice pronunciation (7)

longmanการแก้ไขลองแมนตอนนี้และตอนต่อๆไปได้มาจากเว็บบล็อกของชาวจีนท่านหนึ่งสามารถเข้าไปดูได้ที่

//blog.sina.com.cn/s/blog_538a1d910100fasq.html~type=v5_one&label=rela_nextarticle

ไฟล์ที่ได้รับการแก้ไขแล้วสามารถดาว์นโหลดได้ที่ //orchidflower.ys168.com
ขอขอบคุณเจ้าของบล็อกที่อนุญาติให้นำมาเผยแพร่ต่อ เนื้อหาของตอนนี้จะต่างจากต้นฉบับอยู่เล็กน้อย

เนื้อหาตอนนี้จะเป็นการเพิ่มปุ่มสั่งงานและปุ่มลัดให้กับหน้าต่างPractice Your Pronunciation

หลังจากแก้แล้ว



รายการปุ่มลัดที่ใช้ได้กับหน้านี้

Esc ปิดหน้าต่าง
F10 ก็อปซอร์สโค้ด
Ctrl+C ก็อปเนื้อหา
backquote เลือกประโยคก่อนหน้า
1 เลือกประโยคต่อไป
Tab ออกเสียง
F1or Shift+Tab บันทึกเสียง
F2 or Ctrl+Tab เล่นเสียงที่บันทึกไว้


    วิธีทำ
    1. เพิ่มโค้ดเข้าไปในไฟล์ C:/ProgramFiles/Longman/LDOCE5/chrome/ldoce5/content/popup/dict_extern_link.xml
    2.       <html xmlns="//www.w3.org/1999/xhtml">
          <head>
             <title>External link</title>
             <link rel="stylesheet" type="text/css"href="chrome://ldoce5/skin/dict_extern_link.css"></link>
             <script type="text/javascript"src="chrome://plugs/content/js/utils.js"></script>
             <script type="text/javascript"src="chrome://plugs/content/js/widget.js"></script>
             <script type="text/javascript"src="chrome://ldoce5/content/js/dict_extern_link.js"></script>
               <scripttype="text/javascript"src="chrome://plugs/content/js/clipboard.js"/>
              <scripttype="text/javascript"src="chrome://ldoce5/content/js/shortcut.js"></script>
          </head>
          <body onload="init(winGM,extraArgs.title, extraArgs.label, extraArgs.refs, extraArgs.css,
             extraArgs.entryId, extraArgs.bgColor);" onfocus   ="winGM.skPopup.closePopupChildren(window);oncontextmenu="returncopySelection();">
             <div id="popup-subtitle"/>
             <div id="layerRecorder"style="margin:0px; display:none; background-color:lightblue;border:1pxsolid #FFFFFF;height:50px;text-align:center">
                 <select type="single" id="soundlist"style="width:99%;margin-left:2px;margin-top:2px;margin-right:2px">
                 </select>
                 <br/>
                 <input type="button" value="   Play    " accesskey="1" id="btnPlay"onclick="btnPlayClick();"/>
                 <input type="button" value="  Record   " id="btnRecord" accesskey="2"onclick="btnRecordClick();"/>
                 <RECORD id="btnRecord2"/>
                 <input type="button" value="  Play Back "id="btnPlayBack" accesskey="3" onclick="btnPlayBackClick();"/>
                 <PLAYBACK id="btnPlayBack2"/>
             </div>
          </body>
      </html>
    3. เพิ่มโค้ดเข้าไปในไฟล์ C:/ProgramFiles/Longman/LDOCE5/chrome/ldoce5/content/js/dict_extern_link.js
      • เพิ่ม Global variable
      const XHTML ="//www.w3.org/1999/xhtml";
      varisPracticePronunciation = false;
      var pronsList =null;
      var csstype = null;

      • เพิ่มโค้ดในฟังก์ชั่น init
      function init (winGM,title, label, refs, css, entryId, bgColor) {
         if (label=="Practice your pronunciation")
             isPracticePronunciation = true;
         if (entryId)
             window.entryId = entryId;
         if (css)
             addCss(css);
               csstype = css;
         try {
             document.title = title;
             setPopupSubtitle(label, bgColor);
             loadEntry(refs);
             giveFunction(winGM);
             setupDoubleClick(winGM);
             shortcut.add("esc", function(){window.close();} );
             shortcut.add("ctrl+c", function(){copySelection();} );
             shortcut.add("f10", viewSource );
             if (isPracticePronunciation)
             {
                 document.getElementById("layerRecorder").style.display = "block";
                 document.getElementById("popup-subtitle").style.marginBottom = "0px";
                 // binding hotkeys
                 shortcut.add("backquote", btnPreviousClick );
                 shortcut.add("1", btnNextClick );
                 shortcut.add("tab", btnPlayClick );
                 shortcut.add("ctrl+tab", btnPlayBackClick );
                 shortcut.add("f1", btnRecordClick );
                 shortcut.add("shift+tab", btnRecordClick );
                 shortcut.add("f2", btnPlayBackClick );
                 document.getElementById("soundlist").focus();
             }

         }
         catch(e) {

             winGM.jsLog("Error in init: "  +e);
         }
      }

      • เพิ่มโค้ดในฟังก์ชั่น loadEntry
      function loadEntry(refs) {
         var content = "<div id=/"content/" xmlns=/"" + XHTML +"/">";
         var entry, fs, publisher_id, idm_id;
         for (var i = 0 ; i < refs.length ; i++) {
             fs = winGM.skResourceManager.prefix(refs[i].resource + ".skn");
             publisher_id = refs[i].topic;
             try {
                 // retrieve the idm_id matching the publisher id
                 idm_id = winGM.skTabManager.getIdMapping(fs, publisher_id);
                 entry = winGM.skTabManager.getFile(fs + "/config.cff",idm_id).GetData().GetWStringData();
                 content += entry;
             }
             catch (e) {
                 winGM.jsLog("Error when initializing the external links for thedictionary (fs=" + fs +
                         ", publisher_id=" + publisher_id + ") - DVD missing?: " + e);
                 // probably the DVD missing, just close the popup
                 window.close();
                 //content += "<error>Error when retrieving the item #" +publisher_id + " in " + fs + "</error>";
             }
         }
         content += "</div>";
         content =content.replace(/(<[^>]+?fold="yes"[^>]*>)/g,"$1<button xmlns=/"" + XHTML + "/"class=/"arrow-fold/"/>");
         var parser = new DOMParser();
         var xmlDoc = null;
         try {
             xmlDoc = parser.parseFromString(content, "application/xml");

             if (isPracticePronunciation) {
                 nodes = xmlDoc.getElementsByTagName("Audio");
                 examples = xmlDoc.getElementsByTagName("EXAMPLE");
                 hwd = xmlDoc.getElementsByTagName("HWD");

                 pronsList = new Array( nodes.length );
                 for (i=0;i<nodes.length ;i++ )
                 {
                     var temp=new Array(3);
                     temp[0] = nodes[i].getAttribute("resource");
                     temp[1] = nodes[i].getAttribute("topic");
                     if (i>=2) {
                         if (examples[i-2].childNodes[0]) {  // Example text is existing


                             temp[2] = examples[i-2].childNodes[0].nodeValue;
                         }
                         else
                             temp[2] = "[NO AVAILABLE TEXTs]";
                     }
                     else {
                         if (i==0)
                             temp[2] = hwd[0].childNodes[0].nodeValue + "   GB";
                         else
                             temp[2] = hwd[0].childNodes[0].nodeValue + "   US";
                     }
                     pronsList[i] = temp;
                 }
                 var objSoundlist = document.getElementById("soundlist");
                 var count = pronsList.length;
                 for (i=0;i<count ;i++ ) {


                     var newOption=new Option(pronsList[i][2], i);
                     objSoundlist.options.add(newOption);
                 }
                 //set default pronunciation
                 objSoundlist.selectedIndex = winGM.g_AutoPlay-1;
             }
            document.getElementsByTagName("body")[0].appendChild(xmlDoc.firstChild);




      }
           
         catch (err) {
             winGM.jsLog("Error while parsing the document: " + err);
             return;
         }
      }

      • เพิ่มฟังก์ชั่นไปที่ท้ายไฟล์
      functionbtnPlayClick() {
          try {
             var pronIndex =document.getElementById("soundlist").selectedIndex;
             var file = pronsList[pronIndex][1];
             var typeSnd = pronsList[pronIndex][0];;
             var mainWindow = window.winOpener;
             if(mainWindow.app_play)
                 mainWindow.app_play(file, typeSnd);
          }
          catch(e){
             alert( e );
          }
      }
      functionbtnRecordClick() {
          try {
             var button = document.getElementById("btnRecord2");
             button.action();
          }
          catch(e){
             alert( e );
          }
      }
      functionbtnPlayBackClick() {
          try {
             var button = document.getElementById( "btnPlayBack2" );
             button.action();
          }
          catch(e){
             alert( e );
          }
      }
      functionbtnNextClick() {
          try {
             var count =document.getElementById("soundlist").options.length;
             var curIndex =document.getElementById("soundlist").selectedIndex;
             curIndex += 1;
             if (curIndex>=count) {
                 curIndex = count-1;
             }
             document.getElementById("soundlist").selectedIndex =curIndex;
          }
          catch(e){
             alert( e );
          }
      }
      functionbtnPreviousClick() {
          try {
             var count =document.getElementById("soundlist").options.length;
             var curIndex =document.getElementById("soundlist").selectedIndex;
             curIndex -= 1;
             if (curIndex<0) {
                 curIndex = 0;
             }
             document.getElementById("soundlist").selectedIndex =curIndex;
          }
          catch(e){
             alert( e );
          }
      }
       functioncopySelection() {
          try {
             var focusedWindow = this.window;
             var objSelection = focusedWindow.getSelection();
             if (objSelection.rangeCount==0) return;
             var objRange = objSelection.getRangeAt(0);
             var objClone = objRange.cloneContents();
              
             var objTemp;
             if (csstype.match("examples"))
                 objTemp = focusedWindow.document.createElement("examples");//NS("//www.w3.org/1999/xhtml","examples");
             else if (csstype.match("collocations"))
                 objTemp = focusedWindow.document.createElement("body");//NS("//www.w3.org/1999/xhtml","body");
             else if (csstype.match("thesaurus"))
                 objTemp = focusedWindow.document.createElement("body");//NS("//www.w3.org/1999/xhtml","body");
             else if (csstype.match("phrases"))
                 objTemp = focusedWindow.document.createElement("Phrases"); //NS("//www.w3.org/1999/xhtml","Phrases");
             else if (csstype.match("pronpractice"))
                 objTemp =focusedWindow.document.createElement("ENTRY");   //NS("//www.w3.org/1999/xhtml","ENTRY");
             else
                 objTemp = focusedWindow.document.createElement("div"); //NS("//www.w3.org/1999/xhtml","div");

             objTemp.appendChild(objClone);
             //alert( objTemp.innerHTML );
             skCopy.add( objTemp );
             skCopy.putInClipoard("text/unicode");
             //putInClipoard( objTemp.innerHTML, null, "text/unicode");
             //showHintMessage( "The selected texts have been copied to theclipboard!" );
             return false;
          } catch (e) {
             alert( e );
          }
      }

      function viewSource() {
          try {
             //alert( document.documentElement.innerHTML );
             putInClipoard( document.documentElement.innerHTML, null,"text/unicode");
          }
          catch (e)
          {
             alert( e );
          }
      }




    Create Date : 12 ตุลาคม 2552
    Last Update : 12 ตุลาคม 2552 20:45:08 น. 0 comments
    Counter : 691 Pageviews.

    ชื่อ : * blog นี้ comment ได้เฉพาะสมาชิก
    Comment :
      *ส่วน comment ไม่สามารถใช้ javascript และ style sheet
     

    anchan42
    Location :


    [ดู Profile ทั้งหมด]

    ฝากข้อความหลังไมค์
    Rss Feed

    ผู้ติดตามบล็อก : 1 คน [?]




    Friends' blogs
    [Add anchan42's blog to your web]
    Links
     

     Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.