//================= //File: putHeader.jsee //Author: Abhishek Tripathi (planetcall [at] yahoo [döt] com) //Date: 17/Feb/2005 19:54 Hrs //Info: Now this Header Script can put the file information from the Clipboard. Simply Copy/Cut the info from anywhere and use this macro //===== www.abhishekclub.co.nr //modify as required var author,email,www,defaultInfo; author="Abhishek Tripathi"; email="planetcall [at] yahoo [döt] com"; www="www.abhishekclub.co.nr"; defaultInfo=""; //edit it to put same info in every file xPos = document.selection.GetActivePointX( eePosView ); yPos = document.selection.GetActivePointY( eePosLogical ); var pattern="^.*=+\n.*File"; var nFound = document.selection.Find( pattern, eeFindReplaceRegExp + eeFindAround ); status="Header Script for EmEditor V"+editor.Version+" by Abhishek"; var header=""; if (nFound==0){ document.selection.SetBookmark(); document.selection.StartOfDocument(false); //document.writeln(""); //document.selection.StartOfDocument(false); header="=================\n"; var FN=(document.Name=="")?"Untitled*":document.Name; header+="File: "+FN+"\n"; header+="Author: "+author+" ("+email+")\n"; header+="Date: "+getDateTime()+"\n"; header+="Info: "; //Note: Using Clipboard can be problematic if you have some other text on it. So clear clipboard if you dont want to insert copied text. header+=document.selection; header+="\n===== "+www+"\n"; document.write(header); document.selection.StartOfDocument(true); document.selection.Indent( -1 ); editor.ExecuteCommandByID(4371); document.selection.NextBookmark(); document.selection.ClearBookmark(); document.selection.SetActivePoint( eePosView, xPos,document.selection.GetActivePointY( eePosView ), false ); }else { document.selection.SetActivePoint( eePosLogical, xPos,yPos, false ); alert("Header already exists"); } function getDateTime() { var d = new Date(); var mm, mmm, dd, yy, yyyy, hour, min, sec; //formatting vars var arr_month=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); mm = d.getMonth() + 1; if(mm < 10) mm = "0" + mm; mmm=arr_month[mm-1] dd = d.getDate(); if (dd < 10) dd = "0" + dd; yyyy = d.getFullYear(); yy=yyyy - 2000 if (yy < 10) yy = "0" + yy; hour=d.getHours(); hour=(hour<10)?"0"+hour:hour; min=d.getMinutes(); min=(min<10)?"0"+min:min; sec=d.getSeconds(); sec=(sec<10)?"0"+sec:sec; //format the string below to produce date as required var formatStr = dd+"/"+mmm+"/"+yyyy+" "+hour+":"+min+" Hrs"; return formatStr }