Group Blog
 
<<
กันยายน 2552
 12345
6789101112
13141516171819
20212223242526
27282930 
 
18 กันยายน 2552
 
All Blogs
 
ปรับปรุง Longman Dictionary of Contemporary English 2009 เพิ่มความสามารถในการก้อปปี้(4)

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

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

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


โดยปกติการก้อปปี้ในลองแมนจะทำได้โดยใช้เมนู Copy เท่านั้นและจะก้อปคำปัจจุบันพร้อมคำแปลมาทั้งแผง ไม่สามารถเลือกข้อความที่จะก็อปได้
ตอนนี้จะเป็นการเพิ่มฟังชั่นให้สามารถก็อปข้อความที่เลือกไว้ได้โดยใช้เมาส์ปุ่มขวา หรือ Crlt + C หรือเมนู Copyการก้อปนี้จะก้อปไปทั้งข้อความและฟอร์แม็ตของข้อความนั้นด้วย
 
วิธีทำ
  1. โหลดไฟล์ shortcut.js จาก //wwwjs.com/scripts/events/keyboard_shortcuts/ไปไว้ใน C:Program FilesLongmanLDOCE5chromeldoce5contentjs

  2. แก้ไขไฟล์C:/ProgramFiles/Longman/LDOCE5/chrome/plugs.jarไฟล์นี้จริงๆแล้วเป็นไฟล์zipข้างในจะมีโครงสร้างไดเร็กทอรี่และไฟล์ย่อยๆซ่อนอยู่ให้หาโปรแกรมบีบอัดไฟล์มาเปิดWinzip ก็ได้ Winrar ก็ได้
    แต่แนะนำ 7zip เพราะฟรีโหลดได้ที่นี่ www.7-zip.org/download.html

    ให้เพิ่มโค้ดสีแดงนี้เข้าไปใน  plugs/content/skVirtualList/xbl/skVirtualList.xml ที่อยู่ในไฟล์ plugs.jar 

  3.   <xbl:handlers>
                <xbl:handlerevent="click" button="2" action="copySelection();"/>
               <xbl:handler event="focus" action="this.focused = true;"/>
               <xbl:handler event="blur" action="this.focused = false;"/>

  4. แก้ไขไฟล์ C:/ProgramFiles/Longman/LDOCE5/chrome/ldoce5/content/flash/homepage/main_app.xulโดยเปลี่ยนให้เมนูไปเรียกฟังชั่น copySelection() แทนฟังชั่นwin.skGroups.selectedGroup.copy()

                            <hboxclass="toolmenu" debug="true">
                                   <label value="Home" onclick="setMode('home');"/>
                                   <spacer class="toolseparator"/>
                                   <label value="Copy" onclick="copySelection();"/>
                                   <spacer class="toolseparator"/>  


    จากนั้นเพิ่มStatusbarโดยเพิ่มโค้ดสีแดงเข้าไปที่ท้ายไฟล์

       </deck>
       <statusbar id="statusbarMain" style="background: #EFEFEF;border:outset 0px gray" collapsed="true">
           <statusbarpanel style="border:inset 1pxgray;font-size:9pt;padding:0px 5px 0px 1px;color:blue;"id="statusbarLeftPanel" label="" flex="1"/>
           <spacer style="margin: 0px 5px 0px 5px; width: 1px;background-color: #AAAAAA"/>
           <statusbarpanel style="border:groove 1px gray;font-size:9pt;padding:0px 5px 0px 5px;cursor:pointer;"label="//blog.sina.com.cn/zhangliminqd"/>
       </statusbar>
    </window>

    แล้วเพิ่มโค้ดสีแดงนี้เข้าไปที่หัวไฟล์เพื่ออ้างถึงไฟล์ shortcut.js

    1.                <scripttype="text/javascript"src="chrome://ldoce5/content/js/shortcut.js"/>

  5. เพิ่มฟังชั่น copySelection()และฟังชั่นที่ใช้ควบคุม Statusbar ตามโค้ดด้านล่างเข้าไปในไฟล์C:/ProgramFiles/Longman/LDOCE5/chrome/ldoce5/content/js/application.js 

    //Copy selection text to clipboard with its format
    functioncopySelection() {
       try {
           var focusedWindow =this.window.document.commandDispatcher.focusedWindow;
           var objSelection = focusedWindow.getSelection();
           var objRange = objSelection.getRangeAt(0);
           var objClone = objRange.cloneContents();
           //var objDiv =focusedWindow.document.createElementNS("//www.w3.org/1999/xhtml","html:div");
           var objDiv = focusedWindow.document.createElement("Entry");
           //objDiv.className = "contentEntryItem";
           objDiv.appendChild(objClone);
           var objBody = focusedWindow.document.createElement("Section");
           objBody.appendChild(objDiv);

           skCopy.add( objBody );
           skCopy.putInClipoard("text/unicode");
           showHintMessage( "The selected texts have been copied to theclipboard!" );
       } catch (e) {
          win.skGroups.selectedGroup.copy()
           showHintMessage( "The current entry has been copied to the clipboard!");

       }
    }


    // Show hintmessage
    functionshowHintMessage( msg ) {
       showStatusbar();
       win.document.getElementById("statusbarLeftPanel").label = msg;
       g_StatusbarHideTimer =setTimeout("hideStatusbar()", 5000);
    }

    // show status bar
    functionshowStatusbar() {
       var statusbarMain =win.document.getElementById("statusbarMain");
       var show = true;
       if (statusbarMain.collapsed)
           show = false;
       if (!show)
           $(statusbarMain).removeAttr("collapsed");
       if (g_StatusbarHideTimer)
       {
           clearTimeout( g_StatusbarHideTimer );
           g_StatusbarHideTimer = null;
       }
    }

    // Hide status bar
    functionhideStatusbar() {
       var statusbarMain =win.document.getElementById("statusbarMain");
       var show = true;
       if (statusbarMain.collapsed)
           show = false;
       if (show)
       {
           $(statusbarMain).attr("collapsed", "true");
           g_StatusbarHideTimer = null;
       }
    }

  6. จากนั้นให้เพิ่มโค้ดนี้เข้าไปที่ท้ายฟังชั่น app_init( )เพื่อสร้างปุ่มลัดctrl+c
       
           setMode('home')
                shortcut.add("ctrl+c", copySelection );
             } catch(e) { jsLog("app_init failed: " +e); }
                   
          }



    ทีนี้เมื่อกด้เมาส์ปุ่มขวา หรือ Crlt + C หรือใช้เมนู Copy ก็จะมีstatusbar แสดงสถาณะการก้อปปี้ขึ้นมา และก้อปข้อความที่เลือกไว้เข้าไปในclibboard แต่ถ้าไม่ได้เลือกอะไรไว้ก็จะก้อปทั้ง entry แทน











Create Date : 18 กันยายน 2552
Last Update : 18 กันยายน 2552 21:19:27 น. 0 comments
Counter : 540 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.