zoukankan      html  css  js  c++  java
  • 测试语法高亮显示

    测试第一种语法高亮:javascript
    /**
     * @author macleo
     */
    //var xhr = createXHR();
    var xhr=null;
    var url=null;
    
    function createXHR()
    {
    	
    	if (window.ActiveXObject)//判断IE内置对象
    	{
    		xhr = new ActiveXObject("Microsoft.XMLHTTP");
    	}
    	else if(window.XMLHttpRequest)//firefox内置对象
    	{
    		xhr = new XMLHttpRequest();
    	}
    	//return xhr;//return xmlhttprequest object
    }
    
    function startRequest(num){
    		createXHR();
    		url = getUrl(num);
    		xhr.open("GET", url ,true);//url的意义何在?//获取信息的url
    		xhr.onreadystatechange = handleResponse;
    		xhr.send(null);
    }
    
    /* get different url */
    function getUrl(num)
    {
    	switch(num)
    	{
    		case 1:url = "xml/inner.xml";
    			break;
    		case 2:url = "xml/macleo.xml";
    			break;
    		case 3:url = "validate.php";
    			break;
    		case 4:url = "xml/case4.html";
    			break;
    		default:url = "xml/inner.xml";
    	}
    	return url;
    }
    
    
    function handleResponse()
    {
    if (xhr.readyState == 4 && xhr.status == 200) {
    	document.getElementById("content").innerHTML = xhr.responseText;
    }
    }
    
    function retrieveRequest()
    {
    	document.getElementById("content").innerHTML ="123";
    }
    
    测试第二种语法高亮:Java
    import ij.*;
    import ij.io.*;
    import ij.plugin.PlugIn;
    import com.visualtek.png.*;

    /**
    Uses the PNG library from http://www.visualtek.com/javapng.html to
    save an image in PNG format. The png.jar file must be in the CLASSPATH.
    */
    public class PNG_Writer implements PlugIn {

     
    public void run(String arg) {
       
    ImagePlus imp = WindowManager.getCurrentImage();
       
    if (imp == null) {
         
    IJ.showMessage("Save as PNG", "No images are open.");
         
    return;
       
    }
       
    SaveDialog sd = new SaveDialog("Save as PNG", imp.getTitle(), ".png");
        String file = sd.getFileName
    ();
       
    if (file == null) return;
        String directory = sd.getDirectory
    ();

       
    try {
         
    new PNGEncoder(imp.getImage(), directory+file).encode();
       
    }
       
    catch(Exception e)  {IJ.showMessage("Save as PNG", ""+e);}
      }

    }

    第三种语法高亮的方法:

     1 function SetTheme($aTheme) {
     2    ifin_array($aTheme,array_keys($this->themearr)) )
     3        $this->theme = $aTheme;
     4    else
     5        JpGraphError::RaiseL(15001,$aTheme);//("PiePLot::SetTheme() Unknown theme: $aTheme");
     6    }
     7    
     8    function ExplodeSlice($e,$radius=20) {
     9    if! is_integer($e) ) 
    10        JpGraphError::RaiseL(15002);//('Argument to PiePlot::ExplodeSlice() must be an integer');
    11    $this->explode_radius[$e]=$radius;
    12    }
    13
    14    function ExplodeAll($radius=20) {
    15    $this->explode_all=true;
    16    $this->explode_r = $radius;
    17    }
    18
    19    function Explode($aExplodeArr) {
    20    if!is_array($aExplodeArr) ) {
    21        JpGraphError::RaiseL(15003);
    22//("Argument to PiePlot::Explode() must be an array with integer distances.");
    23    }
    24    $this->explode_radius = $aExplodeArr;
    25    }
    26
    27    function SetStartAngle($aStart) {
    28    if$aStart < 0 || $aStart > 360 ) {
    29        JpGraphError::RaiseL(15004);//('Slice start angle must be between 0 and 360 degrees.');
    30    }
    31    $this->startangle = 360-$aStart;
    32    $this->startangle *= M_PI/180;
    33    }
    34    
    35    function SetFont($family,$style=FS_NORMAL,$size=10) {
    36    JpGraphError::RaiseL(15005);//('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.');
    37    }
    38    
    39    // Size in percentage
    40    function SetSize($aSize) {
    41    if( ($aSize>0 && $aSize<=0.5|| ($aSize>10 && $aSize<1000) )
    42        $this->radius = $aSize;
    43    else
    44        JpGraphError::RaiseL(15006);
    45//("PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels  in the range [10, 1000]");
    46    }
  • 相关阅读:
    centos7安装kde桌面
    centos7安装NVIDIA驱动
    15日报
    11日报
    14日报
    奖励加分
    课程建议
    13日报
    12日报
    每日总结1213
  • 原文地址:https://www.cnblogs.com/macleo/p/1234423.html
Copyright © 2011-2022 走看看