/************** * @description カーソル位置のURLをEmEditorで開く。 *(XmlHttp版) * http://www.livedoor.com/ のように * URLにカーソルがある時,このマクロを実行すると、 * そのコンテンツを新規タブで開きます。 * ソース表示が出来ない場合に有効かもしれません。 * HTMLを編集時にリンクしたCSS や JS の中身確認に便利です * 注意)EUC文字コードの処理が正しくできません。 * @lastmodified 2006/11/28 * @author takuya_1st * @name viewSrcInNewTab.jsee * @version 1.0 alpha */ function XmlHttpRequest(){ this.context = null;//static this.timeID = null; this.xmlhttp = function(){//static var obj = new ActiveXObject("Microsoft.XMLHTTP"); this.timeID = ""; return obj; } this.request = function(url){ var req = this.xmlhttp(); req.open("GET", url, false ); req.send(null); this.context = req.responseText; this.typeName( req.getResponseHeader("Content-Type") ); this.status = req.status; } this.typeName = function ( str ){ //text/htmlから、HTMLを、text/plainからTEXTを返す this.responseMajorType = str.split("/")[0]; this.responseSubtype = str.split("/")[1]; } } document.selection.copyLink(); text = Window.clipboardData.getData("Text"); if(text.indexOf("http://") == 0) { var client = new XmlHttpRequest(); client.request(text); if( client.status >= 200 && client.status < 400 ){ if( client.responseMajorType == "text" ){ editor.newFile(); document.write(client.context); document.selection.StartOfDocument(); switch( client.responseSubtype ){ case("vbscript"): document.ConfigName = "VBScript";break; case("javascript"): document.ConfigName = "JavaScript";break; case("css"): document.ConfigName = "CSS";break; case("sgml"): case("xml"): document.ConfigName = "XML";break; case("html"): document.ConfigName = "TEXT";break; case("plain"): default: document.ConfigName = "TEXT"; } } } }