| 8 | },t.TableControl.prototype.CreateTableControl=function(){return t.CreateTableControl(this)},t.TableControl.prototype.PositionTableControlElements=function(){t.PositionTableControlElements(this)},t.TableControl.prototype.ComputeTableControlPositions=function(){t.ComputeTableControlPositions(this)},t.CreateTableControl=function(e){var o,i,n,r=t.AssignID,a=t.setStyles,s=t.Constants,l=e.editor.imageprefix,c=e.vertical?"v":"h",u=t.LocalizeString;return e.main=document.createElement("div"),o=e.main.style,o.height=(e.vertical?e.size:e.controlthickness)+"px",o.width=(e.vertical?e.controlthickness:e.size)+"px",o.zIndex=0,a(e.main,s.TCmainStyle),o.backgroundImage="url("+l+"main-"+c+".gif)",s.TCmainClass&&(e.main.className=s.TCmainClass),e.main.style.display="none",e.endcap=document.createElement("div"),o=e.endcap.style,o.height=e.controlthickness+"px",o.width=e.controlthickness+"px",o.zIndex=1,o.overflow="hidden",o.position="absolute",a(e.endcap,s.TCendcapStyle),o.backgroundImage="url("+l+"endcap-"+c+".gif)",s.TCendcapClass&&(e.endcap.className=s.TCendcapClass),r(e.editor,e.endcap,"endcap"+c),e.main.appendChild(e.endcap),e.paneslider=document.createElement("div"),o=e.paneslider.style,o.height=(e.vertical?e.sliderthickness:e.controlthickness)+"px",o.overflow="hidden",o.width=(e.vertical?e.controlthickness:e.sliderthickness)+"px",o.position="absolute",o[e.vertical?"top":"left"]="4px",o.zIndex=3,o.backgroundImage="url("+l+"paneslider-"+c+".gif)",s.TCpanesliderClass&&(e.paneslider.className=s.TCpanesliderClass),r(e.editor,e.paneslider,"paneslider"+c),e.paneslider.title=u(e.vertical?"Drag to lock pane horizontally":"Drag to lock pane vertically"),i={MouseDown:t.TCPSDragFunctionStart,MouseMove:t.TCPSDragFunctionMove,MouseUp:t.TCPSDragFunctionStop,Disabled:function(){return e.editor.busy}},i.control=e,1!=t._app&&t.DragRegister(e.paneslider,e.vertical,!e.vertical,i,e.editor.toplevel),e.main.appendChild(e.paneslider),e.lessbutton=document.createElement("div"),o=e.lessbutton.style,o.height=(e.vertical?e.buttonthickness:e.controlthickness)+"px",o.width=(e.vertical?e.controlthickness:e.buttonthickness)+"px",o.zIndex=2,o.overflow="hidden",o.position="absolute",a(e.lessbutton,s.TClessbuttonStyle),o.backgroundImage="url("+l+"less-"+c+"n.gif)",s.TClessbuttonClass&&(e.lessbutton.className=s.TClessbuttonClass),r(e.editor,e.lessbutton,"lessbutton"+c),n={repeatwait:s.TClessbuttonRepeatWait,repeatinterval:s.TClessbuttonRepeatInterval,normalstyle:"backgroundImage:url("+l+"less-"+c+"n.gif);",downstyle:"backgroundImage:url("+l+"less-"+c+"d.gif);",hoverstyle:"backgroundImage:url("+l+"less-"+c+"h.gif);"},i={MouseDown:function(){e.editor.busy||e.editor.ScrollRelative(e.vertical,-1)},Repeat:function(){e.editor.busy||e.editor.ScrollRelative(e.vertical,-1)},Disabled:function(){return e.editor.busy}},t.ButtonRegister(e.editor,e.lessbutton,n,i),e.main.appendChild(e.lessbutton),e.morebutton=document.createElement("div"),o=e.morebutton.style,o.height=(e.vertical?e.buttonthickness:e.controlthickness)+"px",o.width=(e.vertical?e.controlthickness:e.buttonthickness)+"px",o.zIndex=2,o.overflow="hidden",o.position="absolute",a(e.morebutton,s.TCmorebuttonStyle),o.backgroundImage="url("+l+"more-"+c+"n.gif)",s.TCmorebuttonClass&&(e.morebutton.className=s.TCmorebuttonClass),r(e.editor,e.morebutton,"morebutton"+c),n={repeatwait:s.TCmorebuttonRepeatWait,repeatinterval:s.TCmorebuttonRepeatInterval,normalstyle:"backgroundImage:url("+l+"more-"+c+"n.gif);",downstyle:"backgroundImage:url("+l+"more-"+c+"d.gif);",hoverstyle:"backgroundImage:url("+l+"more-"+c+"h.gif);"},i={MouseDown:function(){e.editor.busy||e.editor.ScrollRelative(e.vertical,1)},Repeat:function(){e.editor.busy||e.editor.ScrollRelative(e.vertical,1)},Disabled:function(){return e.editor.busy}},t.ButtonRegister(e.editor,e.morebutton,n,i),e.main.appendChild(e.morebutton),e.scrollarea=document.createElement("div"),o=e.scrollarea.style,o.height=e.controlthickness+"px",o.width=e.controlthickness+"px",o.zIndex=1,o.overflow="hidden",o.position="absolute",a(e.scrollarea,s.TCscrollareaStyle),o.backgroundImage="url("+l+"scrollarea-"+c+".gif)",s.TCscrollareaClass&&(e.scrollarea.className=s.TCscrollareaClass),r(e.editor,e.scrollarea,"scrollarea"+c),n={repeatwait:s.TCscrollareaRepeatWait,repeatinterval:s.TCscrollareaRepeatWait},i={MouseDown:t.ScrollAreaClick,Repeat:t.ScrollAreaClick,Disabled:function(){return e.editor.busy}},i.control=e,t.ButtonRegister(e.editor,e.scrollarea,n,i),e.main.appendChild(e.scrollarea),e.thumb=document.createElement("div"),o=e.thumb.style,o.height=(e.vertical?e.thumbthickness:e.controlthickness)+"px",o.width=(e.vertical?e.controlthickness:e.thumbthickness)+"px",o.zIndex=2,o.overflow="hidden",o.position="absolute",a(e.thumb,s.TCthumbStyle),e.thumb.style.backgroundImage="url("+l+"thumb-"+c+"n.gif)",s.TCthumbClass&&(e.thumb.className=s.TCthumbClass),r(e.editor,e.thumb,"thumb"+c),i={MouseDown:t.TCTDragFunctionStart,MouseMove:t.TCTDragFunctionMove,MouseUp:t.TCTDragFunctionStop,Disabled:function(){return e.editor.busy}},i.control=e,1!=t._app&&t.DragRegister(e.thumb,e.vertical,!e.vertical,i,e.editor.toplevel),n={normalstyle:"backgroundImage:url("+l+"thumb-"+c+"n.gif)",name:"Thumb",downstyle:"backgroundImage:url("+l+"thumb-"+c+"d.gif)",hoverstyle:"backgroundImage:url("+l+"thumb-"+c+"h.gif)"},t.ButtonRegister(e.editor,e.thumb,n,null),e.main.appendChild(e.thumb),e.main},t.ScrollAreaClick=function(e,o,i){var n=i.functionobj.control,r=t.GetElementPositionWithScroll(n.editor.toplevel),a=n.vertical?o.clientY-r.top:o.clientX-r.left;n.editor.busy||n.editor.PageRelative(n.vertical,a>n.thumbpos?1:-1)},t.PositionTableControlElements=function(e){var t,o,i,n=e.editor;e.vertical?(t=e.controlborder+"px",e.endcap.style.top=e.endcapstart+"px",e.endcap.style.left=t,e.paneslider.style.top=e.panesliderstart+"px",e.paneslider.style.left=t,e.lessbutton.style.top=e.lessbuttonstart+"px",e.lessbutton.style.left=t,e.morebutton.style.top=e.morebuttonstart+"px",e.morebutton.style.left=t,e.scrollarea.style.top=e.scrollareastart+"px",e.scrollarea.style.left=t,e.scrollarea.style.height=e.scrollareasize+"px",o=Math.max(n.context.sheetobj.attribs.lastrow,n.firstscrollingrow+1),i=(n.firstscrollingrow-(n.lastnonscrollingrow+1))*(e.scrollareasize-3*e.thumbthickness)/(o-(n.lastnonscrollingrow+1))+e.scrollareastart-1,i=Math.floor(i),e.thumb.style.top=i+"px",e.thumb.style.left=t):(t=e.controlborder+"px",e.endcap.style.left=e.endcapstart+"px",e.endcap.style.top=t,e.paneslider.style.left=e.panesliderstart+"px",e.paneslider.style.top=t,e.lessbutton.style.left=e.lessbuttonstart+"px",e.lessbutton.style.top=t,e.morebutton.style.left=e.morebuttonstart+"px",e.morebutton.style.top=t,e.scrollarea.style.left=e.scrollareastart+"px",e.scrollarea.style.top=t,e.scrollarea.style.width=e.scrollareasize+"px",o=Math.max(n.context.sheetobj.attribs.lastcol,n.firstscrollingcol+1),i=(n.firstscrollingcol-(n.lastnonscrollingcol+1))*(e.scrollareasize-e.thumbthickness)/(o-n.lastnonscrollingcol)+e.scrollareastart-1,i=Math.floor(i),e.thumb.style.left=i+"px",e.thumb.style.top=t),e.thumbpos=i,e.main.style.display="block"},t.ComputeTableControlPositions=function(e){var t=e.editor;if(!t.gridposition||!t.headposition)throw"Can't compute table control positions before editor positions";e.vertical?(e.controlborder=t.gridposition.left+t.tablewidth,e.endcapstart=t.gridposition.top,e.panesliderstart=t.firstscrollingrowtop-e.sliderthickness,e.lessbuttonstart=t.firstscrollingrowtop-1,e.morebuttonstart=t.gridposition.top+t.tableheight-e.buttonthickness,e.scrollareastart=t.firstscrollingrowtop-1+e.buttonthickness,e.scrollareaend=e.morebuttonstart-1,e.scrollareasize=e.scrollareaend-e.scrollareastart+1):(e.controlborder=t.gridposition.top+t.tableheight,e.endcapstart=t.gridposition.left,e.panesliderstart=t.firstscrollingcolleft-e.sliderthickness,e.lessbuttonstart=t.firstscrollingcolleft-1,e.morebuttonstart=t.gridposition.left+t.tablewidth-e.buttonthickness,e.scrollareastart=t.firstscrollingcolleft-1+e.buttonthickness,e.scrollareaend=e.morebuttonstart-1,e.scrollareasize=e.scrollareaend-e.scrollareastart+1)},t.TCPSDragFunctionStart=function(e,o,i){var n=i.functionobj.control.editor,r=t.Constants;t.DragFunctionStart(e,o,i),o.trackingline=document.createElement("div"),o.trackingline.style.height=i.vertical?r.TCPStrackinglineThickness:n.tableheight-(n.headposition.top-n.gridposition.top)+"px",o.trackingline.style.width=i.vertical?n.tablewidth-(n.headposition.left-n.gridposition.left)+"px":r.TCPStrackinglineThickness,o.trackingline.style.backgroundImage="url("+n.imageprefix+"trackingline-"+(i.vertical?"v":"h")+".gif)",r.TCPStrackinglineClass&&(o.trackingline.className=r.TCPStrackinglineClass),t.setStyles(o.trackingline,r.TCPStrackinglineStyle),i.vertical?(row=t.Lookup(o.clientY+i.functionobj.control.sliderthickness,n.rowpositions),o.trackingline.style.top=(n.rowpositions[row]||n.headposition.top)+"px",o.trackingline.style.left=n.headposition.left+"px",o.trackingline.id="trackingline-vertical",n.context.rowpanes.length-1&&(n.context.SetRowPaneFirstLast(1,n.context.rowpanes[0].last+1,n.context.rowpanes[0].last+1),n.FitToEditTable(),n.ScheduleRender())):(col=t.Lookup(o.clientX+i.functionobj.control.sliderthickness,n.colpositions),o.trackingline.style.top=n.headposition.top+"px",o.trackingline.style.left=(n.colpositions[col]||n.headposition.left)+"px",o.trackingline.id="trackingline-horizon",n.context.colpanes.length-1&&(n.context.SetColPaneFirstLast(1,n.context.colpanes[0].last+1,n.context.colpanes[0].last+1),n.FitToEditTable(),n.ScheduleRender())),n.griddiv.appendChild(o.trackingline)},t.TCPSDragFunctionMove=function(e,o,i){var n,r,a,s,l=i.functionobj.control,c=l.sliderthickness,u=l.editor;if(i.vertical){for(a=l.morebuttonstart-l.minscrollingpanesize-o.offsetY,o.clientY>a&&(o.clientY=a),s=u.headposition.top-c-o.offsetY,o.clientY<s&&(o.clientY=s),n=t.Lookup(o.clientY+c,u.rowpositions);"yes"==u.context.sheetobj.rowattribs.hide[n];)n++;o.trackingline.style.top=(u.rowpositions[n]||u.headposition.top)+"px"}else{for(a=l.morebuttonstart-l.minscrollingpanesize-o.offsetX,o.clientX>a&&(o.clientX=a),s=u.headposition.left-c-o.offsetX,o.clientX<s&&(o.clientX=s),r=t.Lookup(o.clientX+c,u.colpositions);"yes"==u.context.sheetobj.colattribs.hide[t.rcColname(r)];)r++;o.trackingline.style.left=(u.colpositions[r]||u.headposition.left)+"px"}t.DragFunctionPosition(e,o,i)},t.TCPSDragFunctionStop=function(e,o,i){var n,r,a,s,l=i.functionobj.control,c=l.sliderthickness,u=l.editor;if(i.vertical){for(a=l.morebuttonstart-l.minscrollingpanesize-o.offsetY,o.clientY>a&&(o.clientY=a),s=u.headposition.top-c-o.offsetY,o.clientY<s&&(o.clientY=s),n=t.Lookup(o.clientY+c,u.rowpositions),n>u.context.sheetobj.attribs.lastrow&&(n=u.context.sheetobj.attribs.lastrow);"yes"==u.context.sheetobj.rowattribs.hide[n];)n++;u.EditorScheduleSheetCommands("pane row "+n,!0,!1)}else{for(a=l.morebuttonstart-l.minscrollingpanesize-o.offsetX,o.clientX>a&&(o.clientX=a),s=u.headposition.left-c-o.offsetX,o.clientX<s&&(o.clientX=s),r=t.Lookup(o.clientX+c,u.colpositions),r>u.context.sheetobj.attribs.lastcol&&(r=u.context.sheetobj.attribs.lastcol);"yes"==u.context.sheetobj.colattribs.hide[t.rcColname(r)];)r++;u.EditorScheduleSheetCommands("pane col "+r,!0,!1)}},t.TCTDragFunctionStart=function(e,o,i){var n=i.functionobj.control,r=n.editor,a=t.Constants;if(t.DragFunctionStart(e,o,i),o.thumbstatus&&(o.thumbstatus.rowmsgele&&(o.thumbstatus.rowmsgele=null),o.thumbstatus.rowpreviewele&&(o.thumbstatus.rowpreviewele=null),r.toplevel.removeChild(o.thumbstatus),o.thumbstatus=null),o.thumbstatus=document.createElement("div"),i.vertical){a.TCTDFSthumbstatusvClass&&(o.thumbstatus.className=a.TCTDFSthumbstatusvClass),t.setStyles(o.thumbstatus,a.TCTDFSthumbstatusvStyle),o.thumbstatus.style.top=o.clientY+a.TCTDFStopOffsetv+"px",o.thumbstatus.style.left=n.controlborder-10-r.tablewidth/2+"px",o.thumbstatus.style.width=r.tablewidth/2+"px",o.thumbcontext=new t.RenderContext(r.context.sheetobj),o.thumbcontext.showGrid=!0,o.thumbcontext.rowpanes=[{first:1,last:1}];var s=r.context.colpanes[r.context.colpanes.length-1];o.thumbcontext.colpanes=[{first:s.first,last:s.last}],o.thumbstatus.innerHTML='<table cellspacing="0" cellpadding="0"><tr><td valign="top" style="'+a.TCTDFSthumbstatusrownumStyle+'" class="'+a.TCTDFSthumbstatusrownumClass+'"><div>msg</div></td><td valign="top"><div style="overflow:hidden;">preview</div></td></tr></table>',o.thumbstatus.rowmsgele=o.thumbstatus.firstChild.firstChild.firstChild.firstChild.firstChild,o.thumbstatus.rowpreviewele=o.thumbstatus.firstChild.firstChild.firstChild.childNodes[1].firstChild,r.toplevel.appendChild(o.thumbstatus),t.TCTDragFunctionRowSetStatus(o,r,r.firstscrollingrow||1)}else a.TCTDFSthumbstatushClass&&(o.thumbstatus.className=a.TCTDFSthumbstatushClass),t.setStyles(o.thumbstatus,a.TCTDFSthumbstatushStyle),o.thumbstatus.style.top=n.controlborder+a.TCTDFStopOffseth+"px",o.thumbstatus.style.left=o.clientX+a.TCTDFSleftOffseth+"px",r.toplevel.appendChild(o.thumbstatus),o.thumbstatus.innerHTML=a.s_TCTDFthumbstatusPrefixh+t.rcColname(r.firstscrollingcol)},t.TCTDragFunctionRowSetStatus=function(e,o,i){var n=t.Constants,r=n.s_TCTDFthumbstatusPrefixv+i+" ";e.thumbstatus.rowmsgele.innerHTML=r,e.thumbcontext.rowpanes=[{first:i,last:i}],e.thumbrowshown=i;e.thumbcontext.RenderSheet(e.thumbstatus.rowpreviewele.firstChild,{type:"html"})},t.TCTDragFunctionMove=function(e,o,i){var n,r,a=i.functionobj.control,s=(a.thumbthickness,a.editor),l=t.Constants;i.vertical?(o.clientY>a.scrollareaend-o.offsetY-a.thumbthickness+2&&(o.clientY=a.scrollareaend-o.offsetY-a.thumbthickness+2),o.clientY<a.scrollareastart-o.offsetY-1&&(o.clientY=a.scrollareastart-o.offsetY-1),o.thumbstatus.style.top=o.clientY+"px",n=(o.clientY+o.offsetY-a.scrollareastart+1)/(a.scrollareasize-a.thumbthickness)*(s.context.sheetobj.attribs.lastrow-s.lastnonscrollingrow)+s.lastnonscrollingrow+1,n=Math.floor(n),n<=s.lastnonscrollingrow&&(n=s.lastnonscrollingrow+1),n>s.context.sheetobj.attribs.lastrow&&(n=s.context.sheetobj.attribs.lastrow),n!=o.thumbrowshown&&t.TCTDragFunctionRowSetStatus(o,s,n)):(o.clientX>a.scrollareaend-o.offsetX-a.thumbthickness+2&&(o.clientX=a.scrollareaend-o.offsetX-a.thumbthickness+2),o.clientX<a.scrollareastart-o.offsetX-1&&(o.clientX=a.scrollareastart-o.offsetX-1),o.thumbstatus.style.left=o.clientX+"px",n=(o.clientX+o.offsetX-a.scrollareastart+1)/(a.scrollareasize-a.thumbthickness)*(s.context.sheetobj.attribs.lastcol-s.lastnonscrollingcol)+s.lastnonscrollingcol+1,n=Math.floor(n),n<=s.lastnonscrollingcol&&(n=s.lastnonscrollingcol+1),n>s.context.sheetobj.attribs.lastcol&&(n=s.context.sheetobj.attribs.lastcol),r=l.s_TCTDFthumbstatusPrefixh+t.rcColname(n),o.thumbstatus.innerHTML=r),t.DragFunctionPosition(e,o,i)},t.TCTDragFunctionStop=function(e,t,o){var i,n=o.functionobj.control,r=n.editor;o.vertical?(i=(t.clientY+t.offsetY-n.scrollareastart+1)/(n.scrollareasize-n.thumbthickness)*(r.context.sheetobj.attribs.lastrow-r.lastnonscrollingrow)+r.lastnonscrollingrow+1,i=Math.floor(i),i<=r.lastnonscrollingrow&&(i=r.lastnonscrollingrow+1),i>r.context.sheetobj.attribs.lastrow&&(i=r.context.sheetobj.attribs.lastrow),r.context.SetRowPaneFirstLast(r.context.rowpanes.length-1,i,i+1)):(i=(t.clientX+t.offsetX-n.scrollareastart+1)/(n.scrollareasize-n.thumbthickness)*(r.context.sheetobj.attribs.lastcol-r.lastnonscrollingcol)+r.lastnonscrollingcol+1,i=Math.floor(i),i<=r.lastnonscrollingcol&&(i=r.lastnonscrollingcol+1),i>r.context.sheetobj.attribs.lastcol&&(i=r.context.sheetobj.attribs.lastcol),r.context.SetColPaneFirstLast(r.context.colpanes.length-1,i,i+1)),r.FitToEditTable(),t.thumbstatus.rowmsgele&&(t.thumbstatus.rowmsgele=null),t.thumbstatus.rowpreviewele&&(t.thumbstatus.rowpreviewele=null),r.toplevel.removeChild(t.thumbstatus),t.thumbstatus=null,r.ScheduleRender()},t.DragInfo={registeredElements:[],draggingElement:null,startX:0,startY:0,startZ:0,clientX:0,clientY:0,offsetX:0,offsetY:0,relativeOffset:{left:0,top:0}},t.DragRegister=function(e,o,i,n,r){var a=t.DragInfo;if(n||(n={MouseDown:t.DragFunctionStart,MouseMove:t.DragFunctionPosition,MouseUp:t.DragFunctionPosition,Disabled:null}),a.registeredElements.push({element:e,vertical:o,horizontal:i,functionobj:n,parent:r}),e.addEventListener)e.addEventListener("mousedown",t.DragMouseDown,!1);else{if(!e.attachEvent)throw t.Constants.s_BrowserNotSupported;e.attachEvent("onmousedown",t.DragMouseDown)}},t.DragUnregister=function(e){var o,i=t.DragInfo;if(e)for(o=0;o<i.registeredElements.length;o++)if(i.registeredElements[o].element==e)return i.registeredElements.splice(o,1),void(e.removeEventListener?e.removeEventListener("mousedown",t.DragMouseDown,!1):e.detachEvent("onmousedown",t.DragMouseDown))},t.DragMouseDown=function(o){var i=o||e.event,n=t.DragInfo,r=t.LookupElement(i.target||i.srcElement,n.registeredElements);return!r||r&&r.functionobj&&r.functionobj.Disabled&&r.functionobj.Disabled(i,n,r)?void 0:(n.draggingElement=r,r.parent&&(n.relativeOffset=t.GetElementPositionWithScroll(r.parent)),n.clientX=i.clientX-n.relativeOffset.left,n.clientY=i.clientY-n.relativeOffset.top,n.startX=n.clientX,n.startY=n.clientY,n.startZ=r.element.style.zIndex,n.offsetX=0,n.offsetY=0,r.element.style.zIndex="100",t.SetMouseMoveUp(t.DragMouseMove,t.DragMouseUp,r.element,i),r&&r.functionobj&&r.functionobj.MouseDown&&r.functionobj.MouseDown(i,n,r),!1)},t.DragMouseMove=function(o){var i=o||e.event,n=t.DragInfo,r=n.draggingElement;return n.clientX=i.clientX-n.relativeOffset.left,n.clientY=i.clientY-n.relativeOffset.top,t.StopPropagation(i),r&&r.functionobj&&r.functionobj.MouseMove&&r.functionobj.MouseMove(i,n,r),!1},t.DragMouseUp=function(o){var i=o||e.event,n=t.DragInfo,r=n.draggingElement;return n.clientX=i.clientX-n.relativeOffset.left,n.clientY=i.clientY-n.relativeOffset.top,r.element.style.zIndex=n.startZ,r&&r.functionobj&&r.functionobj.MouseUp&&r.functionobj.MouseUp(i,n,r),t.RemoveMouseMoveUp(t.DragMouseMove,t.DragMouseUp,r.element,i),n.draggingElement=null,!1},t.DragFunctionStart=function(e,t,o){var i=o.functionobj.positionobj||o.element;t.offsetY=parseInt(i.style.top)-t.clientY,t.offsetX=parseInt(i.style.left)-t.clientX},t.DragFunctionPosition=function(e,t,o){var i=o.functionobj.positionobj||o.element;o.vertical&&(i.style.top=t.clientY+t.offsetY+"px"),o.horizontal&&(i.style.left=t.clientX+t.offsetX+"px")},t.ButtonInfo={registeredElements:[],buttonElement:null,doingHover:!1,buttonDown:!1,timer:null,relativeOffset:null,clientX:0,clientY:0},t.ButtonRegister=function(e,o,i,n){var r=t.ButtonInfo;if(i||(i={}),r.registeredElements.push({name:i.name,element:o,editor:e,normalstyle:i.normalstyle,hoverstyle:i.hoverstyle,downstyle:i.downstyle,repeatwait:i.repeatwait,repeatinterval:i.repeatinterval,functionobj:n}),o.addEventListener)o.addEventListener("mousedown",t.ButtonMouseDown,!1),o.addEventListener("mouseover",t.ButtonMouseOver,!1),o.addEventListener("mouseout",t.ButtonMouseOut,!1);else{if(!o.attachEvent)throw t.Constants.s_BrowserNotSupported;o.attachEvent("onmousedown",t.ButtonMouseDown),o.attachEvent("onmouseover",t.ButtonMouseOver),o.attachEvent("onmouseout",t.ButtonMouseOut)}},t.ButtonMouseOver=function(o){var i=o||e.event,n=t.ButtonInfo,r=t.LookupElement(i.target||i.srcElement,n.registeredElements);if(r){if(n.buttonDown)return void(n.buttonElement==r&&(n.doingHover=!0));n.buttonElement&&n.buttonElement!=r&&n.doingHover&&t.setStyles(n.buttonElement.element,n.buttonElement.normalstyle),n.buttonElement=r,n.doingHover=!0,t.setStyles(r.element,r.hoverstyle),r&&r.functionobj&&r.functionobj.MouseOver&&r.functionobj.MouseOver(i,n,r)}},t.ButtonMouseOut=function(o){var i=o||e.event,n=t.ButtonInfo;if(n.buttonDown)return void(n.doingHover=!1);var r=t.LookupElement(i.target||i.srcElement,n.registeredElements);n.doingHover&&(n.buttonElement&&t.setStyles(n.buttonElement.element,n.buttonElement.normalstyle),n.buttonElement=null,n.doingHover=!1),r&&r.functionobj&&r.functionobj.MouseOut&&r.functionobj.MouseOut(i,n,r)},t.ButtonMouseDown=function(o){var i=o||e.event,n=t.ButtonInfo,r=(t.GetViewportInfo(),t.LookupElement(i.target||i.srcElement,n.registeredElements));r&&(r&&r.functionobj&&r.functionobj.Disabled&&r.functionobj.Disabled(i,n,r)||(n.buttonElement=r,n.buttonDown=!0,t.setStyles(r.element,n.buttonElement.downstyle),document.addEventListener?document.addEventListener("mouseup",t.ButtonMouseUp,!0):r.element.attachEvent&&(r.element.setCapture(),r.element.attachEvent("onmouseup",t.ButtonMouseUp),r.element.attachEvent("onlosecapture",t.ButtonMouseUp)),t.StopPropagation(i),n.relativeOffset=t.GetElementPositionWithScroll(r.editor.toplevel),n.clientX=i.clientX-n.relativeOffset.left,n.clientY=i.clientY-n.relativeOffset.top,r&&r.functionobj&&r.functionobj.MouseDown&&r.functionobj.MouseDown(i,n,r),r.repeatwait&&(n.timer=e.setTimeout(t.ButtonRepeat,r.repeatwait))))},t.ButtonMouseUp=function(o){var i=o||e.event,n=t.ButtonInfo,r=n.buttonElement;n.timer&&(e.clearTimeout(n.timer),n.timer=null),n.buttonDown&&(t.StopPropagation(i),document.removeEventListener?document.removeEventListener("mouseup",t.ButtonMouseUp,!0):document.detachEvent&&(r.element.detachEvent("onlosecapture",t.ButtonMouseUp),r.element.detachEvent("onmouseup",t.ButtonMouseUp),r.element.releaseCapture()),n.buttonElement.downstyle&&(n.doingHover?t.setStyles(r.element,n.buttonElement.hoverstyle):t.setStyles(r.element,n.buttonElement.normalstyle)),n.buttonDown=!1,r&&r.functionobj&&r.functionobj.MouseUp&&r.functionobj.MouseUp(i,n,r))},t.ButtonRepeat=function(){var o=t.ButtonInfo,i=o.buttonElement;i&&(i&&i.functionobj&&i.functionobj.Repeat&&i.functionobj.Repeat(null,o,i),o.timer=e.setTimeout(t.ButtonRepeat,i.repeatinterval||100))},t.MouseWheelInfo={registeredElements:[]},t.MouseWheelRegister=function(e,o){var i=t.MouseWheelInfo;if(i.registeredElements.push({element:e,functionobj:o}),e.addEventListener)e.addEventListener("DOMMouseScroll",t.ProcessMouseWheel,!1),e.addEventListener("mousewheel",t.ProcessMouseWheel,!1);else{if(!e.attachEvent)throw t.Constants.s_BrowserNotSupported;e.attachEvent("onmousewheel",t.ProcessMouseWheel)}},t.ProcessMouseWheel=function(o){var i,n=o||e.event;if(!t.Keyboard.passThru){var r,a=t.MouseWheelInfo,s=n.target||n.srcElement;for(r=null;!r&&s;s=s.parentNode)r=t.LookupElement(s,a.registeredElements);r&&(i=n.wheelDelta?n.wheelDelta/120:-n.detail/3,i||(i=0),r.functionobj&&r.functionobj.WheelMove&&r.functionobj.WheelMove(n,i,a,r),n.preventDefault&&n.preventDefault(),n.returnValue=!1)}},t.keyboardTables={specialKeysCommon:{8:"[backspace]",9:"[tab]",13:"[enter]",25:"[tab]",27:"[esc]",33:"[pgup]",34:"[pgdn]",35:"[end]",36:"[home]",37:"[aleft]",38:"[aup]",39:"[aright]",40:"[adown]",45:"[ins]",46:"[del]",113:"[f2]"},specialKeysIE:{8:"[backspace]",9:"[tab]",13:"[enter]",25:"[tab]",27:"[esc]",33:"[pgup]",34:"[pgdn]",35:"[end]",36:"[home]",37:"[aleft]",38:"[aup]",39:"[aright]",40:"[adown]",45:"[ins]",46:"[del]",113:"[f2]"},controlKeysIE:{65:"[ctrl-a]",67:"[ctrl-c]",83:"[ctrl-s]",86:"[ctrl-v]",88:"[ctrl-x]",90:"[ctrl-z]"},specialKeysOpera:{8:"[backspace]",9:"[tab]",13:"[enter]",25:"[tab]",27:"[esc]",33:"[pgup]",34:"[pgdn]",35:"[end]",36:"[home]",37:"[aleft]",38:"[aup]",39:"[aright]",40:"[adown]",45:"[ins]",46:"[del]",113:"[f2]"},controlKeysOpera:{65:"[ctrl-a]",67:"[ctrl-c]",83:"[ctrl-s]",86:"[ctrl-v]",88:"[ctrl-x]",90:"[ctrl-z]"},specialKeysSafari:{8:"[backspace]",9:"[tab]",13:"[enter]",25:"[tab]",27:"[esc]",63232:"[aup]",63233:"[adown]",63234:"[aleft]",63235:"[aright]",63272:"[del]",63273:"[home]",63275:"[end]",63276:"[pgup]",63277:"[pgdn]",63237:"[f2]"},controlKeysSafari:{97:"[ctrl-a]",99:"[ctrl-c]",115:"[ctrl-s]",118:"[ctrl-v]",120:"[ctrl-x]",122:"[ctrl-z]"},ignoreKeysSafari:{63236:"[f1]",63238:"[f3]",63239:"[f4]",63240:"[f5]",63241:"[f6]",63242:"[f7]",63243:"[f8]",63244:"[f9]",63245:"[f10]",63246:"[f11]",63247:"[f12]",63289:"[numlock]"},specialKeysFirefox:{8:"[backspace]",9:"[tab]",13:"[enter]",25:"[tab]",27:"[esc]",33:"[pgup]",34:"[pgdn]",35:"[end]",36:"[home]",37:"[aleft]",38:"[aup]",39:"[aright]",40:"[adown]",45:"[ins]",46:"[del]",113:"[f2]"},controlKeysFirefox:{97:"[ctrl-a]",99:"[ctrl-c]",115:"[ctrl-s]",118:"[ctrl-v]",120:"[ctrl-x]",122:"[ctrl-z]"},ignoreKeysFirefox:{16:"[shift]",17:"[ctrl]",18:"[alt]",20:"[capslock]",19:"[pause]",44:"[printscreen]",91:"[windows]",92:"[windows]",112:"[f1]",114:"[f3]",115:"[f4]",116:"[f5]",117:"[f6]",118:"[f7]",119:"[f8]",120:"[f9]",121:"[f10]",122:"[f11]",123:"[f12]",144:"[numlock]",145:"[scrolllock]",224:"[cmd]"}},t.Keyboard={areListener:!1,focusTable:null,passThru:null,didProcessKey:!1,statusFromProcessKey:!1,repeatingKeyPress:!1,chForProcessKey:""},t.KeyboardSetFocus=function(o){t.Keyboard.focusTable=o,t.Keyboard.areListener||(document.onkeydown=t.ProcessKeyDown,document.onkeypress=t.ProcessKeyPress,t.Keyboard.areListener=!0),t.Keyboard.passThru&&(t.Keyboard.passThru.blur&&t.Keyboard.passThru.blur(),t.Keyboard.passThru=null),e.focus()},t.KeyboardFocus=function(){t.Keyboard.passThru=null,e.focus()},t.ProcessKeyDown=function(o){var i=t.keyboardTables;i.didProcessKey=!1,i.statusFromProcessKey=!1,i.repeatingKeyPress=!1;var n="",r=!0;if(!t._app&&!t.Keyboard.passThru){if(o=o||e.event,void 0==o.which){if(n=i.specialKeysCommon[o.keyCode],!n&&(o.ctrlKey&&(n=i.controlKeysIE[o.keyCode]),!n))return!0;r=t.ProcessKey(n,o),r||(o.preventDefault&&o.preventDefault(),o.returnValue=!1)}else{if(n=i.specialKeysCommon[o.keyCode],!n&&((o.ctrlKey||o.metaKey)&&(n=i.controlKeysIE[o.keyCode]),!n))return!0;r=t.ProcessKey(n,o),i.didProcessKey=!0,i.statusFromProcessKey=r,i.chForProcessKey=n}return r}},t.ProcessKeyPress=function(o){var i=t.keyboardTables,n="";if(o=o||e.event,!t._app&&!t.Keyboard.passThru){if(i.didProcessKey)return i.repeatingKeyPress?t.ProcessKey(i.chForProcessKey,o):(i.repeatingKeyPress=!0,i.statusFromProcessKey);if(void 0==o.which)n=String.fromCharCode(o.keyCode);else{if(!o.which)return!1;if(void 0==o.charCode){if(0==o.which)return!0;if(o.which<32||144==o.which){if(n=i.specialKeysOpera[o.which])return!0}else n=o.ctrlKey?i.controlKeysOpera[o.keyCode]:String.fromCharCode(o.which)}else{if(0==o.keyCode&&0==o.charCode)return;if(o.keyCode==o.charCode){if(n=i.specialKeysSafari[o.keyCode],!n){if(i.ignoreKeysSafari[o.keyCode])return!0;n=o.metaKey?i.controlKeysSafari[o.keyCode]:String.fromCharCode(o.which)}}else{if(i.specialKeysFirefox[o.keyCode])return!0;n=String.fromCharCode(o.which),(o.ctrlKey||o.metaKey)&&(n=i.controlKeysFirefox[o.which])}}}var r=t.ProcessKey(n,o);return r||(o.preventDefault&&o.preventDefault(),o.returnValue=!1),r}},t.ProcessKey=function(e,o){var i=t.Keyboard.focusTable;return i?i.EditorProcessKey(e,o):!0};var t;t||(t={}),t.FormatNumber={},t.FormatNumber.format_definitions={},t.FormatNumber.separatorchar=",",t.FormatNumber.decimalchar=".",t.FormatNumber.daynames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],t.FormatNumber.daynames3=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],t.FormatNumber.monthnames3=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],t.FormatNumber.monthnames=["January","February","March","April","May","June","July","August","September","October","November","December"],t.FormatNumber.allowedcolors={BLACK:"#000000",BLUE:"#0000FF",CYAN:"#00FFFF",GREEN:"#00FF00",MAGENTA:"#FF00FF",RED:"#FF0000",WHITE:"#FFFFFF",YELLOW:"#FFFF00"},t.FormatNumber.alloweddates={H:"h]",M:"m]",MM:"mm]",S:"s]",SS:"ss]"},t.FormatNumber.commands={copy:1,color:2,integer_placeholder:3,fraction_placeholder:4,decimal:5,currency:6,general:7,separator:8,date:9,comparison:10,section:11,style:12},t.FormatNumber.datevalues={julian_offset:2415019,seconds_in_a_day:86400,seconds_in_an_hour:3600},t.FormatNumber.formatNumberWithFormat=function(e,o,i){var n,r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C,w,x,_,S,k,T,F,E,D,P,A,I,M,R,N,L,O,z,H,B,U,j,V=t.Constants,W=t.FormatNumber,G="";if("string"==typeof e&&!e.length)return"";if(j=e-0,!isFinite(j))return"string"==typeof e?W.formatTextWithFormat(e,o):"NaN";e=j;var $=0>j?1:0;$&&(j=-j);var Y=0==j?1:0;if(i=i||V.FormatNumber_DefaultCurrency,W.parse_format_string(W.format_definitions,o),C=W.format_definitions[o],!C)throw"Format not parsed error!";if(w=C.sectioninfo.length-1,C.hascomparison)for(w=0,x=0,k=0;;k++){if(n=C.operators[k],r=C.operands[k],!n){x&&(o="General",W.parse_format_string(W.format_definitions,o),C=W.format_definitions[o],w=0);break}if(n!=W.commands.section){if(n==W.commands.comparison){if(E=r.indexOf(":"),_=r.substring(0,E),S=r.substring(E+1)-0,"<"==_&&S>e||"<="==_&&S>=e||"="==_&&e==S||"<>"==_&&e!=S||">="==_&&e>=S||">"==_&&e>S)break;x=1}}else{if(!x)break;x=0,w++}}else w>0&&(1==w?$?($=0,w=1):w=0:(2==w||3==w)&&($?($=0,w=1):w=Y?2:0));if(F=C.sectioninfo[w],F.commas>0)for(E=0;E<F.commas;E++)j/=1e3;if(F.percent>0)for(E=0;E<F.percent;E++)j*=100;for(D=1,E=0;E<F.fractiondigits;E++)D*=10;if(P=Math.floor(j*D+.5),P/=D,"number"!=typeof P)return"NaN";if(!isFinite(P))return"NaN";if(A=P+"",0==P&&(F.fractiondigits||F.integerdigits)&&($=0),A.indexOf("e")>=0)return e+"";if(I=A.match(/^\+{0,1}(\d*)(?:\.(\d*)){0,1}$/),!I)return"NaN";if(M=I[1],M&&"0"!=M||(M=""),R=I[2],R||(R=""),F.hasdate){if(0>e)return"??-???-?? ??:??:??";for(c=(e-Math.floor(e))*W.datevalues.seconds_in_a_day,u=e*W.datevalues.seconds_in_a_day,d=Math.floor(c/W.datevalues.seconds_in_an_hour),f=Math.floor(u/W.datevalues.seconds_in_an_hour),c-=d*W.datevalues.seconds_in_an_hour,h=Math.floor(c/60),m=Math.floor(u/60),p=c-60*h,D=1,E=0;E<F.fractiondigits;E++)D*=10;for(p=Math.floor(p*D+.5),p/=D,g=Math.floor(u*D+.5),g/=D,p>=60&&(p=0,h++,m++,h>=60&&(h=0,d++,f++,d>=24&&(d=0,e++))),R=p-Math.floor(p)+"",R=R.substring(2),b=t.FormatNumber.convert_date_julian_to_gregorian(Math.floor(e+W.datevalues.julian_offset)),y=0,mspos=F.sectionstart;(n=C.operators[mspos],r=C.operands[mspos],n)&&n!=W.commands.section;mspos++)n==W.commands.date?("am/pm"!=r.toLowerCase()&&"a/p"!=r.toLowerCase()||v||(d>=12?(d-=12,v="a/p"==r.toLowerCase()?V.s_FormatNumber_pm1:V.s_FormatNumber_pm):v="a/p"==r.toLowerCase()?V.s_FormatNumber_am1:V.s_FormatNumber_am,r.indexOf(v)<0&&(v=v.toLowerCase())),!y||"m"!=r&&"mm"!=r||(C.operands[mspos]+="in"),y="h"==r.charAt(0)?1:0):n!=W.commands.copy&&(y=0);for(y=0,--mspos;(n=C.operators[mspos],r=C.operands[mspos],n)&&n!=W.commands.section;mspos--)n==W.commands.date?(!y||"m"!=r&&"mm"!=r||(C.operands[mspos]+="in"),y="ss"==r?1:0):n!=W.commands.copy&&(y=0)}for(N=0,L=0,O=0,z="",H="",B=V.FormatNumber_separatorchar,B.indexOf(" ")>=0&&(B=B.replace(/ /g," ")),U=V.FormatNumber_decimalchar,U.indexOf(" ")>=0&&(U=U.replace(/ /g," ")),T=F.sectionstart;n=C.operators[T];)if(r=C.operands[T++],n==W.commands.copy)G+=r;else if(n==W.commands.color)z=r;else if(n==W.commands.style)H=r;else if(n==W.commands.integer_placeholder){if($&&(G+="-",$=0),N++,1==N&&M.length>F.integerdigits)for(;L<M.length-F.integerdigits;L++)G+=M.charAt(L),F.thousandssep&&(a=M.length-L-1,a>2&&a%3==0&&(G+=B));M.length<F.integerdigits&&N<=F.integerdigits-M.length?("0"==r||"?"==r)&&(G+="0"==r?"0":" ",F.thousandssep&&(a=F.integerdigits-N,a>2&&a%3==0&&(G+=B))):(G+=M.charAt(L),F.thousandssep&&(a=M.length-L-1,a>2&&a%3==0&&(G+=B)),L++)}else if(n==W.commands.fraction_placeholder)O>=R.length?("0"==r||"?"==r)&&(G+="0"==r?"0":" "):G+=R.charAt(O),O++;else if(n==W.commands.decimal)$&&(G+="-",$=0),G+=U;else if(n==W.commands.currency)$&&(G+="-",$=0),G+=r;else if(n==W.commands.general){if(0!=j){var K=Math.floor(Math.LOG10E*Math.log(j));if(K=Math.pow(10,13-K),j=Math.floor(K*j+.5)/K,!isFinite(j))return"NaN"}if($&&(G+="-"),A=j+"",A.indexOf("e")>=0){G+=A;continue}if(I=A.match(/^\+{0,1}(\d*)(?:\.(\d*)){0,1}$/),M=I[1],M&&"0"!=M||(M=""),R=I[2],R||(R=""),L=0,O=0,M.length)for(;L<M.length;L++)G+=M.charAt(L),F.thousandssep&&(a=M.length-L-1,a>2&&a%3==0&&(G+=B));else G+="0";if(R.length)for(G+=U;O<R.length;O++)G+=R.charAt(O)}else if(n==W.commands.date)l=r.toLowerCase(),"y"==l||"yy"==l?G+=(b.year+"").substring(2):"yyyy"==l?G+=b.year+"":"d"==l?G+=b.day+"":"dd"==l?(s=1e3+b.day,G+=(s+"").substr(2)):"ddd"==l?(s=Math.floor(e+6)%7,G+=V.s_FormatNumber_daynames3[s]):"dddd"==l?(s=Math.floor(e+6)%7,G+=V.s_FormatNumber_daynames[s]):"m"==l?G+=b.month+"":"mm"==l?(s=1e3+b.month,G+=(s+"").substr(2)):"mmm"==l?G+=V.s_FormatNumber_monthnames3[b.month-1]:"mmmm"==l?G+=V.s_FormatNumber_monthnames[b.month-1]:"mmmmm"==l?G+=V.s_FormatNumber_monthnames[b.month-1].charAt(0):"h"==l?G+=d+"":"h]"==l?G+=f+"":"mmin"==l?(s=1e3+h+"",G+=s.substr(2)):"mm]"==l?100>m?(s=1e3+m+"",G+=s.substr(2)):G+=m+"":"min"==l?G+=h+"":"m]"==l?G+=m+"":"hh"==l?(s=1e3+d+"",G+=s.substr(2)):"s"==l?(s=Math.floor(p),G+=s+""):"ss"==l?(s=1e3+Math.floor(p)+"",G+=s.substr(2)):"am/pm"==l||"a/p"==l?G+=v:"ss]"==l&&(100>g?(s=1e3+Math.floor(g)+"",G+=s.substr(2)):(s=Math.floor(g),G+=s+"")); |
| 9 | else{if(n==W.commands.section)break;if(n==W.commands.comparison)continue;G+="!! Parse error !!"}return z&&(G='<span style="color:'+z+';">'+G+"</span>"),H&&(G='<span style="'+H+';">'+G+"</span>"),G},t.FormatNumber.formatTextWithFormat=function(e,o){var i,n,r,a,s=(t.Constants,t.FormatNumber),l=e+"",c="",u="",d="";if(s.parse_format_string(s.format_definitions,o),thisformat=s.format_definitions[o],!thisformat)throw"Format not parsed error!";if(i=thisformat.sectioninfo.length-1,0==i)i=0;else{if(3!=i)return l;i=3}for(n=thisformat.sectioninfo[i],r=n.sectionstart;op=thisformat.operators[r];)a=thisformat.operands[r++],op==s.commands.copy?c+="@"==a?l:a.replace(/ /g," "):op==s.commands.color?u=a:op==s.commands.style&&(d=a);return u&&(c='<span style="color:'+u+';">'+c+"</span>"),d&&(c='<span style="'+d+';">'+c+"</span>"),c},t.FormatNumber.parse_format_string=function(e,o){var i,n,r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C=t.FormatNumber,w=1;if(!e[o]){for(i={operators:[],operands:[],sectioninfo:[{}]},e[o]=i,n=0,sectioninfo=i.sectioninfo[n],sectioninfo.sectionstart=0,sectioninfo.integerdigits=0,sectioninfo.fractiondigits=0,sectioninfo.commas=0,sectioninfo.percent=0,b=0;b<o.length;b++)if(y=o.charAt(b),c){if('"'==y){c=0,i.operators.push(C.commands.copy),i.operands.push(u);continue}u+=y}else if(d){if("]"==y){if(d=0,p=t.FormatNumber.parse_format_bracket(h),p.operator==C.commands.separator){sectioninfo.thousandssep=1;continue}p.operator==C.commands.date&&(sectioninfo.hasdate=1),p.operator==C.commands.comparison&&(i.hascomparison=1),i.operators.push(p.operator),i.operands.push(p.operand);continue}h+=y}else if(a)i.operators.push(C.commands.copy),i.operands.push(y),a=!1;else if(s)i.operators.push(C.commands.copy),i.operands.push(y+y+y+y+y),s=!1;else if(l)i.operators.push(C.commands.copy),i.operands.push(" "),l=!1;else{if(f){if("general".charAt(f)==y.toLowerCase()){f++,7==f&&(i.operators.push(C.commands.general),i.operands.push(y),f=0);continue}f=0}if(v){if(v.charAt(0)==y){v+=y;continue}i.operators.push(C.commands.date),i.operands.push(v),sectioninfo.hasdate=1,v=""}m?(m+=y,g=m.toLowerCase(),g!="am/pm".substring(0,g.length)&&g!="a/p".substring(0,g.length)?ampstr="":("am/pm"==g||"a/p"==g)&&(i.operators.push(C.commands.date),i.operands.push(m),m="")):"#"==y||"0"==y||"?"==y?w?(sectioninfo.integerdigits++,sectioninfo.commas&&(sectioninfo.thousandssep=1,sectioninfo.commas=0),r=1,i.operators.push(C.commands.integer_placeholder),i.operands.push(y)):(sectioninfo.fractiondigits++,r=1,i.operators.push(C.commands.fraction_placeholder),i.operands.push(y)):"."==y?(r=0,i.operators.push(C.commands.decimal),i.operands.push(y),w=0):"$"==y?(r=0,i.operators.push(C.commands.currency),i.operands.push(y)):","==y?r?sectioninfo.commas++:(i.operators.push(C.commands.copy),i.operands.push(y)):"%"==y?(r=0,sectioninfo.percent++,i.operators.push(C.commands.copy),i.operands.push(y)):'"'==y?(r=0,c=1,u=""):"["==y?(r=0,d=1,h=""):"\\"==y?(a=1,r=0):"*"==y?(s=1,r=0):"_"==y?(l=1,r=0):";"==y?(n++,i.sectioninfo[n]={},sectioninfo=i.sectioninfo[n],sectioninfo.sectionstart=1+i.operators.length,sectioninfo.integerdigits=0,sectioninfo.fractiondigits=0,sectioninfo.commas=0,sectioninfo.percent=0,w=1,r=0,i.operators.push(C.commands.section),i.operands.push(y)):"g"==y.toLowerCase()?(f=1,r=0):"a"==y.toLowerCase()?(m=y,r=0):"dmyhHs".indexOf(y)>=0?v=y:(r=0,i.operators.push(C.commands.copy),i.operands.push(y))}v&&(i.operators.push(C.commands.date),i.operands.push(v),sectioninfo.hasdate=1)}},t.FormatNumber.parse_format_bracket=function(e){var o,i=t.FormatNumber,n=t.Constants,r={};return"$"==e.charAt(0)?(r.operator=i.commands.currency,o=e.match(/^\$(.+?)(\-.+?){0,1}$/),r.operand=o?o[1]||n.FormatNumber_defaultCurrency||"$":e.substring(1)||n.FormatNumber_defaultCurrency||"$"):"?$"==e?(r.operator=i.commands.currency,r.operand="[?$]"):i.allowedcolors[e.toUpperCase()]?(r.operator=i.commands.color,r.operand=i.allowedcolors[e.toUpperCase()]):(o=e.match(/^style=([^"]*)$/))?(r.operator=i.commands.style,r.operand=o[1]):","==e?(r.operator=i.commands.separator,r.operand=e):i.alloweddates[e.toUpperCase()]?(r.operator=i.commands.date,r.operand=i.alloweddates[e.toUpperCase()]):(o=e.match(/^[<>=]/))?(o=e.match(/^([<>=]+)(.+)$/),r.operator=i.commands.comparison,r.operand=o[1]+":"+o[2]):(r.operator=i.commands.copy,r.operand="["+e+"]"),r},t.FormatNumber.convert_date_gregorian_to_julian=function(e,o,i){var n;return n=i-32075+t.intFunc(1461*(e+4800+t.intFunc((o-14)/12))/4),n+=t.intFunc(367*(o-2-12*t.intFunc((o-14)/12))/12),n-=t.intFunc(3*t.intFunc((e+4900+t.intFunc((o-14)/12))/100)/4)},t.FormatNumber.convert_date_julian_to_gregorian=function(e){var t,o,i,n,r;return t=e+68569,o=Math.floor(4*t/146097),t-=Math.floor((146097*o+3)/4),i=Math.floor(4e3*(t+1)/1461001),t=t-Math.floor(1461*i/4)+31,n=Math.floor(80*t/2447),r=t-Math.floor(2447*n/80),t=Math.floor(n/11),n=n+2-12*t,i=100*(o-49)+i+t,{year:i,month:n,day:r}},t.intFunc=function(e){return 0>e?-Math.floor(-e):Math.floor(e)};var t;t||(t={}),t.Formula={},t.TriggerIoAction={},t.Formula.ParseState={num:1,alpha:2,coord:3,string:4,stringquote:5,numexp1:6,numexp2:7,alphanumeric:8,specialvalue:9},t.Formula.TokenType={num:1,coord:2,op:3,name:4,error:5,string:6,space:7},t.Formula.CharClass={num:1,numstart:2,op:3,eof:4,alpha:5,incoord:6,error:7,quote:8,space:9,specialstart:10},t.Formula.CharClassTable={" ":9,"!":3,'"':8,"'":8,"#":10,$:6,"%":3,"&":3,"(":3,")":3,"*":3,"+":3,",":3,"-":3,".":2,"/":3,0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,":":3,"<":3,"=":3,">":3,A:5,B:5,C:5,D:5,E:5,F:5,G:5,H:5,I:5,J:5,K:5,L:5,M:5,N:5,O:5,P:5,Q:5,R:5,S:5,T:5,U:5,V:5,W:5,X:5,Y:5,Z:5,"^":3,_:5,a:5,b:5,c:5,d:5,e:5,f:5,g:5,h:5,i:5,j:5,k:5,l:5,m:5,n:5,o:5,p:5,q:5,r:5,s:5,t:5,u:5,v:5,w:5,x:5,y:5,z:5},t.Formula.UpperCaseTable={a:"A",b:"B",c:"C",d:"D",e:"E",f:"F",g:"G",h:"H",i:"I",j:"J",k:"K",l:"L",m:"M",n:"N",o:"O",p:"P",q:"Q",r:"R",s:"S",t:"T",u:"U",v:"V",w:"W",x:"X",y:"Y",z:"Z",A:"A",B:"B",C:"C",D:"D",E:"E",F:"F",G:"G",H:"H",I:"I",J:"J",K:"K",L:"L",M:"M",N:"N",O:"O",P:"P",Q:"Q",R:"R",S:"S",T:"T",U:"U",V:"V",W:"W",X:"X",Y:"Y",Z:"Z"},t.Formula.SpecialConstants={"#NULL!":"0,e#NULL!","#NUM!":"0,e#NUM!","#DIV/0!":"0,e#DIV/0!","#VALUE!":"0,e#VALUE!","#REF!":"0,e#REF!","#NAME?":"0,e#NAME?"},t.Formula.TokenPrecedence={"!":1,":":2,",":2,M:-3,P:-3,"%":4,"^":5,"*":6,"/":6,"+":7,"-":7,"&":8,"<":9,">":9,G:9,L:9,N:9},t.Formula.TokenOpExpansion={G:">=",L:"<=",M:"-",N:"<>",P:"+"},t.Formula.TypeLookupTable={unaryminus:{"n*":"|n*:1|","e*":"|e*:1|","t*":"|t*:e#VALUE!|",b:"|b:n|"},unaryplus:{"n*":"|n*:1|","e*":"|e*:1|","t*":"|t*:e#VALUE!|",b:"|b:n|"},unarypercent:{"n*":"|n:n%|n*:n|","e*":"|e*:1|","t*":"|t*:e#VALUE!|",b:"|b:n|"},plus:{"n%":"|n%:n%|nd:n|nt:n|ndt:n|n$:n|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|",nd:"|n%:n|nd:nd|nt:ndt|ndt:ndt|n$:n|n:nd|n*:n|b:n|e*:2|t*:e#VALUE!|",nt:"|n%:n|nd:ndt|nt:nt|ndt:ndt|n$:n|n:nt|n*:n|b:n|e*:2|t*:e#VALUE!|",ndt:"|n%:n|nd:ndt|nt:ndt|ndt:ndt|n$:n|n:ndt|n*:n|b:n|e*:2|t*:e#VALUE!|",n$:"|n%:n|nd:n|nt:n|ndt:n|n$:n$|n:n$|n*:n|b:n|e*:2|t*:e#VALUE!|",nl:"|n%:n|nd:n|nt:n|ndt:n|n$:n|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|",n:"|n%:n|nd:nd|nt:nt|ndt:ndt|n$:n$|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|",b:"|n%:n%|nd:nd|nt:nt|ndt:ndt|n$:n$|n:n|n*:n|b:n|e*:2|t*:e#VALUE!|","t*":"|ni:1|n*:e#VALUE!|t*:e#VALUE!|b:e#VALUE!|e*:2|","n*":"|ni:1|e*:2|","e*":"|e*:1|n*:1|t*:1|b:1|"},concat:{t:"|t:t|th:th|tw:tw|tl:t|tr:tr|t*:2|e*:2|",th:"|t:th|th:th|tw:t|tl:th|tr:t|t*:t|e*:2|",tw:"|t:tw|th:t|tw:tw|tl:tw|tr:tw|t*:t|e*:2|",tl:"|t:tl|th:th|tw:tw|tl:tl|tr:tr|t*:t|e*:2|","t*":"|t*:t|e*:2|","e*":"|e*:1|n*:1|t*:1|"},oneargnumeric:{"n*":"|n*:n|","e*":"|e*:1|","t*":"|t*:e#VALUE!|",b:"|b:n|"},twoargnumeric:{"n*":"|n*:n|t*:e#VALUE!|e*:2|","e*":"|e*:1|n*:1|t*:1|","t*":"|t*:e#VALUE!|n*:e#VALUE!|e*:2|"},propagateerror:{"n*":"|n*:2|e*:2|","e*":"|e*:2|","t*":"|t*:2|e*:2|",b:"|b:2|e*:2|"}},t.Formula.ParseFormulaIntoTokens=function(e){var o,i,n,r,a,s,l,c,u=t.Formula,d=t.Constants,h=u.ParseState,p=u.TokenType,f=u.CharClass,m=u.CharClassTable,g=u.UpperCaseTable,v=u.ParsePushToken,b=/^\$?[A-Z]{1,2}\$?[1-9]\d*$/i,y=[],C="",w=0,r=!1,x="";for(o=0;o<=e.length;o++)o<e.length?(i=e.charAt(o),n=m[i]):(i="",n=f.eof),w==h.num&&(n==f.num?C+=i:n!=f.numstart||r?"E"==i||"e"==i?(C+=i,r=!1,w=h.numexp1):(v(y,C,p.num,0),r=!1,w=0):(r=!0,C+=i)),w==h.numexp1&&(n==h.num?w=h.numexp2:"+"!=i&&"-"!=i||"E"!=g[C.charAt(C.length-1)]?"E"==i||"e"==i||(v(y,d.s_parseerrexponent,p.error,0),w=0):C+=i),w==h.numexp2&&(n==f.num?C+=i:(v(y,C,p.num,0),w=0)),w==h.alpha&&(n==f.num?w=h.coord:n==f.alpha||"."==i?C+=i:n==f.incoord?w=h.coord:n==f.op||n==f.numstart||n==f.space||n==f.eof?(v(y,C.toUpperCase(),p.name,0),w=0):(v(y,d.s_parseerrchar,p.error,0),w=0)),w==h.coord&&(n==f.num?C+=i:n==f.incoord?C+=i:n==f.alpha?w=h.alphanumeric:n==f.op||n==f.numstart||n==f.eof||n==f.space?(c=b.test(C)?p.coord:p.name,v(y,C.toUpperCase(),c,0),w=0):(v(y,d.s_parseerrchar,p.error,0),w=0)),w==h.alphanumeric&&(n==f.num||n==f.alpha?C+=i:n==f.op||n==f.numstart||n==f.space||n==f.eof?(v(y,C.toUpperCase(),p.name,0),w=0):(v(y,d.s_parseerrchar,p.error,0),w=0)),w==h.string?n==f.quote?w=h.stringquote:n==f.eof?(v(y,d.s_parseerrstring,p.error,0),w=0):C+=i:w==h.stringquote?n==f.quote?(C+=i,w=h.string):(v(y,C,p.string,0),w=0):w==h.specialvalue&&("!"==C.charAt(C.length-1)?(v(y,C,p.name,0),w=0):n==f.eof?(v(y,d.s_parseerrspecialvalue,p.error,0),w=0):C+=i),0==w&&(n==f.num?(C=i,w=h.num):n==f.numstart?(C=i,r=!0,w=h.num):n==f.alpha||n==f.incoord?(C=i,w=h.alpha):n==f.specialstart?(C=i,w=h.specialvalue):n==f.op?(C=i,y.length>0?(a=y[y.length-1],s=a.type,l=a.text,s==f.op&&(x=l+C,("<="==x||">="==x||"<>"==x)&&(C=l+C,y.pop(),y.length>0?(a=y[y.length-1],s=a.type,l=a.text):(s=f.eof,l="EOF")))):(s=f.eof,l="EOF"),c=p.op,0==y.length||s==f.op&&")"!=l&&"%"!=l?"-"==C?(C="M",i="M"):"+"==C?(C="P",i="P"):")"==C&&"("==l||"("!=C&&(c=p.error,C=d.s_parseerrtwoops):C.length>1&&(">="==C?(C="G",i="G"):"<="==C?(C="L",i="L"):"<>"==C?(C="N",i="N"):(c=p.error,C=d.s_parseerrtwoops)),v(y,C,c,i),w=0):n==f.quote?(C="",w=h.string):n==f.space||n==f.eof||v(y,d.s_parseerrchar,p.error,0));return y},t.Formula.ParsePushToken=function(e,t,o,i){e.push({text:t,type:o,opcode:i})},t.Formula.evaluate_parsed_formula=function(e,o,i){{var n,r,a=t.Formula;a.TokenType}return r=a.ConvertInfixToPolish(e),n=a.EvaluatePolish(e,r,o,i)},t.Formula.ConvertInfixToPolish=function(e){var o,i,n,r,a,s,l=t.Formula,c=t.Constants,u=l.TokenType,d=l.TokenPrecedence,h=[],p=[],f="",m=-1;for(o=0;o<e.length;o++)if(i=e[o],n=i.type,r=i.text,n==u.num||n==u.coord||n==u.string)h.push(o);else if(n==u.name)p.push(o),h.push(m);else{if(n==u.space)continue;if(","==r){for(;p.length&&"("!=e[p[p.length-1]].text;)h.push(p.pop());if(0==p.length){f=c.s_parseerrmissingopenparen;break}}else if("("==r)p.push(o);else if(")"==r){for(;p.length&&"("!=e[p[p.length-1]].text;)h.push(p.pop());if(0==p.length){f=c.s_parseerrcloseparennoopen;break}p.pop(),p.length&&e[p[p.length-1]].type==u.name&&h.push(p.pop())}else{if(n!=u.op){if(n==u.error){f=r;break}f="Internal error while processing parsed formula. ";break}for(p.length&&e[p[p.length-1]].type==u.name&&h.push(p.pop());!(!p.length||e[p[p.length-1]].type!=u.op||"("==e[p[p.length-1]].text||(a=d[i.opcode],s=d[e[p[p.length-1]].opcode],a>=0&&s>a)||0>a&&(a=-a,0>s&&(s=-s),s>=a));)h.push(p.pop());p.push(o)}}for(;p.length>0;){if("("==e[p[p.length-1]].text){f=c.s_parseerrmissingcloseparen;break}h.push(p.pop())}return f?f:h},"undefined"==typeof t.debug_log&&(t.debug_log=[]),t.DebugLog=function(){},t.Formula.EvaluatePolish=function(e,o,i,n){var r,a,s,l,c,u,d,h,p,f,m,g,v,b,y=t.Formula,C=t.Constants,w=y.TokenType,x=y.LookupResultType,_=y.TypeLookupTable,S=y.OperandAsNumber,k=y.OperandAsText,T=y.OperandValueAndType,F=y.OperandsAsCoordOnSheet,E=t.format_number_for_display||function(e){return e+""},D="",P=-1,A={value:"",type:"e#VALUE!",error:C.s_parseerrmissingoperand},I=[],M=function(e,t){I.push({type:e,value:t})};if(!(e.length&&o instanceof Array))return{value:"",type:"e#VALUE!",error:"string"==typeof o?o:""};var R=[];for(r=0;r<o.length;r++)if(a=o[r],a!=P)if(s=e[a],l=s.type,c=s.text,R.push(s),l==w.num)M("n",c-0);else if(l==w.coord)M("coord",c);else if(l==w.string)M("t",c);else if(l==w.op){if(I.length<=0)return A;if("M"==c)u=S(i,I),f=x(u.type,u.type,_.unaryminus),M(f,-u.value);else if("P"==c)u=S(i,I),f=x(u.type,u.type,_.unaryplus),M(f,u.value);else if("%"==c)u=S(i,I),f=x(u.type,u.type,_.unarypercent),M(f,.01*u.value);else if("&"==c){if(I.length<=1)return A;d=k(i,I),u=k(i,I),f=x(u.type,u.type,_.concat),M(f,u.value+d.value)}else if(":"==c){if(I.length<=1)return A;u=y.OperandsAsRangeOnSheet(i,I),u.error&&(D=D||u.error),M(u.type,u.value)}else if("!"==c){if(I.length<=1)return A;u=F(i,I),u.error&&(D=D||u.error),M(u.type,u.value)}else if("<"==c||"L"==c||"="==c||"G"==c||">"==c||"N"==c){if(I.length<=1){D=C.s_parseerrmissingoperand;break}d=T(i,I),u=T(i,I),"n"==u.type.charAt(0)&&"n"==d.type.charAt(0)?(g=0,"<"==c?g=u.value<d.value?1:0:"L"==c?g=u.value<=d.value?1:0:"="==c?g=u.value==d.value?1:0:"G"==c?g=u.value>=d.value?1:0:">"==c?g=u.value>d.value?1:0:"N"==c&&(g=u.value!=d.value?1:0),M("nl",g)):"e"==u.type.charAt(0)?M(u.type,0):"e"==d.type.charAt(0)?M(d.type,0):(h=u.type.charAt(0),p=d.type.charAt(0),"n"==h?u.value=E(u.value,"n",""):"b"==h&&(u.value=""),"n"==p?d.value=E(d.value,"n",""):"b"==p&&(d.value=""),g=0,u.value=u.value.toLowerCase(),d.value=d.value.toLowerCase(),"<"==c?g=u.value<d.value?1:0:"L"==c?g=u.value<=d.value?1:0:"="==c?g=u.value==d.value?1:0:"G"==c?g=u.value>=d.value?1:0:">"==c?g=u.value>d.value?1:0:"N"==c&&(g=u.value!=d.value?1:0),M("nl",g))}else{if(I.length<=1){D=C.s_parseerrmissingoperand;break}"+"==c?(d=T(i,I),u=T(i,I),f=x(u.type,d.type,_.plus),M(f,u.value+d.value)):(d=S(i,I),u=S(i,I)),"-"==c?(f=x(u.type,d.type,_.plus),M(f,u.value-d.value)):"*"==c?(f=x(u.type,d.type,_.plus),M(f,u.value*d.value)):"/"==c?0!=d.value?M("n",u.value/d.value):M("e#DIV/0!",0):"^"==c&&(u.value=Math.pow(u.value,d.value),u.type="n",isNaN(u.value)&&(u.value=0,u.type="e#NUM!"),M(u.type,u.value))}}else{if(l!=w.name){D=C.s_InternalError+"Unknown token "+l+" ("+c+"). ";break}if(D=y.CalculateFunction(c,I,i,e.coord))break}else M("start",0);return value=I[0]?I[0].value:"",h=I[0]?I[0].type:"","name"==h&&(u=t.Formula.LookupName(i,value),value=u.value,h=u.type,D=D||u.error),"coord"==h&&(u=T(i,I),value=u.value,h=u.type,"b"==h&&(h="n",value=0)),I.length>1&&!D&&(D+=C.s_parseerrerrorinformula),m=h,"e"==h.charAt(0)?D=D||h.substring(1)||C.s_calcerrerrorvalueinformula:"range"==h&&(v=value.match(/^(.*)\|(.*)\|/),b=v[1].indexOf("!"),v[1]=b>=0?v[1].substring(b+1)+"!"+v[1].substring(0,b).toUpperCase():v[1].toUpperCase(),value=v[1]+":"+v[2].toUpperCase(),n||(D=C.s_formularangeresult+" "+value)),D&&"e"!=m.charAt(0)&&(value=D,m="e"),"n"!=m.charAt(0)||!isNaN(value)&&isFinite(value)||(value=0,m="e#NUM!",D=isNaN(value)?C.s_calcerrnumericnan:C.s_calcerrnumericoverflow),{value:value,type:m,error:D}},t.Formula.LookupResultType=function(e,t,o){var i,n,r,a=o[e];return a||(a=o[e.charAt(0)+"*"])?(i=a.indexOf("|"+t+":"),i>=0?(n=a.indexOf("|",i+1),0>n?"e#VALUE! (internal error, incorrect LookupResultType "+a+")":(r=a.substring(i+t.length+2,n),"1"==r?e:"2"==r?t:r)):(i=a.indexOf("|"+t.charAt(0)+"*:"),i>=0?(n=a.indexOf("|",i+1),0>n?"e#VALUE! (internal error, incorrect LookupResultType "+a+")":(r=a.substring(i+4,n),"1"==r?e:"2"==r?t:r)):"e#VALUE!")):"e#VALUE! (internal error, missing LookupResultType "+e.charAt(0)+"*)"},t.Formula.TopOfStackValueAndType=function(e,o){var i=t.Formula,n={type:"",value:""},r=o.length;return r?(n.value=o[r-1].value,n.type=o[r-1].type,o.pop(),"name"==n.type&&(n=i.LookupName(e,n.value)),n):(n.error=t.Constants.s_InternalError+"no operand on stack",n)},t.Formula.OperandAsNumber=function(e,o){var i,n,r=t.Formula.OperandValueAndType(e,o);return i=r.type.charAt(0),"n"==i?r.value=r.value-0:"b"==i?(r.type="n",r.value=0):"e"==i?r.value=0:(n=t.DetermineValueType?t.DetermineValueType(r.value):{value:r.value-0,type:"n"},"n"==n.type.charAt(0)?(r.value=n.value-0,r.type=n.type):(r.value=0,r.type=n.type)),r},t.Formula.OperandAsText=function(e,o){var i,n=t.Formula.OperandValueAndType(e,o);return i=n.type.charAt(0),"t"==i||("n"==i?(n.value=t.format_number_for_display?t.format_number_for_display(n.value,n.type,""):n.value=n.value+"",n.type="t"):"b"==i?(n.value="",n.type="t"):"e"==i?n.value="":(o.value=n.value+"",o.type="t")),n},t.Formula.OperandValueAndType=function(e,o){var i,n,r,a,s=t.Formula,l={type:"",value:""},c=o.length;if(!c)return l.error=t.Constants.s_InternalError+"no operand on stack",l;if(l.value=o[c-1].value,l.type=o[c-1].type,o.pop(),"name"==l.type&&(l=s.LookupName(e,l.value)),"range"==l.type&&(l=s.StepThroughRangeDown(o,l.value)),"coord"==l.type){if(a=e,r=l.value.indexOf("!"),-1!=r){if(a=s.FindInSheetCache(l.value.substring(r+1)),null==a)return l.type="e#REF!",l.error=t.Constants.s_sheetunavailable+" "+l.value.substring(r+1),l.value=0,l;l.value=l.value.substring(0,r)}a?(n=a.cells[t.Formula.PlainCoord(l.value)],n?(i=n.valuetype,l.value=n.datavalue):i="b"):(i="e#N/A",l.value=0),l.type=i||"b","b"==l.type&&(l.value=0)}return l},t.Formula.OperandAsCoord=function(e,o){return t.Formula.OperandAsType(e,o,"coord")},t.Formula.OperandAsRange=function(e,o){return t.Formula.OperandAsType(e,o,"range")},t.Formula.OperandAsType=function(e,o,i){var n=(t.Formula,{type:"",value:""}),r=o.length;return n.value=o[r-1].value,n.type=o[r-1].type,o.pop(),"name"==n.type&&(n=t.Formula.LookupName(e,n.value)),n.type==i?n:(n.value=t.Constants.s_calcerrcellrefmissing,n.type="e#REF!",n)},t.Formula.OperandsAsCoordOnSheet=function(e,o){var i,n,r,a,s={},l={},c=t.Formula,u=o.length;return s.value=o[u-1].value,s.type=o[u-1].type,o.pop(),i=c.OperandAsSheetName(e,o),n=c.FindInSheetCache(i.value),null==n?(l.type="e#REF!",l.value=0,l.error=t.Constants.s_sheetunavailable+" "+i.value,l):("name"==s.type&&(s=c.LookupName(n,s.value)),l.type=s.type,"coord"==s.type?l.value=s.value+"!"+i.value:"range"==s.type?(r=s.value.indexOf("|"),a=s.value.indexOf("|",r+1),l.value=s.value.substring(0,r)+"!"+i.value+"|"+s.value.substring(r+1,a)+"|"):"e"==s.type.charAt(0)?l.value=s.value:(l.error=t.Constants.s_calcerrcellrefmissing,l.type="e#REF!",l.value=0),l)},t.Formula.OperandsAsRangeOnSheet=function(e,o){var i,n,r,a,s={},l=t.Formula,c=t.Constants,u=o.length;return s.value=o[u-1].value,s.type=o[u-1].type,o.pop(),i=l.OperandAsCoord(e,o),"coord"!=i.type?{value:0,type:"e#REF!"}:(n=e,r=i.value.indexOf("!"),-1!=r&&(a=i.value.indexOf("|",r+1),0>a&&(a=i.value.length),n=l.FindInSheetCache(i.value.substring(r+1,a)),null==n)?{value:0,type:"e#REF!",errortext:c.s_sheetunavailable+" "+i.value.substring(r+1,a)}:("name"==s.type&&(s=l.LookupName(n,s.value,"end")),"coord"==s.type?{value:i.value+"|"+s.value+"|",type:"range"}:{value:c.s_calcerrcellrefmissing,type:"e#REF!"}))},t.Formula.OperandAsSheetName=function(e,o){var i,n,r=(t.Formula,{type:"",value:""}),a=o.length;if(r.value=o[a-1].value,r.type=o[a-1].type,o.pop(),"name"==r.type){if(i=t.Formula.LookupName(e,r.value),!i.value)return r;r.value=i.value,r.type=i.type}return"coord"==r.type&&(n=e.cells[t.Formula.PlainCoord(r.value)],n?(r.value=n.datavalue,r.type=n.valuetype):(r.value="",r.type="b")),"t"==r.type.charAt(0)?r:(r.value="",r.error=t.Constants.s_calcerrsheetnamemissing,r)},t.Formula.LookupName=function(e,o,i){var n,r,a,s=e.names,l={},c=!1;if(s[o.toUpperCase()]){if(l.value=s[o.toUpperCase()].definition,"="==l.value.charAt(0)){if(e.checknamecirc){if(e.checknamecirc[o])return l.type="e#NAME?",l.error=t.Constants.s_circularnameref+' "'+o+'".',l}else e.checknamecirc={},c=!0;if(e.checknamecirc[o]=!0,a=t.Formula.ParseFormulaIntoTokens(l.value.substring(1)),l=t.Formula.evaluate_parsed_formula(a,e,1),delete e.checknamecirc[o],c&&delete e.checknamecirc,"range"!=l.type)return l}return n=l.value.indexOf(":"),-1!=n?(l.type="range",l.value=l.value.substring(0,n)+"|"+l.value.substring(n+1)+"|",l.value=l.value.toUpperCase()):(l.type="coord",l.value=l.value.toUpperCase()),l}return(r=t.Formula.SpecialConstants[o.toUpperCase()])?(n=r.indexOf(","),l.value=r.substring(0,n)-0,l.type=r.substring(n+1),l):/^[a-zA-Z][a-zA-Z]?$/.test(o)?(l.type="coord",l.value=o.toUpperCase()+(i?e.attribs.lastrow:1),l):(l.value="",l.type="e#NAME?",l.error=t.Constants.s_calcerrunknownname+' "'+o+'"',l)},t.Formula.StepThroughRangeDown=function(e,o){var i,n,r,a,s,l,c,u,d,h,p=t.Formula;for(a=o.indexOf("|"),s=o.indexOf("|",a+1),i=o.substring(0,a),n=o.substring(a+1,s),r=o.substring(s+1)-0,a=i.indexOf("!"),-1!=a?(l=i.substring(a),i=i.substring(0,a)):l="",a=n.indexOf("!"),-1!=a&&(n=n.substring(0,a)),c=p.OrderRangeParts(i,n),h=0,d=c.r1;d<=c.r2;d++)for(u=c.c1;u<=c.c2;u++)if(h++,h>r)return(d!=c.r2||u!=c.c2)&&p.PushOperand(e,"range",i+l+"|"+n+"|"+h),{value:t.crToCoord(u,d)+l,type:"coord"}},t.Formula.DecodeRangeParts=function(e,o){var i,n,r,a,s,l,c,u=t.Formula;return r=o.indexOf("|"),a=o.indexOf("|",r+1),i=o.substring(0,r),n=o.substring(r+1,a),r=i.indexOf("!"),-1!=r?(s=i.substring(r+1),i=i.substring(0,r)):s="",r=n.indexOf("!"),-1!=r&&(n=n.substring(0,r)),l=e,s&&(l=u.FindInSheetCache(s),null==l)?null:(c=u.OrderRangeParts(i,n),{sheetdata:l,sheetname:s,col1num:c.c1,ncols:c.c2-c.c1+1,row1num:c.r1,nrows:c.r2-c.r1+1})},t.Formula.FunctionList||(t.Formula.FunctionList={}),t.Formula.FunctionClasses=null,t.Formula.FunctionArgDefs={},t.Formula.StoreIoEventFormula=function(e,o,i,n,r){var a=[];if(t.Formula.Clone(a,i),a.reverse(),0!=a.length){if("undefined"==typeof n.ioEventTree&&(n.ioEventTree={}),"undefined"==typeof n.ioParameterList&&(n.ioParameterList={}),"undefined"==typeof n.ioTimeTriggerList&&(n.ioTimeTriggerList={}),"undefined"==typeof n.radioGroupList&&(n.radioGroupList={}),"undefined"==typeof n.ioParameterList[o]&&(n.ioParameterList[o]={}),n.ioParameterList[o]=a,n.ioParameterList[o].function_name=e,"TimeTrigger"==r){var s=function(e,t,o){var i=o.cells[t];"undefined"!=typeof i&&"n"==i.valuetype.charAt(0)&&e.push(i.datavalue)},l=t.Formula.PlainCoord(a[0].value),c=[];if("range"==a[0].type)for(var u=t.Formula.DecodeRangeParts(n,l),d=0;d<u.ncols;d++)for(var h=0;h<u.nrows;h++){var p=t.crToCoord(u.col1num+d,u.row1num+h);s(c,p,n)}if("coord"==a[0].type&&s(c,l,n),"n"==a[0].type.charAt(0)&&c.push(a[0].value),"undefined"==typeof n.ioTimeTriggerList[o]||0==t.Formula.ArrayValuesEqual(n.ioTimeTriggerList[o],c)){n.ioTimeTriggerList[o]=c;for(var f=(new Date).getTimezoneOffset(),m=25569,g=[],v=0;v<c.length;++v)g[v]=Math.floor(24*(c[v]-m)*60+f);n.ScheduleSheetCommands("settimetrigger "+o+" "+g.toString())}}if("EventTree"==r&&("coord"==a[0].type||"range"==a[0].type)){var b=a[0].value.replace(/\$/g,""),y=function(e,t,o){"undefined"==typeof e[t]&&(e[t]={}),e[t][o]=o};if("range"==a[0].type)for(var u=t.Formula.DecodeRangeParts(n,b),d=0;d<u.ncols;d++)for(var h=0;h<u.nrows;h++){var C=t.crToCoord(u.col1num+d,u.row1num+h);y(n.ioEventTree,C,o)}"coord"==a[0].type&&y(n.ioEventTree,b,o)}if("Input"==r){var w=null!=t.CurrentSpreadsheetControlObject?t.CurrentSpreadsheetControlObject.formDataViewer:t.CurrentSpreadsheetViewerObject.formDataViewer;if(null!=w&&1==w.loaded){null==w.formFields&&t.Formula.LoadFormFields();var x=(e+o).toLowerCase(),_=null;if(null==w.formFields[x]){var S=w.formFields[x]=w.formFieldsLength++ +2,k=t.crToCoord(S,1);_="set "+k+" text t "+t.encodeForSave(e.toLowerCase()+o)}if("t"==a[0].type.charAt(0)||"n"==a[0].type.charAt(0)){var T=t.crToCoord(w.formFields[x],2);if(null==w.sheet.cells[T]||w.sheet.cells[T].datavalue!=a[0].value){var F="set "+T+" text t "+t.encodeForSave(a[0].value);_=null!=_?_+"\n"+F:F}}null!=_&&w.sheet.ScheduleSheetCommands(_,!1)}}}},t.Formula.ArrayValuesEqual=function(e,t){var o=e.length;if(o!=t.length)return!1;for(;o--;)if(e[o]!==t[o])return!1;return!0},t.Formula.Clone=function(e,o){for(var i in o)"object"==typeof o[i]&&null!==o[i]&&e[i]?t.Formula.Clone(e[i],o[i]):e[i]=o[i]},t.Formula.LoadFormFields=function(){var e=null!=t.CurrentSpreadsheetControlObject?t.CurrentSpreadsheetControlObject.formDataViewer:t.CurrentSpreadsheetViewerObject.formDataViewer;e.formFields={},null==e.sheet.cells.A1&&e.sheet.ScheduleSheetCommands("set A1 text t "+t.encodeForSave("FieldName:"),!1),null==e.sheet.cells.A2&&e.sheet.ScheduleSheetCommands("set A2 text t "+t.encodeForSave("Pending:"),!1);for(var o=2;;){var i=t.crToCoord(o,1),n=e.sheet.cells[i];if(!n)break;e.formFields[n.datavalue.toLowerCase()]=o,o++}e.formFieldsLength=o-2},t.Formula.CalculateFunction=function(e,o,i,n){var r,a,s,l,c,u=t.Formula,d="";if(r=u.FunctionList[e]){if(a=[],s=r[0],l=r[1],u.CopyFunctionArgs(o,a),r[6]&&""!=r[6]&&(t.DebugLog("action:"+e),u.StoreIoEventFormula(e,n,a,i,r[6])),100!=l)if(0>l){if(a.length<-l)return d=u.FunctionArgsError(e,o)}else if(a.length!=l)return d=u.FunctionArgsError(e,o);d=s(e,o,a,i,n)}else c=e,o.length&&"start"==o[o.length-1].type?(o.pop(),u.PushOperand(o,"name",c)):d=t.Constants.s_sheetfuncunknownfunction+" "+c+". ";return d},t.Formula.PushOperand=function(e,t,o){e.push({type:t,value:o})},t.Formula.CopyFunctionArgs=function(e,o){var o;for(t.Formula;e.length>0&&"start"!=e[e.length-1].type;)o.push(e.pop());e.pop()},t.Formula.FunctionArgsError=function(e,o){var i=t.Constants.s_calcerrincorrectargstofunction+" "+e+". ";return t.Formula.PushOperand(o,"e#VALUE!",i),i},t.Formula.FunctionSpecificError=function(e,o,i,n){return t.Formula.PushOperand(o,i,n),n},t.Formula.CheckForErrorValue=function(e,t){return"e"==t.type.charAt(0)?(e.push(t),!0):!1},t.Formula.FillFunctionInfo=function(){var e,o,i,n,r,a=t.Formula,s=t.Constants;if(!a.FunctionClasses){for(e in a.FunctionList)o=a.FunctionList[e],o[2]&&(a.FunctionArgDefs[o[2]]=s["s_farg_"+o[2]]||""),o[3]||s["s_fdef_"+e]&&(a.FunctionList[e][3]=s["s_fdef_"+e]);for(a.FunctionClasses={},r=0;r<s.function_classlist.length;r++)n=s.function_classlist[r],a.FunctionClasses[n]={name:s["s_fclass_"+n],items:[]};for(e in a.FunctionList)for(o=a.FunctionList[e],i=o[4]?o[4].split(","):[],i.push("all"),r=0;r<i.length;r++)n=i[r],a.FunctionClasses[n].items.push(e);for(n in a.FunctionClasses)a.FunctionClasses[n].items.sort()}},t.Formula.FunctionArgString=function(e){var o,i,n,r=t.Formula,a=r.FunctionList[e],s=a[2];if(!s){if(o=a[1],0!=o){if(o>0){for(n="v1",i=2;o>=i;i++)n+=", v"+i;return n}if(0>o){for(n="v1",i=2;-o>i;i++)n+=", v"+i;return n+", ..."}return"nargs: "+o}s=" "}return n=r.FunctionArgDefs[s]||s},t.Formula.SeriesFunctions=function(e,o,i,n){for(var r,a,s,l,c,u,d,h,p,f=t.Formula,m=f.OperandValueAndType,g=f.LookupResultType,v=f.TypeLookupTable.plus,b=function(e,t){o.push({type:e,value:t})},y="",C=0,w="",x=0,_=0,S=0,k=1;i.length>0;)r=m(n,i),a=r.type.charAt(0),"n"==a&&(x+=1),"b"!=a&&(_+=1),"b"==a&&(S+=1),"e"!=a&&"b"!=a&&(y+=r.value),"n"==a?(s=r.value-0,C+=s,k*=s,l=void 0!=l?s>l?s:l:s,c=void 0!=c?c>s?s:c:s,1==x?(h=s,p=0):(u=h+(s-h)/x,d=p+(s-h)*(s-u),p=d,h=u),w=g(r.type,w||r.type,v)):"e"==a&&"e"!=w.charAt(0)&&(w=r.type);switch(w=w||"n",e){case"CONCAT":case"CONCATENATE":b("t",y);break;case"SUM":b(w,C);break;case"PRODUCT":b(w,k);break;case"MIN":b(w,c||0);break;case"MAX":b(w,l||0);break;case"COUNT":b("n",x);break;case"COUNTA":b("n",_);break;case"COUNTBLANK":b("n",S);break;case"AVERAGE":x>0?b(w,C/x):b("e#DIV/0!",0);break;case"STDEV":x>1?b(w,Math.sqrt(d/(x-1))):b("e#DIV/0!",0);break;case"STDEVP":x>1?b(w,Math.sqrt(d/x)):b("e#DIV/0!",0);break;case"VAR":x>1?b(w,d/(x-1)):b("e#DIV/0!",0);break;case"VARP":x>1?b(w,d/x):b("e#DIV/0!",0)}return null},t.Formula.FunctionList.AVERAGE=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.CONCAT=[t.Formula.SeriesFunctions,-1,"vn",null,"text"],t.Formula.FunctionList.CONCATENATE=[t.Formula.SeriesFunctions,-1,"vn",null,"text"],t.Formula.FunctionList.COUNT=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.COUNTA=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.COUNTBLANK=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.MAX=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.MIN=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.PRODUCT=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.STDEV=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.STDEVP=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.SUM=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.VAR=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.FunctionList.VARP=[t.Formula.SeriesFunctions,-1,"vn",null,"stat"],t.Formula.SumProductFunction=function(e,o,n,r){for(var a,s=[],l=0,c=t.Formula,u=0,d=0,h=function(e,t){o.push({type:e,value:t})};n.length>0;){if(a=c.TopOfStackValueAndType(r,n),"range"!=a.type)return void h("e#VALUE!",0);if(rangeinfo=c.DecodeRangeParts(r,a.value),u){if(u!=rangeinfo.ncols)return void h("e#VALUE!",0)}else u=rangeinfo.ncols;if(d){if(d!=rangeinfo.nrows)return void h("e#VALUE!",0)}else d=rangeinfo.nrows;for(i=0;i<rangeinfo.ncols;i++)for(j=0;j<rangeinfo.nrows;j++)k=i*rangeinfo.nrows+j,cellcr=t.crToCoord(rangeinfo.col1num+i,rangeinfo.row1num+j),cell=rangeinfo.sheetdata.GetAssuredCell(cellcr),value="n"==cell.valuetype?cell.datavalue:0,s[k]=("undefined"!=typeof s[k]?s[k]:1)*value}for(i=0;i<s.length;i++)l+=s[i];h("n",l)},t.Formula.FunctionList.SUMPRODUCT=[t.Formula.SumProductFunction,-1,"rangen","","stat"],t.Formula.DSeriesFunctions=function(e,o,i,n){var r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C,w,x,_,S,k,T,F,E,D,P,A=t.Formula,I=(A.OperandValueAndType,A.LookupResultType),M=A.TypeLookupTable.plus,R=function(e,t){o.push({type:e,value:t})},r={},N=0,L="",O=0,z=0,H=0,B=0,U=1;if(s=A.TopOfStackValueAndType(n,i),l=A.OperandValueAndType(n,i),c=A.TopOfStackValueAndType(n,i),"range"!=s.type||"range"!=c.type)return A.FunctionArgsError(e,o);if(u=A.DecodeRangeParts(n,s.value),d=A.DecodeRangeParts(n,c.value),h=A.FieldToColnum(u.sheetdata,u.col1num,u.ncols,u.row1num,l.value,l.type),0>=h)return void R("e#VALUE!",0);for(p=u.col1num+h-1,b=[],f=0;f<d.ncols;f++){if(v=d.sheetdata.GetAssuredCell(t.crToCoord(d.col1num+f,d.row1num)),criterianum=A.FieldToColnum(u.sheetdata,u.col1num,u.ncols,u.row1num,v.datavalue,v.valuetype),0>=criterianum)return void R("e#VALUE!",0);b.push(u.col1num+criterianum-1)}for(f=1;f<u.nrows;f++){y=!1;e:for(m=1;m<d.nrows;m++){for(g=0;g<d.ncols;g++)if(C=t.crToCoord(d.col1num+g,d.row1num+m),v=d.sheetdata.GetAssuredCell(C),w=v.datavalue,("string"!=typeof w||0!=w.length)&&(x=b[g],_=t.crToCoord(x,u.row1num+f),v=u.sheetdata.GetAssuredCell(_),!A.TestCriteria(v.datavalue,v.valuetype||"b",w)))continue e;y=!0;break e}y&&(a=t.crToCoord(p,u.row1num+f),v=u.sheetdata.GetAssuredCell(a),r.value=v.datavalue,r.type=v.valuetype,S=r.type.charAt(0),B+=1,"n"==S&&(O+=1),"b"!=S&&(z+=1),"b"==S&&(H+=1),"n"==S?(v1=r.value-0,N+=v1,U*=v1,k=void 0!=k?v1>k?v1:k:v1,T=void 0!=T?T>v1?v1:T:v1,1==O?(D=v1,P=0):(F=D+(v1-D)/O,E=P+(v1-D)*(v1-F),P=E,D=F),L=I(r.type,L||r.type,M)):"e"==S&&"e"!=L.charAt(0)&&(L=r.type))}switch(L=L||"n",e){case"DSUM":R(L,N);break;case"DPRODUCT":R(L,U);break;case"DMIN":R(L,T||0);break;case"DMAX":R(L,k||0);break;case"DCOUNT":R("n",O);break;case"DCOUNTA":R("n",z);break;case"DAVERAGE":O>0?R(L,N/O):R("e#DIV/0!",0);break;case"DSTDEV":O>1?R(L,Math.sqrt(E/(O-1))):R("e#DIV/0!",0);break;case"DSTDEVP":O>1?R(L,Math.sqrt(E/O)):R("e#DIV/0!",0);break;case"DVAR":O>1?R(L,E/(O-1)):R("e#DIV/0!",0);break;case"DVARP":O>1?R(L,E/O):R("e#DIV/0!",0);break;case"DGET":1==B?R(r.type,r.value):0==B?R("e#VALUE!",0):R("e#NUM!",0)}},t.Formula.FunctionList.DAVERAGE=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DCOUNT=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DCOUNTA=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DGET=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DMAX=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DMIN=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DPRODUCT=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DSTDEV=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DSTDEVP=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DSUM=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DVAR=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FunctionList.DVARP=[t.Formula.DSeriesFunctions,3,"dfunc","","stat"],t.Formula.FieldToColnum=function(e,o,i,n,r,a){var s,l,c; |
| 10 | if("n"==a.charAt(0))return s=r-0,0>=s||s>i?0:Math.floor(s);if("t"!=a.charAt(0))return 0;for(r=r?r.toLowerCase():"",s=0;i>s;s++)if(l=e.GetAssuredCell(t.crToCoord(o+s,n)),c=l.datavalue,c=(c+"").toLowerCase(),c==r)return s+1;return 0},t.Formula.LookupFunctions=function(e,o,i,n){var r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C,r,w=t.Formula,x=w.OperandValueAndType,_=(w.LookupResultType,w.TypeLookupTable.plus,function(e,t){o.push({type:e,value:t})});if(r=x(n,i),"string"==typeof r.value&&(r.value=r.value.toLowerCase()),a=w.TopOfStackValueAndType(n,i),s=1,"MATCH"==e){if(i.length){if(s=w.OperandAsNumber(n,i),"n"!=s.type.charAt(0))return void _("e#VALUE!",0);if(i.length)return w.FunctionArgsError(e,o),0;s=s.value-0}}else{if(l=w.OperandAsNumber(n,i),"n"!=l.type.charAt(0))return void _("e#VALUE!",0);if(l=Math.floor(l.value),i.length){if(s=w.OperandAsNumber(n,i),"n"!=s.type.charAt(0))return void _("e#VALUE!",0);if(i.length)return w.FunctionArgsError(e,o),0;s=s.value?1:0}}if(r.type=r.type.charAt(0),"n"==r.type&&(r.value=r.value-0),"range"!=a.type)return w.FunctionArgsError(e,o),0;if(c=w.DecodeRangeParts(n,a.value,a.type),!c)return void _("e#REF!",0);if(u=0,d=0,h=0,p=0,"HLOOKUP"==e){if(h=1,l>c.nrows)return void _("e#REF!",0)}else if("VLOOKUP"==e){if(p=1,l>c.ncols)return void _("e#REF!",0)}else{if("MATCH"!=e)return w.FunctionArgsError(e,o),0;if(c.ncols>1){if(c.nrows>1)return void _("e#N/A",0);h=1}else p=1}if(1>l&&"MATCH"!=e)return _("e#VALUE!",0),0;for(;;){if(C=t.crToCoord(c.col1num+u,c.row1num+d),v=c.sheetdata.GetAssuredCell(C),b=v.datavalue,y=v.valuetype?v.valuetype.charAt(0):"b","n"==y&&(b-=0),s){if("n"==r.type&&"n"==y){if(r.value==b)break;if(s>0&&r.value>b||0>s&&r.value<b)f=1,m=u,g=d;else if(f){f=2;break}}else if("t"==r.type&&"t"==y){if(b="string"==typeof b?b.toLowerCase():"",r.value==b)break;if(s>0&&r.value>b||0>s&&r.value<b)f=1,m=u,g=d;else if(f){f=2;break}}}else if("n"==r.type&&"n"==y){if(r.value==b)break}else if("t"==r.type&&"t"==y&&(b="string"==typeof b?b.toLowerCase():"",r.value==b))break;if(d+=p,u+=h,d>=c.nrows||u>=c.ncols){if(f){f=2;break}return void _("e#N/A",0)}}2==f&&(d=g,u=m),"MATCH"==e?(b=u+d+1,y="n"):(C=t.crToCoord(c.col1num+u+("VLOOKUP"==e?l-1:0),c.row1num+d+("HLOOKUP"==e?l-1:0)),v=c.sheetdata.GetAssuredCell(C),b=v.datavalue,y=v.valuetype),_(y,b)},t.Formula.FunctionList.HLOOKUP=[t.Formula.LookupFunctions,-3,"hlookup","","lookup"],t.Formula.FunctionList.MATCH=[t.Formula.LookupFunctions,-2,"match","","lookup"],t.Formula.FunctionList.VLOOKUP=[t.Formula.LookupFunctions,-3,"vlookup","","lookup"],t.Formula.IndexFunction=function(e,o,i,n){var r,a,s,l,c,u,d,h=t.Formula,p=function(e,t){o.push({type:e,value:t})};if(r=h.TopOfStackValueAndType(n,i),"range"!=r.type)return h.FunctionArgsError(e,o),0;if(s=h.DecodeRangeParts(n,r.value,r.type),a=s.sheetname?"!"+s.sheetname:"",l={value:0},c={value:0},i.length){if(l=h.OperandAsNumber(n,i),"n"!=l.type.charAt(0)||l.value<0)return void p("e#VALUE!",0);if(i.length){if(c=h.OperandAsNumber(n,i),"n"!=c.type.charAt(0)||c.value<0)return void p("e#VALUE!",0);if(i.length)return h.FunctionArgsError(e,o),0}else 1==s.nrows&&(c.value=l.value,l.value=0)}return l.value>s.nrows||c.value>s.ncols?void p("e#REF!",0):(0==l.value?0==c.value?1==s.nrows&&1==s.ncols?(u=t.crToCoord(s.col1num,s.row1num)+a,d="coord"):(u=t.crToCoord(s.col1num,s.row1num)+a+"|"+t.crToCoord(s.col1num+s.ncols-1,s.row1num+s.nrows-1)+"|",d="range"):1==s.nrows?(u=t.crToCoord(s.col1num+c.value-1,s.row1num)+a,d="coord"):(u=t.crToCoord(s.col1num+c.value-1,s.row1num)+a+"|"+t.crToCoord(s.col1num+c.value-1,s.row1num+s.nrows-1)+"|",d="range"):0==c.value?1==s.ncols?(u=t.crToCoord(s.col1num,s.row1num+l.value-1)+a,d="coord"):(u=t.crToCoord(s.col1num,s.row1num+l.value-1)+a+"|"+t.crToCoord(s.col1num+s.ncols-1,s.row1num+l.value-1)+"|",d="range"):(u=t.crToCoord(s.col1num+c.value-1,s.row1num+l.value-1)+a,d="coord"),void p(d,u))},t.Formula.FunctionList.INDEX=[t.Formula.IndexFunction,-1,"index","","lookup"],t.Formula.CountifSumifFunctions=function(e,o,i,n){var r,a,s,l,c,u,d=0,h="",p=0,f=t.Formula,m=f.OperandValueAndType,g=f.LookupResultType,v=f.TypeLookupTable.plus,b=function(e,t){o.push({type:e,value:t})};if(r=f.TopOfStackValueAndType(n,i),a=f.OperandAsText(n,i),"SUMIF"==e)if(1==i.length)s=f.TopOfStackValueAndType(n,i);else{if(0!=i.length)return f.FunctionArgsError(e,o),0;s={value:r.value,type:r.type}}else s={value:r.value,type:r.type};if("n"==a.type.charAt(0)?a.value=a.value+"":"e"==a.type.charAt(0)?a.value=null:"b"==a.type.charAt(0)&&(a.value=null),"coord"!=r.type&&"range"!=r.type)return f.FunctionArgsError(e,o),0;if("SUMIF"==e&&"coord"!=s.type&&"range"!=s.type)return f.FunctionArgsError(e,o),0;for(i.push(r),l=[],l.push(s);i.length;)c=m(n,i),u=m(n,l),f.TestCriteria(c.value,c.type,a.value)&&(p+=1,"n"==u.type.charAt(0)?(d+=u.value-0,h=g(u.type,h||u.type,v)):"e"==u.type.charAt(0)&&"e"!=h.charAt(0)&&(h=u.type));h=h||"n","SUMIF"==e?b(h,d):"COUNTIF"==e&&b("n",p)},t.Formula.FunctionList.COUNTIF=[t.Formula.CountifSumifFunctions,2,"rangec","","stat"],t.Formula.FunctionList.SUMIF=[t.Formula.CountifSumifFunctions,-2,"sumif","","stat"],t.Formula.SumifsFunction=function(e,o,i,n){var r,a,s,l,c,u,d=0,h="",p=t.Formula,f=p.OperandValueAndType,m=p.LookupResultType,g=p.TypeLookupTable.plus,v=function(e,t){o.push({type:e,value:t})};if(s=p.TopOfStackValueAndType(n,i),"coord"!=s.type&&"range"!=s.type)return p.FunctionArgsError(e,o),0;for(var b=[],y=[];i.length;){if(r=p.TopOfStackValueAndType(n,i),a=p.OperandAsText(n,i),"n"==a.type.charAt(0)?a.value=a.value+"":"e"==a.type.charAt(0)?a.value=null:"b"==a.type.charAt(0)&&(a.value=null),"coord"!=r.type&&"range"!=r.type)return p.FunctionArgsError(e,o),0;b.push([r]),y.push(a)}for(l=[],l.push(s);l.length;){u=f(n,l);for(var C=!0,w=0;w<b.length;w++)c=f(n,b[w]),C&&(p.TestCriteria(c.value,c.type,y[w].value)||(C=!1));C&&("n"==u.type.charAt(0)?(d+=u.value-0,h=m(u.type,h||u.type,g)):"e"==u.type.charAt(0)&&"e"!=h.charAt(0)&&(h=u.type))}h=h||"n",v(h,d)},t.Formula.FunctionList.SUMIFS=[t.Formula.SumifsFunction,-3,"sum_range, criteria_range1, criteria1, [criteria_range2, criteria2, ... criteria_range_n, criteria_n]","","stat"],t.Formula.IfFunction=function(e,o,i,n){var r,a,s=t.Formula;if(r=t.Formula.OperandValueAndType(n,i),a=r.type.charAt(0),"n"!=a&&"b"!=a)return void o.push({type:"e#VALUE!",value:0});var l,c;if(l=i.pop(),1==i.length)c=i.pop();else{if(0!=i.length)return void s.FunctionArgsError(e,o);c={type:"n",value:0}}o.push(r.value?l:c)},t.Formula.FunctionList.IF=[t.Formula.IfFunction,-2,"iffunc","","test"],t.Formula.DateFunction=function(e,o,i,n){var r=t.Formula,a=0,s=r.OperandAsNumber(n,i),l=r.OperandAsNumber(n,i),c=r.OperandAsNumber(n,i),u=r.LookupResultType(s.type,l.type,r.TypeLookupTable.twoargnumeric);u=r.LookupResultType(u,c.type,r.TypeLookupTable.twoargnumeric),"n"==u.charAt(0)&&(a=t.FormatNumber.convert_date_gregorian_to_julian(Math.floor(s.value),Math.floor(l.value),Math.floor(c.value))-t.FormatNumber.datevalues.julian_offset,u="nd"),r.PushOperand(o,u,a)},t.Formula.FunctionList.DATE=[t.Formula.DateFunction,3,"date","","datetime"],t.Formula.TimeFunction=function(e,o,i,n){var r=t.Formula,a=0,s=r.OperandAsNumber(n,i),l=r.OperandAsNumber(n,i),c=r.OperandAsNumber(n,i),u=r.LookupResultType(s.type,l.type,r.TypeLookupTable.twoargnumeric);u=r.LookupResultType(u,c.type,r.TypeLookupTable.twoargnumeric),"n"==u.charAt(0)&&(a=(60*s.value*60+60*l.value+c.value)/86400,u="nt"),r.PushOperand(o,u,a)},t.Formula.FunctionList.TIME=[t.Formula.TimeFunction,3,"hms","","datetime"],t.Formula.DMYFunctions=function(e,o,i,n){var r,a,s,l=t.Formula,c=0,u=l.OperandAsNumber(n,i),d=l.LookupResultType(u.type,u.type,l.TypeLookupTable.oneargnumeric);if("n"==d.charAt(0))switch(r=t.FormatNumber.convert_date_julian_to_gregorian(Math.floor(u.value+t.FormatNumber.datevalues.julian_offset)),e){case"DAY":c=r.day;break;case"MONTH":c=r.month;break;case"YEAR":c=r.year;break;case"WEEKDAY":if(a={value:1},i.length){if(a=l.OperandAsNumber(n,i),"n"!=a.type.charAt(0)||a.value<1||a.value>3)return void l.PushOperand(o,"e#VALUE!",0);if(i.length)return void l.FunctionArgsError(e,o)}s=6,a.value>1&&(s-=1),c=Math.floor(u.value+s)%7+(a.value<3?1:0)}l.PushOperand(o,d,c)},t.Formula.FunctionList.DAY=[t.Formula.DMYFunctions,1,"v","","datetime"],t.Formula.FunctionList.MONTH=[t.Formula.DMYFunctions,1,"v","","datetime"],t.Formula.FunctionList.YEAR=[t.Formula.DMYFunctions,1,"v","","datetime"],t.Formula.FunctionList.WEEKDAY=[t.Formula.DMYFunctions,-1,"weekday","","datetime"],t.Formula.HMSFunctions=function(e,o,i,n){var r,a,s,l,c=t.Formula,u=0,d=c.OperandAsNumber(n,i),h=c.LookupResultType(d.type,d.type,c.TypeLookupTable.oneargnumeric);if("n"==h.charAt(0)){if(d.value<0)return void c.PushOperand(o,"e#NUM!",0);l=d.value-Math.floor(d.value),l*=24,r=Math.floor(l),l-=Math.floor(l),l*=60,a=Math.floor(l),l-=Math.floor(l),l*=60,s=Math.floor(l+(d.value>=0?.5:-.5)),"HOUR"==e?u=r:"MINUTE"==e?u=a:"SECOND"==e&&(u=s)}c.PushOperand(o,h,u)},t.Formula.FunctionList.HOUR=[t.Formula.HMSFunctions,1,"v","","datetime"],t.Formula.FunctionList.MINUTE=[t.Formula.HMSFunctions,1,"v","","datetime"],t.Formula.FunctionList.SECOND=[t.Formula.HMSFunctions,1,"v","","datetime"],t.Formula.ExactFunction=function(e,o,i,n){var r=t.Formula,a=0,s="nl",l=r.OperandValueAndType(n,i),c=l.type.charAt(0),u=r.OperandValueAndType(n,i),d=u.type.charAt(0);"t"==c?"t"==d?a=l.value==u.value?1:0:"b"==d?a=l.value.length?0:1:"n"==d?a=l.value==u.value+""?1:0:"e"==d?(a=u.value,s=u.type):a=0:"n"==c?"n"==d?a=l.value-0==u.value-0?1:0:"b"==d?a=0:"t"==d?a=l.value+""==u.value?1:0:"e"==d?(a=u.value,s=u.type):a=0:"b"==c?"t"==d?a=u.value.length?0:1:"b"==d?a=1:"n"==d?a=0:"e"==d?(a=u.value,s=u.type):a=0:"e"==c&&(a=l.value,s=l.type),r.PushOperand(o,s,a)},t.Formula.FunctionList.EXACT=[t.Formula.ExactFunction,2,"","","text"],t.Formula.ArgList={FIND:[1,1,0],LEFT:[1,0],LEN:[1],LOWER:[1],MID:[1,0,0],PROPER:[1],REPLACE:[1,0,0,1],REPT:[1,0],RIGHT:[1,0],SUBSTITUTE:[1,1,1,0],TRIM:[1],HEXCODE:[1],UPPER:[1]},t.Formula.StringFunctions=function(e,o,i,n){var r,a,s,l,c,u,d=t.Formula,h=0,p="e#VALUE!",f=i.length,m=d.ArgList[e],g=[],v=[];for(r=1;f>=r;r++){if(r>m.length)return void d.FunctionArgsError(e,o);if(0==m[r-1]?a=d.OperandAsNumber(n,i):1==m[r-1]?a=d.OperandAsText(n,i):-1==m[r-1]&&(a=d.OperandValueAndType(n,i)),g[r]=a.value,v[r]=a.type,"e"==a.type.charAt(0))return void d.PushOperand(o,a.type,h)}switch(e){case"FIND":s=v[3]?g[3]-1:0,0>s?h="Start is before string":(h=g[2].indexOf(g[1],s),h>=0?(h+=1,p="n"):h="Not found");break;case"LEFT":l=v[2]?g[2]-0:1,0>l?h="Negative length":(h=g[1].substring(0,l),p="t");break;case"LEN":h=g[1].length,p="n";break;case"LOWER":h=g[1].toLowerCase(),p="t";break;case"MID":c=g[2]-0,l=g[3]-0,1>l||1>c?h="Bad arguments":(h=g[1].substring(c-1,c+l-1),p="t");break;case"PROPER":h=g[1].replace(/\b\w+\b/g,function(e){return e.substring(0,1).toUpperCase()+e.substring(1)}),p="t";break;case"REPLACE":c=g[2]-0,l=g[3]-0,0>l||1>c?h="Bad arguments":(h=g[1].substring(0,c-1)+g[4]+g[1].substring(c-1+l),p="t");break;case"REPT":if(u=g[2]-0,0>u)h="Negative count";else{for(h="";u>0;u--)h+=g[1];p="t"}break;case"RIGHT":l=v[2]?g[2]-0:1,0>l?h="Negative length":(h=g[1].slice(-l),p="t");break;case"SUBSTITUTE":if(fulltext=g[1],oldtext=g[2],newtext=g[3],null!=g[4]){if(which=g[4]-0,0>=which){h="Non-positive instance number";break}}else which=0;for(u=0,oldpos=0,h="";;){if(pos=fulltext.indexOf(oldtext,oldpos),!(pos>=0)){h+=fulltext.substring(oldpos);break}if(u++,h+=fulltext.substring(oldpos,pos),0==which)h+=newtext;else{if(which==u){h+=newtext+fulltext.substring(pos+oldtext.length);break}h+=oldtext}oldpos=pos+oldtext.length}p="t";break;case"TRIM":h=g[1],h=h.replace(/^ */,""),h=h.replace(/ *$/,""),h=h.replace(/ +/g," "),p="t";break;case"HEXCODE":h=String(g[1]);var b=h.charCodeAt(0);if(b>=55296&&56319>=b){var y=h.charCodeAt(1);y>=56320&&57343>=y&&(b=1024*(b-55296)+(y-56320)+65536)}h=b.toString(16).toUpperCase(),p="t";break;case"UPPER":h=g[1].toUpperCase(),p="t"}d.PushOperand(o,p,h)},t.Formula.FunctionList.FIND=[t.Formula.StringFunctions,-2,"find","","text"],t.Formula.FunctionList.LEFT=[t.Formula.StringFunctions,-2,"tc","","text"],t.Formula.FunctionList.LEN=[t.Formula.StringFunctions,1,"txt","","text"],t.Formula.FunctionList.LOWER=[t.Formula.StringFunctions,1,"txt","","text"],t.Formula.FunctionList.MID=[t.Formula.StringFunctions,3,"mid","","text"],t.Formula.FunctionList.PROPER=[t.Formula.StringFunctions,1,"v","","text"],t.Formula.FunctionList.REPLACE=[t.Formula.StringFunctions,4,"replace","","text"],t.Formula.FunctionList.REPT=[t.Formula.StringFunctions,2,"tc","","text"],t.Formula.FunctionList.RIGHT=[t.Formula.StringFunctions,-1,"tc","","text"],t.Formula.FunctionList.SUBSTITUTE=[t.Formula.StringFunctions,-3,"subs","","text"],t.Formula.FunctionList.TRIM=[t.Formula.StringFunctions,1,"v","","text"],t.Formula.FunctionList.HEXCODE=[t.Formula.StringFunctions,1,"v","","text"],t.Formula.FunctionList.UPPER=[t.Formula.StringFunctions,1,"v","","text"],t.Formula.IsFunctions=function(e,o,i,n){var r=t.Formula,a=0,s="nl",l=r.OperandValueAndType(n,i),c=l.type.charAt(0);switch(e){case"ISBLANK":a="b"==l.type?1:0;break;case"ISERR":a="e"==c?"e#N/A"==l.type?0:1:0;break;case"ISERROR":a="e"==c?1:0;break;case"ISLOGICAL":a="nl"==l.type?1:0;break;case"ISNA":a="e#N/A"==l.type?1:0;break;case"ISNONTEXT":a="t"==c?0:1;break;case"ISNUMBER":a="n"==c?1:0;break;case"ISTEXT":a="t"==c?1:0}r.PushOperand(o,s,a)},t.Formula.FunctionList.ISBLANK=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISERR=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISERROR=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISLOGICAL=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISNA=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISNONTEXT=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISNUMBER=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.FunctionList.ISTEXT=[t.Formula.IsFunctions,1,"v","","test"],t.Formula.NTVFunctions=function(e,o,i,n){var r=t.Formula,a=0,s="e#VALUE!",l=r.OperandValueAndType(n,i),c=l.type.charAt(0);switch(e){case"N":a="n"==c?l.value-0:0,s="n";break;case"T":a="t"==c?l.value+"":"",s="t";break;case"VALUE":"n"==c||"b"==c?(a=l.value||0,s="n"):"t"==c&&(l=t.DetermineValueType(l.value),"n"!=l.type.charAt(0)?(a=0,s="e#VALUE!"):(a=l.value-0,s="n"))}"e"==c&&(s=l.type),r.PushOperand(o,s,a)},t.Formula.FunctionList.N=[t.Formula.NTVFunctions,1,"v","","math"],t.Formula.FunctionList.T=[t.Formula.NTVFunctions,1,"v","","text"],t.Formula.FunctionList.VALUE=[t.Formula.NTVFunctions,1,"v","","text"],t.Formula.Math1Functions=function(e,o,i,n){var r,a,s,l={},c=t.Formula;if(r=c.OperandAsNumber(n,i),a=r.value,l.type=c.LookupResultType(r.type,r.type,c.TypeLookupTable.oneargnumeric),"n"==l.type)switch(e){case"ABS":a=Math.abs(a);break;case"ACOS":a>=-1&&1>=a?a=Math.acos(a):l.type="e#NUM!";break;case"ASIN":a>=-1&&1>=a?a=Math.asin(a):l.type="e#NUM!";break;case"ATAN":a=Math.atan(a);break;case"COS":a=Math.cos(a);break;case"DEGREES":a=180*a/Math.PI;break;case"EVEN":a=0>a?-a:a,a!=Math.floor(a)?a=Math.floor(a+1)+Math.floor(a+1)%2:a+=a%2,r.value<0&&(a=-a);break;case"EXP":a=Math.exp(a);break;case"FACT":for(s=1,a=Math.floor(a);a>0;a--)s*=a;a=s;break;case"INT":a=Math.floor(a);break;case"LN":0>=a&&(l.type="e#NUM!",l.error=t.Constants.s_sheetfunclnarg),a=Math.log(a);break;case"LOG10":0>=a&&(l.type="e#NUM!",l.error=t.Constants.s_sheetfunclog10arg),a=Math.log(a)/Math.log(10);break;case"ODD":a=0>a?-a:a,a!=Math.floor(a)?a=Math.floor(a+1)+(1-Math.floor(a+1)%2):a+=1-a%2,r.value<0&&(a=-a);break;case"RADIANS":a=a*Math.PI/180;break;case"SIN":a=Math.sin(a);break;case"SQRT":a>=0?a=Math.sqrt(a):l.type="e#NUM!";break;case"TAN":0!=Math.cos(a)?a=Math.tan(a):l.type="e#NUM!"}return l.value=a,o.push(l),null},t.Formula.FunctionList.ABS=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.ACOS=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.ASIN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.ATAN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.COS=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.DEGREES=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.EVEN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.EXP=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.FACT=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.INT=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.LN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.LOG10=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.ODD=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.RADIANS=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.SIN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.SQRT=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.FunctionList.TAN=[t.Formula.Math1Functions,1,"v","","math"],t.Formula.Math2Functions=function(e,o,i,n){var r,a,s,l,c,u,d={},h=t.Formula;if(r=h.OperandAsNumber(n,i),a=h.OperandAsNumber(n,i),s=0,d.type=h.LookupResultType(r.type,a.type,h.TypeLookupTable.twoargnumeric),"n"==d.type)switch(e){case"ATAN2":0==r.value&&0==a.value?d.type="e#DIV/0!":d.value=Math.atan2(a.value,r.value);break;case"POWER":d.value=Math.pow(r.value,a.value),isNaN(d.value)&&(d.value=0,d.type="e#NUM!");break;case"MOD":0==a.value?d.type="e#DIV/0!":(l=r.value/a.value,l=Math.floor(l),d.value=r.value-l*a.value);break;case"TRUNC":if(c=1,a.value>=0){for(a.value=Math.floor(a.value),u=0;u<a.value;u++)c*=10;d.value=Math.floor(Math.abs(r.value)*c)/c}else if(a.value<0){for(a.value=Math.floor(-a.value),u=0;u<a.value;u++)c*=10;d.value=Math.floor(Math.abs(r.value)/c)*c}r.value<0&&(d.value=-d.value)}return o.push(d),null},t.Formula.FunctionList.ATAN2=[t.Formula.Math2Functions,2,"xy","","math"],t.Formula.FunctionList.MOD=[t.Formula.Math2Functions,2,"","","math"],t.Formula.FunctionList.POWER=[t.Formula.Math2Functions,2,"","","math"],t.Formula.FunctionList.TRUNC=[t.Formula.Math2Functions,2,"valpre","","math"],t.Formula.LogFunction=function(e,o,i,n){var r,a,s={},l=t.Formula;if(s.value=0,r=l.OperandAsNumber(n,i),s.type=l.LookupResultType(r.type,r.type,l.TypeLookupTable.oneargnumeric),1==i.length){if(a=l.OperandAsNumber(n,i),"n"!=a.type.charAt(0)||a.value<=0)return l.FunctionSpecificError(e,o,"e#NUM!",t.Constants.s_sheetfunclogsecondarg),0}else{if(0!=i.length)return l.FunctionArgsError(e,o),0;a={value:Math.E,type:"n"}}if("n"==s.type){if(r.value<=0)return l.FunctionSpecificError(e,o,"e#NUM!",t.Constants.s_sheetfunclogfirstarg),0;s.value=Math.log(r.value)/Math.log(a.value)}o.push(s)},t.Formula.FunctionList.LOG=[t.Formula.LogFunction,-1,"log","","math"],t.Formula.RoundFunction=function(e,o,i,n){var r,a,s,l,c=t.Formula,u=0,d="e#VALUE!",h=c.OperandValueAndType(n,i),d=c.LookupResultType(h.type,h.type,c.TypeLookupTable.oneargnumeric);if(1==i.length){if(r=c.OperandValueAndType(n,i),"n"!=r.type.charAt(0))return c.FunctionSpecificError(e,o,"e#NUM!",t.Constants.s_sheetfuncroundsecondarg),0}else{if(0!=i.length)return c.FunctionArgsError(e,o),0;r={value:0,type:"n"}}if("n"==d)if(r.value=r.value-0,0==r.value)u=Math.round(h.value);else if(r.value>0){for(a=1,r.value=Math.floor(r.value),l=0;l<r.value;l++)a*=10;s=Math.round(h.value*a),u=s/a}else if(r.value<0){for(a=1,r.value=Math.floor(-r.value),l=0;l<r.value;l++)a*=10;s=Math.round(h.value/a),u=s*a}c.PushOperand(o,d,u)},t.Formula.FunctionList.ROUND=[t.Formula.RoundFunction,-1,"vp","","math"],t.Formula.CeilingFloorFunctions=function(e,o,i,n){var r,a,s,l=t.Formula,c=function(e,t){o.push({type:e,value:t})};if(r=l.OperandValueAndType(n,i),s=r.type.charAt(0),"n"!=s)return void c("e#VALUE!",0);if(0==r.value)return void c("n",0);if(1==i.length){if(a=l.OperandValueAndType(n,i),s=r.type.charAt(0),"n"!=s)return void c("e#VALUE!",0)}else{if(0!=i.length)return void c("e#VALUE!",0);a={type:"n",value:r.value>0?1:-1}}if(0==a.value)return void c("n",0);if(a.value*r.value<0)return void c("e#NUM!",0);switch(e){case"CEILING":c("n",Math.ceil(r.value/a.value)*a.value);break;case"FLOOR":c("n",Math.floor(r.value/a.value)*a.value)}},t.Formula.FunctionList.CEILING=[t.Formula.CeilingFloorFunctions,-1,"vsig","","math"],t.Formula.FunctionList.FLOOR=[t.Formula.CeilingFloorFunctions,-1,"vsig","","math"],t.Formula.AndOrFunctions=function(e,o,i,n){var r,a,s=t.Formula,l="";for("AND"==e?a=1:"OR"==e&&(a=0);i.length;)r=s.OperandValueAndType(n,i),"n"==r.type.charAt(0)?(r.value=r.value-0,"AND"==e?a=0!=r.value?a:0:"OR"==e&&(a=0!=r.value?1:a),l=s.LookupResultType(r.type,l||"nl",s.TypeLookupTable.propagateerror)):"e"==r.type.charAt(0)&&"e"!=l.charAt(0)&&(l=r.type);l.length<1&&(l="e#VALUE!",a=0),s.PushOperand(o,l,a)},t.Formula.FunctionList.AND=[t.Formula.AndOrFunctions,-1,"vn","","test"],t.Formula.FunctionList.OR=[t.Formula.AndOrFunctions,-1,"vn","","test"],t.Formula.NotFunction=function(e,o,i,n){var r=0,a=t.Formula,s=a.OperandValueAndType(n,i),l=a.LookupResultType(s.type,s.type,a.TypeLookupTable.propagateerror);"n"==s.type.charAt(0)||"b"==s.type?(r=s.value-0!=0?0:1,l="nl"):"t"==s.type.charAt(0)&&(l="e#VALUE!"),a.PushOperand(o,l,r)},t.Formula.FunctionList.NOT=[t.Formula.NotFunction,1,"v","","test"],t.Formula.ChooseFunction=function(e,o,i,n){var r,a,s,l=0,c=t.Formula,u=c.OperandAsNumber(n,i);for("n"!=u.type.charAt(0)&&(u.value=0),u.value=Math.floor(u.value),a=0;i.length;)if(s=c.TopOfStackValueAndType(n,i),a+=1,u.value==a){l=s.value,r=s.type;break}r?c.PushOperand(o,r,l):c.PushOperand(o,"e#VALUE!",0)},t.Formula.FunctionList.CHOOSE=[t.Formula.ChooseFunction,-2,"choose","","lookup"],t.Formula.ColumnsRowsFunctions=function(e,o,i,n){var r,a,s=0,l=t.Formula,c=l.TopOfStackValueAndType(n,i);"coord"==c.type?(s=1,r="n"):"range"==c.type?(a=l.DecodeRangeParts(n,c.value),"COLUMNS"==e?s=a.ncols:"ROWS"==e&&(s=a.nrows),r="n"):(s=0,r="e#VALUE!"),l.PushOperand(o,r,s)},t.Formula.FunctionList.COLUMNS=[t.Formula.ColumnsRowsFunctions,1,"range","","lookup"],t.Formula.FunctionList.ROWS=[t.Formula.ColumnsRowsFunctions,1,"range","","lookup"],t.Formula.ZeroArgFunctions=function(e,o){var i,n,r,a,s,l={value:0};switch(e){case"FALSE":l.type="nl",l.value=0;break;case"NA":l.type="e#N/A";break;case"NOW":i=new Date,n=i.getTimezoneOffset(),i=i.getTime()/1e3,r=25569,a=86400,s=r+i/a-n/1440,l.value=s,l.type="ndt",t.Formula.FreshnessInfo.volatile.NOW=!0;break;case"PI":l.type="n",l.value=Math.PI;break;case"TODAY":i=new Date,n=i.getTimezoneOffset(),i=i.getTime()/1e3,r=25569,a=86400,s=r+i/a-n/1440,l.value=Math.floor(s),l.type="nd",t.Formula.FreshnessInfo.volatile.TODAY=!0;break;case"TRUE":l.type="nl",l.value=1;break;case"RAND":l.type="n",l.value=Math.random(),t.Formula.FreshnessInfo.volatile.RAND=!0}return o.push(l),null},t.Formula.FunctionList.FALSE=[t.Formula.ZeroArgFunctions,0,"","","test"],t.Formula.FunctionList.NA=[t.Formula.ZeroArgFunctions,0,"","","test"],t.Formula.FunctionList.NOW=[t.Formula.ZeroArgFunctions,0,"","","datetime"],t.Formula.FunctionList.RAND=[t.Formula.ZeroArgFunctions,0,"","","math"],t.Formula.FunctionList.PI=[t.Formula.ZeroArgFunctions,0,"","","math"],t.Formula.FunctionList.TODAY=[t.Formula.ZeroArgFunctions,0,"","","datetime"],t.Formula.FunctionList.TRUE=[t.Formula.ZeroArgFunctions,0,"","","test"],t.Formula.DDBFunction=function(e,o,i,n){var r,a,s,l,c=t.Formula,u=c.OperandAsNumber(n,i),d=c.OperandAsNumber(n,i),h=c.OperandAsNumber(n,i),p=c.OperandAsNumber(n,i);if(!(c.CheckForErrorValue(o,u)||c.CheckForErrorValue(o,d)||c.CheckForErrorValue(o,h)||c.CheckForErrorValue(o,p))){if(h.value<1)return c.FunctionSpecificError(e,o,"e#NUM!",t.Constants.s_sheetfuncddblife),0;if(r={value:2,type:"n"},i.length>0&&(r=c.OperandAsNumber(n,i)),0!=i.length)return c.FunctionArgsError(e,o),0;if(!c.CheckForErrorValue(o,r)){for(a=0,s=0,l=1;l<=p.value-0&&l<=h.value;l++)a=(u.value-s)*(r.value/h.value),u.value-s-a<d.value&&(a=u.value-s-d.value),s+=a;c.PushOperand(o,"n$",a)}}},t.Formula.FunctionList.DDB=[t.Formula.DDBFunction,-4,"ddb","","financial"],t.Formula.SLNFunction=function(e,o,i,n){var r,a=t.Formula,s=a.OperandAsNumber(n,i),l=a.OperandAsNumber(n,i),c=a.OperandAsNumber(n,i);if(!a.CheckForErrorValue(o,s)&&!a.CheckForErrorValue(o,l)&&!a.CheckForErrorValue(o,c)){if(c.value<1)return a.FunctionSpecificError(e,o,"e#NUM!",t.Constants.s_sheetfuncslnlife),0;r=(s.value-l.value)/c.value,a.PushOperand(o,"n$",r)}},t.Formula.FunctionList.SLN=[t.Formula.SLNFunction,3,"csl","","financial"],t.Formula.SYDFunction=function(e,o,i,n){var r,a,s=t.Formula,l=s.OperandAsNumber(n,i),c=s.OperandAsNumber(n,i),u=s.OperandAsNumber(n,i),d=s.OperandAsNumber(n,i);if(!(s.CheckForErrorValue(o,l)||s.CheckForErrorValue(o,c)||s.CheckForErrorValue(o,u)||s.CheckForErrorValue(o,d))){if(u.value<1||d.value<=0)return s.PushOperand(o,"e#NUM!",0),0;a=(u.value+1)*u.value/2,r=(l.value-c.value)*(u.value-d.value+1)/a,s.PushOperand(o,"n$",r)}},t.Formula.FunctionList.SYD=[t.Formula.SYDFunction,4,"cslp","","financial"],t.Formula.InterestFunctions=function(e,o,i,n){var r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C,w,x,_,S,h,k,T,F=t.Formula,E=F.OperandAsNumber(n,i),D=F.OperandAsNumber(n,i),P=F.OperandAsNumber(n,i);if(r=F.LookupResultType(E.type,D.type,F.TypeLookupTable.twoargnumeric),r=F.LookupResultType(r,P.type,F.TypeLookupTable.twoargnumeric),i.length&&(s=F.OperandAsNumber(n,i),r=F.LookupResultType(r,s.type,F.TypeLookupTable.twoargnumeric),i.length&&(l=F.OperandAsNumber(n,i),r=F.LookupResultType(r,l.type,F.TypeLookupTable.twoargnumeric),i.length))){if("RATE"!=e)return F.FunctionArgsError(e,o),0;c=F.OperandAsNumber(n,i),r=F.LookupResultType(r,c.type,F.TypeLookupTable.twoargnumeric)}if("n"==r)switch(e){case"FV":h=E.value,p=D.value,f=P.value,u=null!=s?s.value:0,m=null!=l&&l.value?1:0,d=0==h?-u-f*p:-(u*Math.pow(1+h,p)+f*(1+h*m)*(Math.pow(1+h,p)-1)/h),a=d,r="n$";break;case"NPER":if(h=E.value,f=D.value,u=P.value,d=null!=s?s.value:0,m=null!=l&&l.value?1:0,0==h){if(0==f)return void F.PushOperand(o,"e#NUM!",0);p=(u+d)/-f}else{if(v=f*(1+h*m)/h,b=u+v,0==b||-1>=h)return void F.PushOperand(o,"e#NUM!",0);if(y=(v-d)/b,0>=y)return void F.PushOperand(o,"e#NUM!",0);C=Math.log(y),w=Math.log(1+h),p=C/w}a=p,r="n";break;case"PMT":if(h=E.value,p=D.value,u=P.value,d=null!=s?s.value:0,m=null!=l&&l.value?1:0,0==p)return void F.PushOperand(o,"e#NUM!",0);f=0==h?(d-u)/p:(0-d-u*Math.pow(1+h,p))/((1+h*m)*(Math.pow(1+h,p)-1)/h),a=f,r="n$";break;case"PV":if(h=E.value,p=D.value,f=P.value,d=null!=s?s.value:0,m=null!=l&&l.value?1:0,-1==h)return void F.PushOperand(o,"e#DIV/0!",0);u=0==h?-d-f*p:(-d-f*(1+h*m)*(Math.pow(1+h,p)-1)/h)/Math.pow(1+h,p),a=u,r="n$";break;case"RATE":for(p=E.value,f=D.value,u=P.value,d=null!=s?s.value:0,m=null!=l&&l.value?1:0,g=null!=c?c.value:.1,_=100,S=0,delta=1,epsilon=1e-7,h=g||1e-8;(delta>=0?delta:-delta)>epsilon&&h!=k;)if(delta=d+u*Math.pow(1+h,p)+f*(1+h*m)*(Math.pow(1+h,p)-1)/h,null!=x?(T=(delta-x)/(h-k)||.001,k=h,h-=delta/T,x=delta):(k=h,h=1.1*h,x=delta),S++,S>=_)return void F.PushOperand(o,"e#NUM!",0);a=h,r="n%"}F.PushOperand(o,r,a)},t.Formula.FunctionList.FV=[t.Formula.InterestFunctions,-3,"fv","","financial"],t.Formula.FunctionList.NPER=[t.Formula.InterestFunctions,-3,"nper","","financial"],t.Formula.FunctionList.PMT=[t.Formula.InterestFunctions,-3,"pmt","","financial"],t.Formula.FunctionList.PV=[t.Formula.InterestFunctions,-3,"pv","","financial"],t.Formula.FunctionList.RATE=[t.Formula.InterestFunctions,-3,"rate","","financial"],t.Formula.NPVFunction=function(e,o,i,n){var r,a,s,l,c,u=t.Formula,a=u.OperandAsNumber(n,i);if(!u.CheckForErrorValue(o,a)){for(s=0,r="n",l=1;i.length;)if(c=u.OperandValueAndType(n,i),"n"==c.type.charAt(0)){if(l*=1+a.value,0==l)return void u.PushOperand(o,"e#DIV/0!",0);s+=c.value/l,r=u.LookupResultType(c.type,r||c.type,u.TypeLookupTable.plus)}else if("e"==c.type.charAt(0)&&"e"!=r.charAt(0)){r=c.type;break}"n"==r.charAt(0)&&(r="n$"),u.PushOperand(o,r,s)}},t.Formula.FunctionList.NPV=[t.Formula.NPVFunction,-2,"npv","","financial"],t.Formula.IRRFunction=function(e,o,i,n){var r,a,s,l,c,u,d,h,p,f,m,g,v=[],b=[],y=t.Formula;for(v.push(i.pop());v.length;)if(r=y.OperandValueAndType(n,v),"n"==r.type.charAt(0))b.push(r.value);else if("e"==r.type.charAt(0))return void y.PushOperand(o,"e#VALUE!",0);if(!b.length)return void y.PushOperand(o,"e#NUM!",0);if(a={value:0},i.length){if(a=y.OperandAsNumber(n,i),"n"!=a.type.charAt(0)&&"b"!=a.type.charAt(0))return void y.PushOperand(o,"e#VALUE!",0);if(i.length)return void y.FunctionArgsError(e,o)}for(a.value=a.value||.1,l=20,c=0,u=1e-7,d=a.value,f=1;(f>=0?f:-f)>u&&d!=h;){for(f=0,m=1,g=0;g<b.length;g++){if(m*=1+d,0==m)return void y.PushOperand(o,"e#DIV/0!",0);f+=b[g]/m}if(null!=s?(p=(f-s)/(d-h),h=d,d-=f/p,s=f):(h=d,d=1.1*d,s=f),c++,c>=l)return void y.PushOperand(o,"e#NUM!",0)}y.PushOperand(o,"n%",d)},t.Formula.FunctionList.IRR=[t.Formula.IRRFunction,-1,"irr","","financial"],t.Formula.IoFunctions=function(o,i,n,r,a){var s,l,c,u,d={BUTTON:[2],IMAGEBUTTON:[2],EMAIL:[14,14,14,14],EMAILIF:[13,14,14,14,14],EMAILONEDIT:[14,14,14,14,14],EMAILAT:[13,14,14,14,14],EMAILONEDITIF:[14,13,14,14,14,14],EMAILATIF:[13,13,14,14,14,14],SUBMIT:[2],TEXTBOX:[2],AUTOCOMPLETE:[2,14],SELECT:[2,14,1,1],CHECKBOX:[3],RADIOBUTTON:[2,2],COPYVALUE:[4,12,15],COPYFORMULA:[4,12,12],INSERT:[4,8,-12,-15],DELETEIF:[4,7,8],COMMAND:[4,14],COMMANDIF:[4,13,14],PANEL:[15,-12],SPLASH:[12],STYLE:[6]},h=t.Formula,p=0,f="e#VALUE!",m=n.length,g=d[o],v=[],b=[],y=-1;for(s=1;m>=s;s++){if(-1!=y)u=Math.abs(g[c+(s-1-c)%y]);else{if(s>g.length)return void h.FunctionArgsError(o,i);u=g[s-1],0>u&&(y=g.length-(s-1),c=s-1,u=Math.abs(u))}if(1==u)l=h.OperandAsNumber(r,n);else if(2==u)l=h.OperandAsText(r,n);else if(3==u)l=h.OperandValueAndType(r,n);else{var C=n[n.length-1].type,w=!1;if(("n"==C.charAt(0)&&0!=(1&u)||"t"==C.charAt(0)&&0!=(2&u))&&(w=!0,l=h.OperandValueAndType(r,n)),"coord"==C&&0!=(4&u)&&(w=!0,l=h.OperandAsCoord(r,n),l.value=t.Formula.PlainCoord(l.value)),"range"==C&&0!=(8&u)&&(w=!0,l=h.OperandAsRange(r,n),l.value=t.Formula.PlainCoord(l.value)),0==w)return void h.FunctionArgsError(o,i)}if(v[s]=l.value,b[s]=l.type,"e"==l.type.charAt(0))return void h.PushOperand(i,l.type,p)}switch(o){case"STYLE":var x=r.ioParameterList[a];if(x){var _=t.Formula.getStandardizedList(r,{value:v[1],type:b[1]});_.length>0&&(x.css=_[0],x.cssParameter="t"==b[1]?'"'+v[1]+'"':v[1]),p="",f="ni"}break;case"SELECT":var x=r.ioParameterList[a],S=t.Formula.getStandardizedList(r,x[1]);if(x.html=[],x.html[0]=1==v[4]?"multiple":"",x.html[1]=v[3]?""+v[3]:"1",S.length>0){var k="<option>"+S.join("</option><option>")+"</option>",T=new RegExp("<option>"+v[1],"");x.html[2]=k.replace(T,"<option selected>"+v[1])}p=v[1],f="ti"+o;break;case"SUBMIT":p="Submit";case"BUTTON":case"IMAGEBUTTON":case"TEXTBOX":case"AUTOCOMPLETE":m>0&&(p=v[1]),f="ti"+o;break;case"EMAIL":case"EMAILIF":f="ti"+o,p="Send";break;case"EMAILONEDIT":case"EMAILONEDITIF":case"EMAILAT":case"EMAILATIF":f="ti"+o,p="Send Now";break;case"CHECKBOX":case"RADIOBUTTON":p="t"==b[1].charAt(0)?"TRUE"==v[1].toUpperCase()?1:0:0==v[1]?0:1,f="ni"+o;break;case"COPYVALUE":case"COPYFORMULA":case"INSERT":case"DELETEIF":case"COMMAND":case"COMMANDIF":var F=r.cells[v[1]];if("undefined"==typeof F)break;p=F.datavalue,p=String(p).split("/"),p=p[p.length-1],f="t";break;case"PANEL":case"SPLASH":var E,D=2;if("SPLASH"==o){if(p="SPLASH:"+v[1],f="t",1==r.splashdone)break;r.splashdone=!0,D=1,E=[0]}else E=t.Formula.getStandardizedList(r,{value:v[1],type:b[1]}),p=o+":"+E;if(f="t",t._app){for(var P=[],A=[],I=D;I<v.length;++I){var M=!1;for(var R in E)if(E[R]==I-1){M=!0;break}if(M!==!1){for(var N=t.Formula.getStandardizedCoords(r,{value:v[I],type:b[I]}),s=0;s<N.ncols;s++)A[N.col1num+s]=!0;for(var L=0;L<N.nrows;L++)P[N.row1num+L]=!0}}var O=e.spreadsheet;null==O&&(O=e.ss);var z=!1,H=0,B=function(e,t,o,i,n){for(var r=1;t>=r;r++){var a=n(r);"undefined"==typeof o[a]?i[r]!==!0?(o[a]="yes",z=!0):H=r:i[r]===!0&&(delete o[a],z=!0,H=r)}},U=function(e){return e};B(r,r.attribs.lastrow,r.rowattribs.hide,P,U),H=0,B(r,r.attribs.lastcol,r.colattribs.hide,A,t.rcColname),r.attribs.usermaxcol=H,z&&(r.renderneeded=!0,r.widgetsClean=!1,O.editor.context.rowpanes[0].first=1,O.editor.context.CalculateColWidthData(),O.width=O.editor.context.totalwidth,O.height=2500,O.editor.ResizeTableEditor(O.editor.context.totalwidth,2500)) |
| 11 | }}h.PushOperand(i,f,p)},t.Formula.FunctionList.BUTTON=[t.Formula.IoFunctions,1,"label","","gui","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Button('<%=cell_reference%>');\"><%=formated_value%></button>","ParameterList"],t.Formula.FunctionList.IMAGEBUTTON=[t.Formula.IoFunctions,1,"imageurl","","gui","<input type='image' src='<%=display_value%>' alt='Submit' onclick=\"SocialCalc.TriggerIoAction.Button('<%=cell_reference%>');\">","ParameterList"],t.Formula.FunctionList.EMAIL=[t.Formula.IoFunctions,-3,"to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","ParameterList"],t.Formula.FunctionList.EMAILIF=[t.Formula.IoFunctions,-4,"condition_range, to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","ParameterList"],t.Formula.FunctionList.EMAILONEDIT=[t.Formula.IoFunctions,-4,"editRange, to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","EventTree"],t.Formula.FunctionList.EMAILAT=[t.Formula.IoFunctions,-4,"datetime_value, to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","TimeTrigger"],t.Formula.FunctionList.EMAILONEDITIF=[t.Formula.IoFunctions,-5,"editRange, condition, to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","EventTree"],t.Formula.FunctionList.EMAILATIF=[t.Formula.IoFunctions,-5,"datetime_value, condition, to_range subject_range, body_range","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Email('<%=cell_reference%>');\"><%=formated_value%></button>","TimeTrigger"],t.Formula.FunctionList.SUBMIT=[t.Formula.IoFunctions,100,"[label]","","action","<button type='button' onclick=\"SocialCalc.TriggerIoAction.Submit('<%=cell_reference%>');\"><%=formated_value%></button>","ParameterList"],t.Formula.FunctionList.TEXTBOX=[t.Formula.IoFunctions,1,"value","","gui","<input type='text' id='TEXTBOX_<%=cell_reference%>' onblur='SocialCalc.CmdGotFocus(null);' oninput=\"SocialCalc.TriggerIoAction.TextBox('<%=cell_reference%>')\" value='<%=display_value%>' >","Input"],t.Formula.FunctionList.AUTOCOMPLETE=[t.Formula.IoFunctions,2,"value, range or csv_text","","gui","<input type='text' id='AUTOCOMPLETE_<%=cell_reference%>' onfocus=\"SocialCalc.TriggerIoAction.AddAutocomplete('<%=cell_reference%>');\" onblur='SocialCalc.CmdGotFocus(null);' value='<%=display_value%>' >","Input"],t.Formula.FunctionList.SELECT=[t.Formula.IoFunctions,-2,"value, range or csv_text [,size]","","gui","<select size='<%=html1_value%>' id='SELECT_<%=cell_reference%>' onchange=\"SocialCalc.TriggerIoAction.SelectList('<%=cell_reference%>')\" <%=html0_value%>><%=html2_value%></select>","Input"],t.Formula.FunctionList.CHECKBOX=[t.Formula.IoFunctions,1,"value","","gui","<input type='checkbox' id='CHECKBOX_<%=cell_reference%>' <%=checked%> onblur='SocialCalc.CmdGotFocus(null);' onchange=\"SocialCalc.TriggerIoAction.CheckBox('<%=cell_reference%>')\" >","Input"],t.Formula.FunctionList.RADIOBUTTON=[t.Formula.IoFunctions,2,"value, groupname","","gui","<input type='radio' value='<%=cell_reference%>' id='RADIOBUTTON_<%=cell_reference%>' <%=checked%> name='<%=parameter1_value%>' onblur=\"SocialCalc.CmdGotFocus(null);\" onclick=\"SocialCalc.TriggerIoAction.RadioButton('<%=parameter1_value%>');\" >","Input"],t.Formula.FunctionList.COPYVALUE=[t.Formula.IoFunctions,3,"trigger_cell, destinationCell, value_or_range","","action","","EventTree"],t.Formula.FunctionList.COPYFORMULA=[t.Formula.IoFunctions,3,"trigger_cell, destinationCell, formula_range","","action","","EventTree"],t.Formula.FunctionList.INSERT=[t.Formula.IoFunctions,-2,"trigger_cell, destination_range [,formula_range,value_or_range,formula_range, ...]","","action","","EventTree"],t.Formula.FunctionList.DELETEIF=[t.Formula.IoFunctions,-1,"trigger_cell, criteria , test_range","","action","","EventTree"],t.Formula.FunctionList.COMMAND=[t.Formula.IoFunctions,-1,"trigger_cell, commands","","action","","EventTree"],t.Formula.FunctionList.COMMANDIF=[t.Formula.IoFunctions,-1,"trigger_cell, conditions, commands","","action","","EventTree"],t.Formula.FunctionList.PANEL=[t.Formula.IoFunctions,-1,"showindices_range_or_csv, panel1_range [, panel2_range , ...]","","gui",""],t.Formula.FunctionList.SPLASH=[t.Formula.IoFunctions,-1,"splash_panel_range","","gui",""],t.Formula.FunctionList.STYLE=[t.Formula.IoFunctions,-1,"css","","gui",""],t.TriggerIoAction.AddAutocomplete=function(o){var i=e.spreadsheet;null==i&&(i=e.ss);var n=i.sheet,r=(t.Formula,n.ioParameterList[o]);if("undefined"!=typeof r){var a=t.Formula.getStandardizedList(n,r[1]);$.ui.autocomplete.filter=function(e,t){var o=new RegExp("\\b"+$.ui.autocomplete.escapeRegex(t),"i");return $.grep(e,function(e){return o.test(e.label||e.value||e)})},$("#AUTOCOMPLETE_"+o).autocomplete({source:a,minLength:1,autoFocus:!0,select:function(e,i){$(this).val(i.item.label),t.TriggerIoAction.AutoComplete(o)},change:function(e,i){null===i.item&&$(this).val(""),t.TriggerIoAction.AutoComplete(o)}})}},t.TriggerIoAction.Button=function(o){var i=e.spreadsheet;null==i&&(i=e.ss);{var n=i.sheet;t.Formula}if("undefined"!=typeof n.ioEventTree&&"undefined"!=typeof n.ioParameterList&&"undefined"!==n.ioEventTree[o])for(var r in n.ioEventTree[o]){var a=n.ioParameterList[r],s=null;switch(a.function_name){case"COPYVALUE":var l=t.Formula.getStandardizedValues(n,a[2]),c=t.coordToCr(a[1].value),u=t.TriggerIoAction.CopyValueToRange(l,c);i.editor.EditorScheduleSheetCommands(u,!0,!1);break;case"COPYFORMULA":var l=t.Formula.getStandardizedValues(n,a[2]),c=t.coordToCr(a[1].value),u=t.TriggerIoAction.CopyFormulaToRange(l,c);i.editor.EditorScheduleSheetCommands(u,!0,!1);break;case"INSERT":var l=t.Formula.getStandardizedValues(n,a[1]);if("range"!=l.type)break;var d,h,p;l.ncols>1&&(h=1,p=0,d="insertcol"),l.nrows>1&&(h=0,p=1,d="insertrow");for(var f=l.cellcoord[h][p],u=d+" "+f,c=t.coordToCr(f),m=2;m<a.length;)("range"==a[m].type||"coord"==a[m].type||m%2==1)&&(copyCellRange=t.Formula.getStandardizedValues(n,a[m]),u=m%2==0?u+"\n"+t.TriggerIoAction.CopyFormulaToRange(copyCellRange,c):u+"\n"+t.TriggerIoAction.CopyValueToRange(copyCellRange,c),l.nrows>1&&(c.col+=copyCellRange.ncols),l.ncols>1&&(c.row+=copyCellRange.nrows)),m++;i.editor.EditorScheduleSheetCommands(u,!0,!1);break;case"DELETEIF":var h,p,g,v=t.Formula.getStandardizedValues(n,a[1]),b=t.Formula.getStandardizedValues(n,a[2]),u="";if(b.ncols>1&&b.nrows>1)return;b.ncols>1&&(h=1,p=0,g="deletecol"),b.nrows>1&&(h=0,p=1,g="deleterow");for(var y=v.celldata[0][0].datavalue,C=b.ncols-h-1;C>=h;C--)for(var w=b.nrows-p-1;w>=p;w--){var x=b.celldata[C][w];1==t.Formula.TestCriteria(x.datavalue,x.valuetype,y)&&(""!=u&&(u+="\n"),u=u+g+" "+b.cellcoord[C][w])}""!=u&&i.editor.EditorScheduleSheetCommands(u,!0,!1);break;case"COMMANDIF":s=t.Formula.getStandardizedValues(n,a[1]);case"COMMAND":var _,u="";if(null!=s){var _=t.Formula.getStandardizedValues(n,a[2]);if(s.ncols!=_.ncols||s.nrows!=_.nrows)break}else _=t.Formula.getStandardizedValues(n,a[1]);for(var C=0;C<_.ncols;C++)for(var w=0;w<_.nrows;w++){if(null!=s){var S=s.celldata[C][w];if(0==S.datavalue)continue}""!=u&&(u+="\n");var k=_.celldata[C][w];u+=k.datavalue.toString().trim()}""!=u&&i.editor.EditorScheduleSheetCommands(u,!0,!1)}}},t.TriggerIoAction.CopyFormulaToRange=function(e,o){for(var i,n="",r=0;r<e.ncols;r++)for(var a=0;a<e.nrows;a++){var s=e.celldata[r][a],l=t.crToCoord(o.col+r,o.row+a);if((0!=r||0!=a)&&(n+="\n"),"undefined"!=typeof s&&"b"!=s.valuetype){var c=s.datatype,u=s.valuetype,d=s.datavalue,h=s.formula;"f"==c?(h=t.OffsetFormulaCoords(h,o.col-e.col1num,o.row-e.row1num),d="",u=""):"c"!=c&&(h=""),i="set "+l+" "+t.Constants.cellDataType[c]+" "+u+" "+t.encodeForSave(d)+" "+h}else i="set "+l+" empty";n+=i.trim()}return n},t.TriggerIoAction.CopyValueToRange=function(e,o){for(var i,n="",r=0;r<e.ncols;r++)for(var a=0;a<e.nrows;a++){var s=e.celldata[r][a],l=t.crToCoord(o.col+r,o.row+a);if((0!=r||0!=a)&&(n+="\n"),"undefined"!=typeof s&&"b"!=s.valuetype){var c=s.datatype,u=s.valuetype,d=s.datavalue,h=s.formula;"f"==c?(h="",c=u,"n"!=u&&"t"!=u.charAt(0)&&(c="c",h=s.displaystring),"t"==u.charAt(0)&&(c="t")):"c"!=c&&(h=""),i="set "+l+" "+t.Constants.cellDataType[c]+" "+u+" "+t.encodeForSave(d)+" "+h}else i="set "+l+" empty";n+=i.trim()}return n},t.TriggerIoAction.Email=function(o,i){i="undefined"!=typeof i?i:null;var n=t.Formula,r=e.spreadsheet;null==r&&(r=e.ss);var a=r.sheet,s=a.cells[o];if("undefined"!=typeof a.ioParameterList){var l=a.ioParameterList[o];if("undefined"!=typeof l){for(var c=[],u=[],d=1,h=0;h<l.length;h++)if("t"==l[h].type.charAt(0)&&(c[h]=[String(l[h].value).replace(/ /g,"%20")]),"coord"==l[h].type&&(c[h]=[String(a.GetAssuredCell(l[h].value).datavalue).replace(/ /g,"%20")]),"range"==l[h].type){var p=n.DecodeRangeParts(a,l[h].value);c[h]=[],u[h]=[];for(var f=0,m=0;m<p.ncols;m++)for(var g=0;g<p.nrows;g++){var v=t.crToCoord(p.col1num+m,p.row1num+g),s=p.sheetdata.GetAssuredCell(v);c[h].push(s.datavalue.toString().replace(/ /g,"%20")),u[h].push(v),f++}f>d&&(d=f)}var b=-1,y=0;switch(l.function_name){case"EMAILIF":b=0;case"EMAILAT":case"EMAILONEDIT":y=1;break;case"EMAILONEDITIF":case"EMAILATIF":b=1,y=2;break;case"EMAIL":}switch(l.function_name){case"EMAILONEDIT":case"EMAILONEDITIF":i&&"coord"==l[0].type&&l[0].value==i&&(i=null);break;default:i=null}for(var C=!1,w=[],x=d-1;x>-1;x--){if(-1!=b){var _=x>=c[b].length?0:x;if(0==c[b][_])continue}if(!i||i==u[0][x]){var S=x>=c[y].length?0:x,k=x>=c[y+1].length?0:x,T=x>=c[y+2].length?0:x,F=c[y][S]+" "+c[y+1][k]+" "+c[y+2][T];C=!0,a.ScheduleSheetCommands("sendemail "+F,!1),w.push([c[y][S],c[y+1][k],c[y+2][T]])}}return C&&t.EditorSheetStatusCallback(null,"emailing",null,r.editor),w}}},t.TriggerIoAction.Submit=function(){var o=null!=t.CurrentSpreadsheetControlObject?t.CurrentSpreadsheetControlObject.formDataViewer:t.CurrentSpreadsheetViewerObject.formDataViewer;if(null!=o&&1==o.loaded){var i=e.spreadsheet;null==i&&(i=e.ss);for(var n=i.sheet,r=new Date,a=""+r.getFullYear()+"-"+(r.getMonth()+1)+"-"+r.getDate()+" "+r.getHours()+":"+r.getMinutes()+":"+r.getSeconds(),s=2;s<=o.formFieldsLength+1;s++){var l=t.crToCoord(s,2);a+="\r"+o.sheet.cells[l].datavalue}n.ScheduleSheetCommands("submitform \r"+a,!1)}},t.TriggerIoAction.SelectList=function(e){var o=function(e){return e.value},i="SELECT";t.TriggerIoAction.updateInputWidgetFormula(i,e,o)},t.TriggerIoAction.AutoComplete=function(e){var o=function(e){return e.value},i="AUTOCOMPLETE";t.TriggerIoAction.updateInputWidgetFormula(i,e,o)},t.TriggerIoAction.TextBox=function(e){var o=function(e){return e.value},i="TEXTBOX";t.TriggerIoAction.updateInputWidgetFormula(i,e,o)},t.TriggerIoAction.CheckBox=function(e){var o=function(e){return e.checked?"TRUE":"FALSE"},i="CHECKBOX";t.TriggerIoAction.updateInputWidgetFormula(i,e,o)},t.TriggerIoAction.RadioButton=function(e){var o=function(e){return e.checked?"TRUE":"FALSE"},i="RADIOBUTTON";$('input[name="'+e+'"]').each(function(){t.TriggerIoAction.updateInputWidgetFormula(i,$(this).attr("id").replace(/RADIOBUTTON_/,""),o)})},t.TriggerIoAction.updateInputWidgetFormula=function(o,i,n){var r=e.spreadsheet;null==r&&(r=e.ss);var a=r.sheet,s=(a.cells[i],a.ioParameterList[i]);if("undefined"!=typeof s){var l=document.getElementById(o+"_"+i),c=n(l);c=t.encodeForSave(c);for(var u="set "+i+" formula "+o+'("'+c+'"',d=1;d<s.length;d++)"n"==s[d].type.charAt(0)&&(u+=","+s[d].value),"t"==s[d].type.charAt(0)&&(u+=',"'+s[d].value+'"'),"range"==s[d].type&&(u+=","+s[d].value.toString().replace(/(\$?[A-Z]+\$?[0-9]+)([!]?)([^|]*)[|](\$?[A-Z]+\$?[0-9]+)[|]/i,"$3$2$1:$4")),"coord"==s[d].type&&(u+=","+s[d].value);u+=")",s.cssParameter&&(u+="+style("+s.cssParameter+")"),r.editor.EditorScheduleSheetCommands(u,!0,!1),t.TriggerIoAction.UpdateFormDataSheet(o,i,c)}},t.TriggerIoAction.UpdateFormDataSheet=function(e,o,i){var n=null!=t.CurrentSpreadsheetControlObject?t.CurrentSpreadsheetControlObject.formDataViewer:t.CurrentSpreadsheetViewerObject.formDataViewer;if(null!=n){var r=(e+o).toLowerCase();if(null!=n.formFields[r]){var a=t.crToCoord(n.formFields[r],2);n.sheet.ScheduleSheetCommands("set "+a+" text t "+i,!1)}}},t.Formula.getStandardizedValues=function(e,o){return t.Formula.getStandardizedParameter(e,o,!0,!0)},t.Formula.getStandardizedCoords=function(e,o){return t.Formula.getStandardizedParameter(e,o,!0,!1)},t.Formula.getStandardizedList=function(e,o){var i=[],n=t.Formula.getStandardizedValues(e,o);if(1==n.ncols&&1==n.nrows)i=String(n.celldata[0][0].datavalue).split(",");else for(var r=0;r<n.ncols;r++)for(var a=0;a<n.nrows;a++){var s=n.celldata[r][a];i.push(s.datavalue.toString())}return i},t.Formula.getStandardizedParameter=function(e,o,i,n){var r={type:o.type,value:o.value};if(n&&(r.celldata=[]),"coord"!=o.type&&"range"!=o.type){if(r.ncols=1,r.nrows=1,r.col1num=1,r.row1num=1,i&&(r.cellcoord=null),n){r.celldata[0]=[];var a="n"==o.type?"v":"t"==o.type?o.type:"c";r.celldata[0][0]={coord:null,datatype:a,valuetype:o.type,datavalue:o.value}}}else{var s,l=t.Formula;if("coord"==o.type){var c=t.Formula.PlainCoord(o.value);s=l.DecodeRangeParts(e,c+"|"+c+"|")}"range"==o.type&&(s=l.DecodeRangeParts(e,o.value)),i&&(r.cellcoord=[]);for(var u=0;u<s.ncols;u++)for(var d=0;d<s.nrows;d++){var h=t.crToCoord(s.col1num+u,s.row1num+d);if(i&&("undefined"==typeof r.cellcoord[u]&&(r.cellcoord[u]=[]),r.cellcoord[u][d]=h),n){"undefined"==typeof r.celldata[u]&&(r.celldata[u]=[]);var p=s.sheetdata.GetAssuredCell(h);r.celldata[u][d]=p}}r.ncols=s.ncols,r.nrows=s.nrows,r.col1num=s.col1num,r.row1num=s.row1num}return r},t.Formula.SheetCache={sheets:{},waitingForLoading:null,constants:{asloaded:0,recalcing:1,recalcdone:2},loadsheet:null},t.Formula.FindInSheetCache=function(e){var o=t.Formula.SheetCache,i=t.Formula.NormalizeSheetName(e);return o.sheets[i]?o.sheets[i].sheet:o.waitingForLoading?null:o.loadsheet?(alert("Using SocialCalc.Formula.SheetCache.loadsheet - deprecated"),t.Formula.AddSheetToCache(i,o.loadsheet(i))):(o.waitingForLoading=i,null)},t.Formula.AddSheetToCache=function(e,o,i){var n=null,r=t.Formula.SheetCache,a=r.constants,s=t.Formula.NormalizeSheetName(e);return o&&(n=new t.Sheet,n.ParseSheetSave(o)),r.sheets[s]={sheet:n,recalcstate:a.asloaded,name:s},t.Formula.FreshnessInfo.sheets[s]="undefined"==typeof i||i===!1,n},t.Formula.NormalizeSheetName=function(e){return t.Callbacks.NormalizeSheetName?t.Callbacks.NormalizeSheetName(e):e.toLowerCase()},t.Formula.RemoteFunctionInfo={waitingForServer:null},t.Formula.FreshnessInfo={sheets:{},"volatile":{},recalc_completed:!1},t.Formula.FreshnessInfoReset=function(){var e=t.Formula.FreshnessInfo,o=t.Formula.SheetCache;for(var i in e.sheets)e.sheets[i]===!1&&delete o.sheets[i];e.sheets={},e.volatile={},e.recalc_completed=!1},t.Formula.PlainCoord=function(e){return-1==e.indexOf("$")?e:e.replace(/\$/g,"")},t.Formula.OrderRangeParts=function(e,o){var i,n,r={};return i=t.coordToCr(e),n=t.coordToCr(o),i.col>n.col?(r.c1=n.col,r.c2=i.col):(r.c1=i.col,r.c2=n.col),i.row>n.row?(r.r1=n.row,r.r2=i.row):(r.r1=i.row,r.r2=n.row),r},t.Formula.TestCriteria=function(e,o,i){var n,r,a,s,l;if(null==i)return!1;if(i+="",n=i.charAt(0),"="==n||"<"==n||">"==n?r=i.substring(1):-1!=i.search(/([^~]\*|^\*)/)||-1!=i.search(/([^~]\?|^\?)/)?(n="regex","*"==i?r=".+":(r=i.split("").reverse().join(""),r=r.replace(/\?(?=[^~])|\?$/g,"?.").replace(/\?~/g,"?\\").replace(/\*(?=[^~])|\*$/g,"*.").replace(/\*~/,"*\\"),r=r.split("").reverse().join("")),r="^"+r+"$"):(n=i.substring(0,2),"<="==n||"<>"==n||">="==n?r=i.substring(2):(n="none",r=i)),a=t.DetermineValueType(r),!a.type){if("none"==n)return!1;if("b"==o.charAt(0)){if("="==n)return!0}else if("<>"==n)return!0;return!1}if(s=!1,"n"==a.type.charAt(0)&&"t"==o.charAt(0)&&(l=t.DetermineValueType(e),"n"==l.type.charAt(0)&&(e=l.value,o=l.type)),"n"==o.charAt(0)&&"n"==a.type.charAt(0))switch(e-=0,a.value=a.value-0,n){case"<":s=e<a.value;break;case"<=":s=e<=a.value;break;case"=":case"none":s=e==a.value;break;case">=":s=e>=a.value;break;case">":s=e>a.value;break;case"<>":s=e!=a.value}else if("e"==o.charAt(0))s=!1;else if("e"==a.type.charAt(0))s=!1;else{if("n"==o.charAt(0)&&(e=t.format_number_for_display(e,"n","")),"n"==a.type.charAt(0))return!1;switch(e=e?e.toLowerCase():"",a.value=a.value?a.value.toLowerCase():"",n){case"<":s=e<a.value;break;case"<=":s=e<=a.value;break;case"=":s=e==a.value;break;case"none":s=e.substring(0,a.value.length)==a.value;break;case">=":s=e>=a.value;break;case">":s=e>a.value;break;case"<>":s=e!=a.value;break;case"regex":try{s=-1!=e.search(new RegExp(a.value))}catch(c){s=!1}}}return s};var t;t||(t={}),t.Popup={},t.Popup.Types={},t.Popup.Controls={},t.Popup.Current={},t.Popup.LocalizeString=function(e){return e},t.Popup.Create=function(e,o,i){var n=t.Popup.Types[e];n&&n.Create&&n.Create(e,o,i),t.Popup.imagePrefix=t.Constants.defaultImagePrefix},t.Popup.SetValue=function(e,o){var i=t.Popup,n=i.Types,r=i.Controls;if(!r[e])return void alert("Unknown control "+e);var a=r[e].type,s=n[a],l=r[e].data;s&&s.Create&&(s.SetValue(a,e,o),l.attribs&&l.attribs.changedcallback&&l.attribs.changedcallback(l.attribs,e,o))},t.Popup.SetDisabled=function(e,o){var i=t.Popup,n=i.Types,r=i.Controls;if(!r[e])return void alert("Unknown control "+e);var a=r[e].type,s=n[a];s&&s.Create&&(i.Current.id&&e==i.Current.id&&(s.Hide(a,i.Current.id),i.Current.id=null),s.SetDisabled(a,e,o))},t.Popup.GetValue=function(e){var o=t.Popup,i=o.Types,n=o.Controls;if(!n[e])return void alert("Unknown control "+e);var r=n[e].type,a=i[r];return a&&a.Create?a.GetValue(r,e):null},t.Popup.Initialize=function(e,o){var i=t.Popup,n=i.Types,r=i.Controls;if(!r[e])return void alert("Unknown control "+e);var a=r[e].type,s=n[a];s&&s.Initialize&&s.Initialize(a,e,o)},t.Popup.Reset=function(e){{var o=t.Popup,i=o.Types;o.Controls}i[e].Reset&&i[e].Reset(e)},t.Popup.CClick=function(e){var o=t.Popup,i=o.Types,n=o.Controls;if(!n[e])return void alert("Unknown control "+e);if(!n[e].data||!n[e].data.disabled){var r=n[e].type,a=i[r];if(o.Current.id&&(i[n[o.Current.id].type].Hide(r,o.Current.id),e==o.Current.id))return void(o.Current.id=null);a&&a.Show&&a.Show(r,e),o.Current.id=e}},t.Popup.Close=function(){{var e=t.Popup;e.Types,e.Controls}e.Current.id&&e.CClick(e.Current.id)},t.Popup.Cancel=function(){var e=t.Popup,o=e.Types,i=e.Controls;if(e.Current.id){var n=i[e.Current.id].type,r=o[n];r.Cancel(n,e.Current.id),e.Current.id=null}},t.Popup.CreatePopupDiv=function(e,o){var i,n=t.Popup,r=n.Controls,a=r[e].data,s=document.createElement("div");return s.style.position="absolute",i=t.GetElementPosition(a.mainele),s.style.top=i.top+a.mainele.offsetHeight+"px",s.style.left=i.left+"px",s.style.zIndex=100,s.style.backgroundColor="#FFF",s.style.border="1px solid black",o.width&&(s.style.width=o.width),a.mainele.appendChild(s),o.title&&(s.innerHTML='<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr><td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;">'+o.title+'</td><td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.Popup.Cancel();"> X </td></tr></table>',o.moveable&&(a.dragregistered=s.firstChild.firstChild.firstChild.firstChild,t.DragRegister(a.dragregistered,!0,!0,{MouseDown:t.DragFunctionStart,MouseMove:t.DragFunctionPosition,MouseUp:t.DragFunctionPosition,Disabled:null,positionobj:s},a.mainele))),s},t.Popup.EnsurePosition=function(e,o){function i(e){var o=t.GetElementPosition(e);return o.height=e.offsetHeight,o.width=e.offsetWidth,o.bottom=o.top+o.height,o.right=o.left+o.width,o}var n=t.Popup,r=n.Controls,a=r[e].data,s=a.mainele.firstChild;if(!s)return void alert("No main popup element firstChild.");var l=a.popupele,c=i(l),u=i(o),d=i(s),h=0;d.bottom+c.height<u.bottom&&d.left+c.width<u.right?(l.style.top=d.bottom+"px",l.style.left=d.left+"px",h=1):d.top-c.height>u.top&&d.left+c.width<u.right?(l.style.top=d.top-c.height+"px",l.style.left=d.left+"px",h=2):d.bottom+c.height<u.bottom&&d.right-c.width>u.left?(l.style.top=d.bottom+"px",l.style.left=d.right-c.width+"px",h=3):d.top-c.height>u.top&&d.right-c.width>u.left?(l.style.top=d.top-c.height+"px",l.style.left=d.right-c.width+"px",h=4):d.bottom+c.height<u.bottom&&c.width<u.width?(l.style.top=d.bottom+"px",l.style.left=u.left+Math.floor((u.width-c.width)/2)+"px",h=5):d.top-c.height>u.top&&c.width<u.width?(l.style.top=d.top-c.height+"px",l.style.left=u.left+Math.floor((u.width-c.width)/2)+"px",h=6):c.height<u.height&&d.right+c.width<u.right?(l.style.top=u.top+Math.floor((u.height-c.height)/2)+"px",l.style.left=d.right+"px",h=7):c.height<u.height&&d.left-c.width>u.left&&(l.style.top=u.top+Math.floor((u.height-c.height)/2)+"px",l.style.left=d.left-c.width+"px",h=8)},t.Popup.DestroyPopupDiv=function(e,o){e&&(e.innerHTML="",t.DragUnregister(o),e.parentNode&&e.parentNode.removeChild(e))},t.Popup.RGBToHex=function(e){var o=t.Popup;if(""==e)return"000000";var i=e.match(/(\d+)\D+(\d+)\D+(\d+)/);return i?o.ToHex(i[1])+o.ToHex(i[2])+o.ToHex(i[3]):"000000"},t.Popup.HexDigits="0123456789ABCDEF",t.Popup.ToHex=function(e){var o=t.Popup,i=Math.floor(e/16),n=e%16;return o.HexDigits.charAt(i)+o.HexDigits.charAt(n)},t.Popup.FromHex=function(e){var o=t.Popup,i=o.HexDigits.indexOf(e.charAt(0).toUpperCase()),n=o.HexDigits.indexOf(e.charAt(1).toUpperCase());return 16*(i>=0?i:0)+(n>=0?n:0)},t.Popup.HexToRGB=function(e){var o=t.Popup;return"rgb("+o.FromHex(e.substring(1,3))+","+o.FromHex(e.substring(3,5))+","+o.FromHex(e.substring(5,7))+")"},t.Popup.makeRGB=function(e,t,o){return"rgb("+(e>0?e:0)+","+(t>0?t:0)+","+(o>0?o:0)+")"},t.Popup.splitRGB=function(e){var t=e.match(/(\d+)\D+(\d+)\D+(\d+)\D/);return t?{r:t[1]-0,g:t[2]-0,b:t[3]-0}:{r:0,g:0,b:0}},t.Popup.Types.List={},t.Popup.Types.List.Create=function(e,o,i){var n=t.Popup,r=(n.Types,n.Controls),a={type:e,value:"",display:"",data:{}};r[o]=a;var s=a.data;s.attribs=i||{};var l=document.getElementById(o);return l?(s.mainele=l,l.innerHTML='<input style="cursor:pointer;width:100px;font-size:smaller;" onfocus="this.blur();" onclick="SocialCalc.Popup.CClick(\''+o+'\');" value="">',void(s.options=[])):void alert("Missing element "+o)},t.Popup.Types.List.SetValue=function(e,i,n){var r,a=t.Popup,s=(a.Types,a.Controls),l=s[i].data;for(l.value=n,l.custom=!1,r=0;r<l.options.length;r++)if(o=l.options[r],!(o.a&&(o.a.skip||o.a.custom||o.a.cancel)||o.v!=l.value)){l.display=o.o;break}r==l.options.length&&(l.display="Custom",l.custom=!0),l.mainele&&l.mainele.firstChild&&(l.mainele.firstChild.value=l.display)},t.Popup.Types.List.SetDisabled=function(e,o,i){var n=t.Popup,r=(n.Types,n.Controls),a=r[o].data;a.disabled=i,a.mainele&&a.mainele.firstChild&&(a.mainele.firstChild.disabled=i)},t.Popup.Types.List.GetValue=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data;return r.value},t.Popup.Types.List.Initialize=function(e,o,i){var n,r=t.Popup,a=(r.Types,r.Controls),s=a[o].data;for(n in i.attribs)s.attribs[n]=i.attribs[n];s.options=i?i.options:[],i.value&&r.SetValue(o,i.value)},t.Popup.Types.List.Reset=function(e){var o=t.Popup,i=o.Types,n=o.Controls;o.Current.id&&n[o.Current.id].type==e&&(i[e].Hide(e,o.Current.id),o.Current.id=null)},t.Popup.Types.List.Show=function(e,o){var i,n=t.Popup,r=(n.Types,n.Controls),a=r[o].data,s="";a.popupele=n.CreatePopupDiv(o,a.attribs),a.custom?(s=t.Popup.Types.List.MakeCustom(e,o),i=document.createElement("div"),i.innerHTML='<div style="cursor:default;padding:4px;background-color:#CCC;">'+s+"</div>",a.customele=i.firstChild.firstChild.childNodes[1],a.listdiv=null,a.contentele=i):(s=t.Popup.Types.List.MakeList(e,o),i=document.createElement("div"),i.innerHTML='<div style="cursor:default;padding:4px;">'+s+"</div>",a.customele=null,a.listdiv=i.firstChild,a.contentele=i),a.mainele&&a.mainele.firstChild&&(a.mainele.firstChild.disabled=!0),a.popupele.appendChild(i),a.attribs.ensureWithin&&t.Popup.EnsurePosition(o,a.attribs.ensureWithin)},t.Popup.Types.List.MakeList=function(e,o){var i,n,r,a=t.Popup,s=(a.Types,a.Controls),l=s[o].data,c='<table cellspacing="0" cellpadding="0"><tr>',u='<td style="vertical-align:top;">';for(c+=u,l.ncols=1,i=0;i<l.options.length;i++){if(n=l.options[i],n.a){if(n.a.newcol){c+="</td>"+u+" </td>"+u,l.ncols+=1;continue}if(n.a.skip){c+='<div style="font-size:x-small;white-space:nowrap;">'+n.o+"</div>";continue}}r=n.v!=l.value||n.a&&(n.a.custom||n.a.cancel)?"":"background-color:#DDF;",c+='<div style="font-size:x-small;white-space:nowrap;'+r+'" onclick="SocialCalc.Popup.Types.List.ItemClicked(\''+o+"','"+i+"');\" onmousemove=\"SocialCalc.Popup.Types.List.MouseMove('"+o+"',this);\">"+n.o+"</div>"}return c+="</td></tr></table>"},t.Popup.Types.List.MakeCustom=function(e,o){var i=t.Popup.LocalizeString,n=t.Popup,r=(n.Types,n.Controls),a=r[o].data,s='style="font-size:smaller;"',l="",c=a.value;return c=t.special_chars(c),l='<div style="white-space:nowrap;"><br><input id="customvalue" value="'+c+'"><br><br><input '+s+' type="button" value="'+i("OK")+'" onclick="SocialCalc.Popup.Types.List.CustomOK(\''+o+"');return false;\"><input "+s+' type="button" value="'+i("List")+'" onclick="SocialCalc.Popup.Types.List.CustomToList(\''+o+"');\"><input "+s+' type="button" value="'+i("Cancel")+'" onclick="SocialCalc.Popup.Close();"><br></div>'},t.Popup.Types.List.ItemClicked=function(e,o){var i,n,r,a=t.Popup,s=(a.Types,a.Controls),l=s[e].data,c=l.options[o].a;return c&&c.custom?(i=l.contentele,n=t.Popup.Types.List.MakeCustom("List",e),r=document.createElement("div"),r.innerHTML='<div style="cursor:default;padding:4px;background-color:#CCC;">'+n+"</div>",l.customele=r.firstChild.firstChild.childNodes[1],l.listdiv=null,l.contentele=r,l.popupele.replaceChild(r,i),void(l.attribs.ensureWithin&&t.Popup.EnsurePosition(e,l.attribs.ensureWithin))):c&&c.cancel?void t.Popup.Close():(t.Popup.SetValue(e,l.options[o].v),void t.Popup.Close())},t.Popup.Types.List.CustomToList=function(e){var o,i,n,r=t.Popup,a=(r.Types,r.Controls),s=a[e].data;o=s.contentele,i=t.Popup.Types.List.MakeList("List",e),n=document.createElement("div"),n.innerHTML='<div style="cursor:default;padding:4px;">'+i+"</div>",s.customele=null,s.listdiv=n.firstChild,s.contentele=n,s.popupele.replaceChild(n,o),s.attribs.ensureWithin&&t.Popup.EnsurePosition(e,s.attribs.ensureWithin)},t.Popup.Types.List.CustomOK=function(e){var o=t.Popup,i=(o.Types,o.Controls),n=i[e].data;t.Popup.SetValue(e,n.customele.value),t.Popup.Close()},t.Popup.Types.List.MouseMove=function(e,o){var i,n,r=t.Popup,a=(r.Types,r.Controls),s=a[e].data,l=s.listdiv;if(l){var c=l.firstChild.firstChild.firstChild;for(i=0;i<s.ncols;i++)for(n=0;n<c.childNodes[2*i].childNodes.length;n++)c.childNodes[2*i].childNodes[n].style.backgroundColor="#FFF";o.style.backgroundColor="#DDF"}},t.Popup.Types.List.Hide=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data;i.DestroyPopupDiv(r.popupele,r.dragregistered),r.popupele=null,r.mainele&&r.mainele.firstChild&&(r.mainele.firstChild.disabled=!1)},t.Popup.Types.List.Cancel=function(e,o){t.Popup.Types.List.Hide(e,o)},t.Popup.Types.ColorChooser={},t.Popup.Types.ColorChooser.Create=function(e,o,i){var n=t.Popup,r=(n.Types,n.Controls),a={type:e,value:"",display:"",data:{}};r[o]=a;var s=a.data;s.attribs=i||{};var l=s.attribs;s.value="";var c=document.getElementById(o);return c?(s.mainele=c,void(c.innerHTML='<div style="cursor:pointer;border:1px solid black;vertical-align:top;width:'+(l.sampleWidth||"15px")+";height:"+(l.sampleHeight||"15px")+';" onclick="SocialCalc.Popup.Types.ColorChooser.ControlClicked(\''+o+"');\"> </div>")):void alert("Missing element "+o)},t.Popup.Types.ColorChooser.SetValue=function(e,o,i){var n,r,a=t.Popup,s=(a.Types,a.Controls),l=s[o].data,c=l.attribs;l.value=i,l.custom=!1,l.mainele&&l.mainele.firstChild&&(l.value?(l.mainele.firstChild.style.backgroundColor=l.value,n=c.backgroundImage?"url("+a.imagePrefix+c.backgroundImage+")":"",r="center center"):(l.mainele.firstChild.style.backgroundColor="#FFF",c.backgroundImageDefault?(n="url("+a.imagePrefix+c.backgroundImageDefault+")",r="center center"):(n="url("+a.imagePrefix+"defaultcolor.gif)",r="left top")),l.mainele.firstChild.style.backgroundPosition=r,l.mainele.firstChild.style.backgroundImage=n)},t.Popup.Types.ColorChooser.SetDisabled=function(e,o,i){var n=t.Popup,r=(n.Types,n.Controls),a=r[o].data,s=a.attribs;a.disabled=i,a.mainele&&a.mainele.firstChild&&(i?(a.mainele.firstChild.style.backgroundColor="#DDD",s.backgroundImageDisabled?(img="url("+n.imagePrefix+s.backgroundImageDisabled+")",pos="center center"):(img="url("+n.imagePrefix+"defaultcolor.gif)",pos="left top"),a.mainele.firstChild.style.backgroundPosition=pos,a.mainele.firstChild.style.backgroundImage=img):n.SetValue(o,a.value))},t.Popup.Types.ColorChooser.GetValue=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data;return r.value},t.Popup.Types.ColorChooser.Initialize=function(e,o,i){var n,r=t.Popup,a=(r.Types,r.Controls),s=a[o].data;for(n in i.attribs)s.attribs[n]=i.attribs[n];i.value&&r.SetValue(o,i.value)},t.Popup.Types.ColorChooser.Reset=function(e){var o=t.Popup,i=o.Types,n=o.Controls;o.Current.id&&n[o.Current.id].type==e&&(i[e].Hide(e,o.Current.id),o.Current.id=null)},t.Popup.Types.ColorChooser.Show=function(e,o){var i,n,r=t.Popup,a=(r.Types,r.Controls),s=a[o].data,l="";s.oldvalue=s.value,s.popupele=r.CreatePopupDiv(o,s.attribs),s.custom?(l=t.Popup.Types.ColorChooser.MakeCustom(e,o),i=document.createElement("div"),i.innerHTML='<div style="cursor:default;padding:4px;background-color:#CCC;">'+l+"</div>",s.customele=i.firstChild.firstChild.childNodes[2],s.contentele=i):(n=t.Popup.Types.ColorChooser.CreateGrid(e,o),i=document.createElement("div"),i.style.padding="3px",i.style.backgroundColor="#CCC",i.appendChild(n),s.customele=null,s.contentele=i),s.popupele.appendChild(i),s.attribs.ensureWithin&&t.Popup.EnsurePosition(o,s.attribs.ensureWithin)},t.Popup.Types.ColorChooser.MakeCustom=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data,a=i.LocalizeString,s='style="font-size:smaller;"',l="";return l='<div style="white-space:nowrap;"><br>#<input id="customvalue" style="width:75px;" value="'+r.value+'"><br><br><input '+s+' type="button" value="'+a("OK")+'" onclick="SocialCalc.Popup.Types.ColorChooser.CustomOK(\''+o+"');return false;\"><input "+s+' type="button" value="'+a("Grid")+'" onclick="SocialCalc.Popup.Types.ColorChooser.CustomToGrid(\''+o+"');\"><br></div>"},t.Popup.Types.ColorChooser.ItemClicked=function(e){{var o=t.Popup,i=(o.Types,o.Controls);i[e].data}t.Popup.Close()},t.Popup.Types.ColorChooser.CustomToList=function(e){{var o=t.Popup,i=(o.Types,o.Controls);i[e].data}},t.Popup.Types.ColorChooser.CustomOK=function(e){var o=t.Popup,i=(o.Types,o.Controls),n=i[e].data;o.SetValue(e,n.customele.value),o.Close()},t.Popup.Types.ColorChooser.Hide=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data;i.DestroyPopupDiv(r.popupele,r.dragregistered),r.popupele=null},t.Popup.Types.ColorChooser.Cancel=function(e,o){var i=t.Popup,n=(i.Types,i.Controls),r=n[o].data;i.SetValue(o,r.oldvalue),t.Popup.Types.ColorChooser.Hide(e,o)},t.Popup.Types.ColorChooser.CreateGrid=function(e,o){var i,n,r,a,s,l=t.Popup,c=l.Types,u=l.Controls,d=l.LocalizeString,h=u[o].data;h.grid={};var p=h.grid,f=document.createElement("div");for(i=document.createElement("table"),i.cellSpacing=0,i.cellPadding=0,i.style.width="100px",p.table=i,i=document.createElement("tbody"),p.table.appendChild(i),p.tbody=i,n=0;16>n;n++){for(r=document.createElement("tr"),a=0;5>a;a++)s={},p[n+","+a]=s,i=document.createElement("td"),i.style.fontSize="1px",i.innerHTML=" ",i.style.height="10px",1>=a?(i.style.width="17px",i.style.borderRight="3px solid white"):(i.style.width="20px",i.style.backgroundRepeat="no-repeat"),r.appendChild(i),s.ele=i; |
| 12 | p.tbody.appendChild(r)}return f.appendChild(p.table),i=document.createElement("div"),i.style.marginTop="3px",i.innerHTML='<table cellspacing="0" cellpadding="0"><tr><td style="width:17px;background-color:#FFF;background-image:url('+l.imagePrefix+'defaultcolor.gif);height:16px;font-size:10px;cursor:pointer;" title="'+d("Default")+'"> </td><td style="width:23px;height:16px;font-size:10px;text-align:center;cursor:pointer;" title="'+d("Custom")+'">#</td><td style="width:60px;height:16px;font-size:10px;text-align:center;cursor:pointer;">'+d("OK")+"</td></tr></table>",p.defaultbox=i.firstChild.firstChild.firstChild.childNodes[0],p.defaultbox.onclick=c.ColorChooser.DefaultClicked,p.custom=i.firstChild.firstChild.firstChild.childNodes[1],p.custom.onclick=c.ColorChooser.CustomClicked,p.msg=i.firstChild.firstChild.firstChild.childNodes[2],p.msg.onclick=c.ColorChooser.CloseOK,f.appendChild(i),p.table.onmousedown=c.ColorChooser.GridMouseDown,c.ColorChooser.DetermineColors(o),c.ColorChooser.SetColors(o),f},t.Popup.Types.ColorChooser.gridToG=function(e,t,o){return e[t+","+o]},t.Popup.Types.ColorChooser.DetermineColors=function(e){var o,i,n=t.Popup,r=n.Types,a=r.ColorChooser,s=n.Controls,l=s[e].data,c=l.grid,u=n.splitRGB(l.value);for(o=2,i=16-Math.floor((u.r+16)/16),c["selectedrow"+o]=i,i=0;16>i;i++)a.gridToG(c,i,o).rgb=n.makeRGB(17*(15-i),0,0);for(o=3,i=16-Math.floor((u.g+16)/16),c["selectedrow"+o]=i,i=0;16>i;i++)a.gridToG(c,i,o).rgb=n.makeRGB(0,17*(15-i),0);for(o=4,i=16-Math.floor((u.b+16)/16),c["selectedrow"+o]=i,i=0;16>i;i++)a.gridToG(c,i,o).rgb=n.makeRGB(0,0,17*(15-i));for(o=1,i=0;16>i;i++)a.gridToG(c,i,o).rgb=n.makeRGB(17*(15-i),17*(15-i),17*(15-i));o=0;var d,h=[0,68,153,204,255],p=["400","310","420","440","442","340","040","042","032","044","024","004","204","314","402","414"];for(i=0;16>i;i++)d=p[i],a.gridToG(c,i,o).rgb="rgb("+h[d.charAt(0)-0]+","+h[d.charAt(1)-0]+","+h[d.charAt(2)-0]+")"},t.Popup.Types.ColorChooser.SetColors=function(e){var o,i,n,r,a=t.Popup,s=a.Types,l=s.ColorChooser,c=a.Controls,u=c[e].data,d=u.grid;for(o=0;16>o;o++)for(i=0;5>i;i++)n=l.gridToG(d,o,i),n.ele.style.backgroundColor=n.rgb,n.ele.title=a.RGBToHex(n.rgb),n.ele.style.backgroundImage=d["selectedrow"+i]==o?"url("+a.imagePrefix+"chooserarrow.gif)":"";a.SetValue(e,u.value),d.msg.style.backgroundColor=u.value,r=a.splitRGB(u.value||"rgb(255,255,255)"),d.msg.style.color=r.r+r.g+r.b<220?"#FFF":"#000",u.value?(d.msg.style.backgroundImage="",d.msg.title=a.RGBToHex(u.value)):(d.msg.style.backgroundColor="#FFF",d.msg.style.backgroundImage="url("+a.imagePrefix+"defaultcolor.gif)",d.msg.title="Default")},t.Popup.Types.ColorChooser.GridMouseDown=function(o){var i=o||e.event,n=t.Popup,r=n.Types,a=r.ColorChooser,s=n.Controls,l=n.Current.id;if(l){var c=s[l].data,u=c.grid;switch(i.type){case"mousedown":u.mousedown=!0;break;case"mouseup":u.mousedown=!1;break;case"mousemove":if(!u.mousedown)return}var d=t.GetElementPositionWithScroll(c.mainele),h=i.clientX-d.left,p=i.clientY-d.top,f=t.GetElementPositionWithScroll(u.table);f.left-=d.left,f.top-=d.top;var m=Math.floor((p-f.top-2)/10);m=0>m?0:m;var g=Math.floor((h-f.left)/20);m=0>m?0:m>15?15:m,g=0>g?0:g>4?4:g;var v=a.gridToG(u,m,g).ele.style.backgroundColor,b=n.splitRGB(v),y=n.splitRGB(c.value);switch(g){case 2:c.value=n.makeRGB(b.r,y.g,y.b);break;case 3:c.value=n.makeRGB(y.r,b.g,y.b);break;case 4:c.value=n.makeRGB(y.r,y.g,b.b);break;case 0:case 1:c.value=v}a.DetermineColors(l),a.SetColors(l)}},t.Popup.Types.ColorChooser.ControlClicked=function(e){var o=t.Popup,i=o.Types,n=i.ColorChooser,r=(o.Controls,o.Current.id);return r&&e==r?void n.CloseOK():void o.CClick(e)},t.Popup.Types.ColorChooser.DefaultClicked=function(o){var i=(o||e.event,t.Popup),n=i.Types,r=(n.ColorChooser,i.Controls),a=i.Current.id;if(a){var s=r[a].data;s.value="",t.Popup.SetValue(a,s.value),t.Popup.Close()}},t.Popup.Types.ColorChooser.CustomClicked=function(o){var i=(o||e.event,t.Popup),n=i.Types,r=(n.ColorChooser,i.Controls),a=i.Current.id;if(a){var s,l,c,u=r[a].data;s=u.contentele,l=t.Popup.Types.ColorChooser.MakeCustom("ColorChooser",a),c=document.createElement("div"),c.innerHTML='<div style="cursor:default;padding:4px;background-color:#CCC;">'+l+"</div>",u.customele=c.firstChild.firstChild.childNodes[2],u.contentele=c,u.popupele.replaceChild(c,s),u.customele.value=i.RGBToHex(u.value),u.attribs.ensureWithin&&t.Popup.EnsurePosition(a,u.attribs.ensureWithin)}},t.Popup.Types.ColorChooser.CustomToGrid=function(e){var o,i,n=t.Popup,r=(n.Types,n.Controls),a=r[e].data;t.Popup.SetValue(e,n.HexToRGB("#"+a.customele.value));var o,s,i;o=a.contentele,s=t.Popup.Types.ColorChooser.CreateGrid("ColorChooser",e),i=document.createElement("div"),i.style.padding="3px",i.style.backgroundColor="#CCC",i.appendChild(s),a.customele=null,a.contentele=i,a.popupele.replaceChild(i,o),a.attribs.ensureWithin&&t.Popup.EnsurePosition(e,a.attribs.ensureWithin)},t.Popup.Types.ColorChooser.CustomOK=function(e){var o=t.Popup,i=(o.Types,o.Controls),n=i[e].data;t.Popup.SetValue(e,o.HexToRGB("#"+n.customele.value)),t.Popup.Close()},t.Popup.Types.ColorChooser.CloseOK=function(o){var i=(o||e.event,t.Popup),n=i.Types,r=(n.ColorChooser,i.Controls),a=i.Current.id;if(a){var s=r[a].data;t.Popup.SetValue(a,s.value),t.Popup.Close()}};var t;t||(alert("Main SocialCalc code module needed"),t={}),t.TableEditor||alert("SocialCalc TableEditor code module needed"),t.CurrentSpreadsheetControlObject=null,t.SpreadsheetControl=function(e){var o=t.Constants;this.parentNode=null,this.spreadsheetDiv=null,this.requestedHeight=0,this.requestedWidth=0,this.requestedSpaceBelow=0,this.height=0,this.width=0,this.viewheight=0,this.tabs=[],this.tabnums={},this.tabreplacements={},this.currentTab=-1,this.views={},this.sheet=null,this.context=null,this.editor=null,this.spreadsheetDiv=null,this.editorDiv=null,this.sortrange="",this.moverange="",this.idPrefix=e||"SocialCalc-",this.multipartBoundary="SocialCalcSpreadsheetControlSave",this.imagePrefix=o.defaultImagePrefix,this.toolbarbackground=o.SCToolbarbackground,this.tabbackground=o.SCTabbackground,this.tabselectedCSS=o.SCTabselectedCSS,this.tabplainCSS=o.SCTabplainCSS,this.toolbartext=o.SCToolbartext,this.formulabarheight=o.SCFormulabarheight,this.statuslineheight=o.SCStatuslineheight,this.statuslineCSS=o.SCStatuslineCSS,this.ExportCallback=null,"undefined"==typeof t.debug_log&&(t.debug_log=[]),this.sheet=new t.Sheet,this.context=new t.RenderContext(this.sheet),this.context.showGrid=!0,this.context.showRCHeaders=!0,this.editor=new t.TableEditor(this.context),this.editor.StatusCallback.statusline={func:t.SpreadsheetControlStatuslineCallback,params:{statuslineid:this.idPrefix+"statusline",recalcid1:this.idPrefix+"divider_recalc",recalcid2:this.idPrefix+"button_recalc"}},t.CurrentSpreadsheetControlObject=this,this.editor.MoveECellCallback.movefrom=function(e){var o=t.GetSpreadsheetControlObject();o.context.cursorsuffix="",e.range2.hasrange&&!e.cellhandles.noCursorSuffix&&(e.ecell.row==e.range2.top&&(e.ecell.col<e.range2.left||e.ecell.col>e.range2.right+1)&&(o.context.cursorsuffix="insertleft"),e.ecell.col==e.range2.left&&(e.ecell.row<e.range2.top||e.ecell.row>e.range2.bottom+1)&&(o.context.cursorsuffix="insertup"))},this.formulabuttons={formulafunctions:{image:"insertformula.png",tooltip:"Functions",command:t.SpreadsheetControl.DoFunctionList},multilineinput:{image:"listbox.png",tooltip:"Multi-line Input Box",command:t.SpreadsheetControl.DoMultiline},link:{image:"inserthyperlink.png",tooltip:"Link Input Box",command:t.SpreadsheetControl.DoLink},sum:{image:"autosum.png",tooltip:"Auto Sum",command:t.SpreadsheetControl.DoSum}},this.findbuttons={last:{image:"upsearch.png",tooltip:"Find Previous",command:t.SpreadsheetControl.SearchUp},next:{image:"downsearch.png",tooltip:"Find Next",command:t.SpreadsheetControl.SearchDown}},this.tabnums.edit=this.tabs.length,this.tabs.push({name:"edit",text:"Edit",html:' <div id="%id.edittools" style="padding:10px 0px 0px 0px;"> <img id="%id.button_undo" src="%img.undo.png" style="vertical-align:bottom;"> <img id="%id.button_redo" src="%img.redo.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_copy" src="%img.copy.png" style="vertical-align:bottom;"> <img id="%id.button_cut" src="%img.cut.png" style="vertical-align:bottom;"> <img id="%id.button_paste" src="%img.paste.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_delete" src="%img.delete.png" style="vertical-align:bottom;"> <img id="%id.button_pasteformats" src="%img.formatpaintbrush.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <span id="%id.locktools"><img id="%id.button_lock" src="%img.lock.png" style="vertical-align:bottom;"> <img id="%id.button_unlock" src="%img.unlock.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> </span> <img id="%id.button_filldown" src="%img.filldown.png" style="vertical-align:bottom;"> <img id="%id.button_fillright" src="%img.fillright.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_movefrom" src="%img.movefromoff.gif" style="vertical-align:bottom;"> <img id="%id.button_movepaste" src="%img.movepasteoff.gif" style="vertical-align:bottom;"> <img id="%id.button_moveinsert" src="%img.moveinsertoff.gif" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_alignleft" src="%img.alignleft.png" style="vertical-align:bottom;"> <img id="%id.button_aligncenter" src="%img.aligncenter.png" style="vertical-align:bottom;"> <img id="%id.button_alignright" src="%img.alignright.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_borderon" src="%img.borderson.png" style="vertical-align:bottom;"> <img id="%id.button_borderoff" src="%img.bordersoff.png" style="vertical-align:bottom;"> <img id="%id.button_swapcolors" src="%img.swapcolors.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_merge" src="%img.mergecells.png" style="vertical-align:bottom;"> <img src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_insertrow" src="%img.insertrows.png" style="vertical-align:bottom;"> <img id="%id.button_insertcol" src="%img.insertcolumns.png" style="vertical-align:bottom;"> <img id="%id.button_deleterow" src="%img.deleterows.png" style="vertical-align:bottom;"> <img id="%id.button_deletecol" src="%img.deletecolumns.png" style="vertical-align:bottom;"> <img id="%id.button_hiderow" src="%img.hiderow.png" style="vertical-align:bottom;"> <img id="%id.button_hidecol" src="%img.hidecol.png" style="vertical-align:bottom;"> <img id="%id.divider_recalc" src="%img.divider1.png" style="vertical-align:bottom;"> <img id="%id.button_recalc" src="%img.recalc.png" style="vertical-align:bottom;"> </div>',oncreate:null,onclick:null}),this.tabnums.settings=this.tabs.length,this.tabs.push({name:"settings",text:"Format",html:'<div id="%id.settingstools" style="display:none;"> <div id="%id.sheetsettingstoolbar" style="display:none;"> <table cellspacing="0" cellpadding="0"><tr><td> <div style="%tbt.">%loc!SHEET SETTINGS!:</div> </td></tr><tr><td> <input id="%id.settings-savesheet" type="button" value="%loc!Save!" onclick="SocialCalc.SettingsControlSave(\'sheet\');"> <input type="button" value="%loc!Cancel!" onclick="SocialCalc.SettingsControlSave(\'cancel\');"> <input type="button" value="%loc!Show Cell Settings!" onclick="SocialCalc.SpreadsheetControlSettingsSwitch(\'cell\');return false;"> </td></tr></table> </div> <div id="%id.cellsettingstoolbar" style="display:none;"> <table cellspacing="0" cellpadding="0"><tr><td> <div style="%tbt.">%loc!CELL SETTINGS!: <span id="%id.settingsecell"> </span></div> </td></tr><tr><td> <input id="%id.settings-savecell" type="button" value="%loc!Save!" onclick="SocialCalc.SettingsControlSave(\'cell\');"> <input type="button" value="%loc!Cancel!" onclick="SocialCalc.SettingsControlSave(\'cancel\');"> <input type="button" value="%loc!Show Sheet Settings!" onclick="SocialCalc.SpreadsheetControlSettingsSwitch(\'sheet\');return false;"> </td></tr></table> </div></div>',view:"settings",onclick:function(e){t.SettingsControls.idPrefix=e.idPrefix,t.SettingControlReset();var o=e.sheet.EncodeSheetAttributes(),i=e.sheet.EncodeCellAttributes(e.editor.ecell.coord);t.SettingsControlLoadPanel(e.views.settings.values.sheetspanel,o),t.SettingsControlLoadPanel(e.views.settings.values.cellspanel,i),document.getElementById(e.idPrefix+"settingsecell").innerHTML=e.editor.ecell.coord,t.SpreadsheetControlSettingsSwitch("cell"),e.views.settings.element.style.height=e.viewheight+"px",e.views.settings.element.firstChild.style.height=e.viewheight+"px";var n;n=e.editor.range.hasrange?t.crToCoord(e.editor.range.left,e.editor.range.top)+":"+t.crToCoord(e.editor.range.right,e.editor.range.bottom):e.editor.ecell.coord,document.getElementById(e.idPrefix+"settings-savecell").value=t.LocalizeString("Save to")+": "+n},onclickFocus:!0}),this.views.settings={name:"settings",values:{},oncreate:function(e,o){var i=t.Constants;o.values.sheetspanel={colorchooser:{id:e.idPrefix+"scolorchooser"},formatnumber:{setting:"numberformat",type:"PopupList",id:e.idPrefix+"formatnumber",initialdata:i.SCFormatNumberFormats},formattext:{setting:"textformat",type:"PopupList",id:e.idPrefix+"formattext",initialdata:i.SCFormatTextFormats},fontfamily:{setting:"fontfamily",type:"PopupList",id:e.idPrefix+"fontfamily",initialdata:i.SCFormatFontfamilies},fontlook:{setting:"fontlook",type:"PopupList",id:e.idPrefix+"fontlook",initialdata:i.SCFormatFontlook},fontsize:{setting:"fontsize",type:"PopupList",id:e.idPrefix+"fontsize",initialdata:i.SCFormatFontsizes},textalignhoriz:{setting:"textalignhoriz",type:"PopupList",id:e.idPrefix+"textalignhoriz",initialdata:i.SCFormatTextAlignhoriz},numberalignhoriz:{setting:"numberalignhoriz",type:"PopupList",id:e.idPrefix+"numberalignhoriz",initialdata:i.SCFormatNumberAlignhoriz},alignvert:{setting:"alignvert",type:"PopupList",id:e.idPrefix+"alignvert",initialdata:i.SCFormatAlignVertical},textcolor:{setting:"textcolor",type:"ColorChooser",id:e.idPrefix+"textcolor"},bgcolor:{setting:"bgcolor",type:"ColorChooser",id:e.idPrefix+"bgcolor"},padtop:{setting:"padtop",type:"PopupList",id:e.idPrefix+"padtop",initialdata:i.SCFormatPadsizes},padright:{setting:"padright",type:"PopupList",id:e.idPrefix+"padright",initialdata:i.SCFormatPadsizes},padbottom:{setting:"padbottom",type:"PopupList",id:e.idPrefix+"padbottom",initialdata:i.SCFormatPadsizes},padleft:{setting:"padleft",type:"PopupList",id:e.idPrefix+"padleft",initialdata:i.SCFormatPadsizes},colwidth:{setting:"colwidth",type:"PopupList",id:e.idPrefix+"colwidth",initialdata:i.SCFormatColwidth},recalc:{setting:"recalc",type:"PopupList",id:e.idPrefix+"recalc",initialdata:i.SCFormatRecalc},usermaxcol:{setting:"usermaxcol",type:"PopupList",id:e.idPrefix+"usermaxcol",initialdata:i.SCFormatUserMaxCol},usermaxrow:{setting:"usermaxrow",type:"PopupList",id:e.idPrefix+"usermaxrow",initialdata:i.SCFormatUserMaxRow}},o.values.cellspanel={name:"cell",colorchooser:{id:e.idPrefix+"scolorchooser"},cformatnumber:{setting:"numberformat",type:"PopupList",id:e.idPrefix+"cformatnumber",initialdata:i.SCFormatNumberFormats},cformattext:{setting:"textformat",type:"PopupList",id:e.idPrefix+"cformattext",initialdata:i.SCFormatTextFormats},cfontfamily:{setting:"fontfamily",type:"PopupList",id:e.idPrefix+"cfontfamily",initialdata:i.SCFormatFontfamilies},cfontlook:{setting:"fontlook",type:"PopupList",id:e.idPrefix+"cfontlook",initialdata:i.SCFormatFontlook},cfontsize:{setting:"fontsize",type:"PopupList",id:e.idPrefix+"cfontsize",initialdata:i.SCFormatFontsizes},calignhoriz:{setting:"alignhoriz",type:"PopupList",id:e.idPrefix+"calignhoriz",initialdata:i.SCFormatTextAlignhoriz},calignvert:{setting:"alignvert",type:"PopupList",id:e.idPrefix+"calignvert",initialdata:i.SCFormatAlignVertical},ctextcolor:{setting:"textcolor",type:"ColorChooser",id:e.idPrefix+"ctextcolor"},cbgcolor:{setting:"bgcolor",type:"ColorChooser",id:e.idPrefix+"cbgcolor"},cbt:{setting:"bt",type:"BorderSide",id:e.idPrefix+"cbt"},cbr:{setting:"br",type:"BorderSide",id:e.idPrefix+"cbr"},cbb:{setting:"bb",type:"BorderSide",id:e.idPrefix+"cbb"},cbl:{setting:"bl",type:"BorderSide",id:e.idPrefix+"cbl"},cpadtop:{setting:"padtop",type:"PopupList",id:e.idPrefix+"cpadtop",initialdata:i.SCFormatPadsizes},cpadright:{setting:"padright",type:"PopupList",id:e.idPrefix+"cpadright",initialdata:i.SCFormatPadsizes},cpadbottom:{setting:"padbottom",type:"PopupList",id:e.idPrefix+"cpadbottom",initialdata:i.SCFormatPadsizes},cpadleft:{setting:"padleft",type:"PopupList",id:e.idPrefix+"cpadleft",initialdata:i.SCFormatPadsizes}},t.SettingsControlInitializePanel(o.values.sheetspanel),t.SettingsControlInitializePanel(o.values.cellspanel)},replacements:{itemtitle:{regex:/\%itemtitle\./g,replacement:'style="padding:12px 10px 0px 10px;font-weight:bold;text-align:right;vertical-align:top;font-size:small;"'},sectiontitle:{regex:/\%sectiontitle\./g,replacement:'style="padding:16px 10px 0px 0px;font-weight:bold;vertical-align:top;font-size:small;color:#C00;"'},parttitle:{regex:/\%parttitle\./g,replacement:'style="font-weight:bold;font-size:x-small;padding:0px 0px 3px 0px;"'},itembody:{regex:/\%itembody\./g,replacement:'style="padding:12px 0px 0px 0px;vertical-align:top;font-size:small;"'},bodypart:{regex:/\%bodypart\./g,replacement:'style="padding:0px 10px 0px 0px;font-size:small;vertical-align:top;"'}},divStyle:"border:1px solid black;overflow:auto;",html:'<div id="%id.scolorchooser" style="display:none;position:absolute;z-index:20;"></div><table cellspacing="0" cellpadding="0"> <tr><td style="vertical-align:top;"><table id="%id.sheetsettingstable" style="display:none;" cellspacing="0" cellpadding="0"><tr> <td %itemtitle.><br>%loc!Default Format!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Number!</div> <span id="%id.formatnumber"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Text!</div> <span id="%id.formattext"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Default Alignment!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Text Horizontal!</div> <span id="%id.textalignhoriz"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Number Horizontal!</div> <span id="%id.numberalignhoriz"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Vertical!</div> <span id="%id.alignvert"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Default Font!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Family!</div> <span id="%id.fontfamily"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Bold & Italics!</div> <span id="%id.fontlook"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Size!</div> <span id="%id.fontsize"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Color!</div> <div id="%id.textcolor"></div> </td> <td %bodypart.> <div %parttitle.>%loc!Background!</div> <div id="%id.bgcolor"></div> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Default Padding!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Top!</div> <span id="%id.padtop"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Right!</div> <span id="%id.padright"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Bottom!</div> <span id="%id.padbottom"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Left!</div> <span id="%id.padleft"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Default Column Width!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.> </div> <span id="%id.colwidth"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Recalculation!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.> </div> <span id="%id.recalc"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Dimensions!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Columns!</div> <span id="%id.usermaxcol"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Rows!</div> <span id="%id.usermaxrow"></span> </td> </tr></table> </td></tr></table><table id="%id.cellsettingstable" cellspacing="0" cellpadding="0"><tr> <td %itemtitle.><br>%loc!Format!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Number!</div> <span id="%id.cformatnumber"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Text!</div> <span id="%id.cformattext"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Alignment!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Horizontal!</div> <span id="%id.calignhoriz"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Vertical!</div> <span id="%id.calignvert"></span> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Font!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Family!</div> <span id="%id.cfontfamily"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Bold & Italics!</div> <span id="%id.cfontlook"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Size!</div> <span id="%id.cfontsize"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Color!</div> <div id="%id.ctextcolor"></div> </td> <td %bodypart.> <div %parttitle.>%loc!Background!</div> <div id="%id.cbgcolor"></div> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Borders!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"> <tr><td %bodypart. colspan="3"><div %parttitle.>%loc!Top Border!</div></td> <td %bodypart. colspan="3"><div %parttitle.>%loc!Right Border!</div></td> <td %bodypart. colspan="3"><div %parttitle.>%loc!Bottom Border!</div></td> <td %bodypart. colspan="3"><div %parttitle.>%loc!Left Border!</div></td> </tr><tr> <td %bodypart.> <input id="%id.cbt-onoff-bcb" onclick="SocialCalc.SettingsControlOnchangeBorder(this);" type="checkbox"> </td> <td %bodypart.> <div id="%id.cbt-color"></div> </td> <td> </td> <td %bodypart.> <input id="%id.cbr-onoff-bcb" onclick="SocialCalc.SettingsControlOnchangeBorder(this);" type="checkbox"> </td> <td %bodypart.> <div id="%id.cbr-color"></div> </td> <td> </td> <td %bodypart.> <input id="%id.cbb-onoff-bcb" onclick="SocialCalc.SettingsControlOnchangeBorder(this);" type="checkbox"> </td> <td %bodypart.> <div id="%id.cbb-color"></div> </td> <td> </td> <td %bodypart.> <input id="%id.cbl-onoff-bcb" onclick="SocialCalc.SettingsControlOnchangeBorder(this);" type="checkbox"> </td> <td %bodypart.> <div id="%id.cbl-color"></div> </td> <td> </td> </tr></table> </td></tr><tr> <td %itemtitle.><br>%loc!Padding!:</td> <td %itembody.> <table cellspacing="0" cellpadding="0"><tr> <td %bodypart.> <div %parttitle.>%loc!Top!</div> <span id="%id.cpadtop"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Right!</div> <span id="%id.cpadright"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Bottom!</div> <span id="%id.cpadbottom"></span> </td> <td %bodypart.> <div %parttitle.>%loc!Left!</div> <span id="%id.cpadleft"></span> </td> </tr></table> </td></tr></table> </td><td style="vertical-align:top;padding:12px 0px 0px 12px;"> <div style="width:100px;height:100px;overflow:hidden;border:1px solid black;background-color:#EEE;padding:6px;"> <table cellspacing="0" cellpadding="0"><tr> <td id="sample-text" style="height:100px;width:100px;"><div>%loc!This is a<br>sample!</div><div>-1234.5</div></td> </tr></table> </div> </td></tr></table><br>'},this.tabnums.sort=this.tabs.length,this.tabs.push({name:"sort",text:"Sort",html:' <div id="%id.sorttools" style="display:none;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;padding-right:4px;width:160px;"> <div style="%tbt.">%loc!Set Cells To Sort!</div> <select id="%id.sortlist" size="1" onfocus="%s.CmdGotFocus(this);"><option selected>[select range]</option><option value="all">Sort All</option></select> <input type="button" value="%loc!OK!" onclick="%s.DoCmd(this, \'ok-setsort\');" style="font-size:x-small;"> </td> <td style="vertical-align:middle;padding-right:16px;width:100px;text-align:right;"> <div style="%tbt."> </div> <input type="button" id="%id.sortbutton" value="%loc!Sort Cells! A1:A1" onclick="%s.DoCmd(this, \'dosort\');" style="visibility:hidden;"> </td> <td style="vertical-align:top;padding-right:16px;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;"> <div style="%tbt.">%loc!Major Sort!</div> <select id="%id.majorsort" size="1" onfocus="%s.CmdGotFocus(this);"></select> </td><td> <input type="radio" name="majorsort" id="%id.majorsortup" value="up" checked><span style="font-size:x-small;color:#555753;">%loc!Up!</span><br> <input type="radio" name="majorsort" id="%id.majorsortdown" value="down"><span style="font-size:x-small;color:#555753;">%loc!Down!</span> </td> </tr></table> </td> <td style="vertical-align:top;padding-right:16px;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;"> <div style="%tbt.">%loc!Minor Sort!</div> <select id="%id.minorsort" size="1" onfocus="%s.CmdGotFocus(this);"></select> </td><td> <input type="radio" name="minorsort" id="%id.minorsortup" value="up" checked><span style="font-size:x-small;color:#555753;">%loc!Up!</span><br> <input type="radio" name="minorsort" id="%id.minorsortdown" value="down"><span style="font-size:x-small;color:#555753;">%loc!Down!</span> </td> </tr></table> </td> <td style="vertical-align:top;padding-right:16px;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;"> <div style="%tbt.">%loc!Last Sort!</div> <select id="%id.lastsort" size="1" onfocus="%s.CmdGotFocus(this);"></select> </td><td> <input type="radio" name="lastsort" id="%id.lastsortup" value="up" checked><span style="font-size:x-small;color:#555753;">%loc!Up!</span><br> <input type="radio" name="lastsort" id="%id.lastsortdown" value="down"><span style="font-size:x-small;color:#555753;">%loc!Down!</span> </td> </tr></table> </td> </tr></table> </div>',onclick:t.SpreadsheetControlSortOnclick}),this.editor.SettingsCallbacks.sort={save:t.SpreadsheetControlSortSave,load:t.SpreadsheetControlSortLoad},this.tabnums.audit=this.tabs.length,this.tabs.push({name:"audit",text:"Audit",html:'<div id="%id.audittools" style="display:none;"> <div style="%tbt."> </div></div>',view:"audit",onclick:function(e){var o,i,n=t.LocalizeString,r='<table cellspacing="0" cellpadding="0" style="margin-bottom:10px;"><tr><td style="font-size:small;padding:6px;"><b>'+n("Audit Trail This Session")+":</b><br><br>",a=e.sheet.changes.stack,s=e.sheet.changes.tos;for(o=0;o<a.length;o++)for(o==s+1&&(r+='<br></td></tr><tr><td style="font-size:small;background-color:#EEE;padding:6px;">'+n("UNDONE STEPS")+":<br>"),i=0;i<a[o].command.length;i++)r+=t.special_chars(a[o].command[i])+"<br>";var l=function(e){if("string"==typeof e)return e;if(!e)return"null";if("object"==typeof e){l.check||(l.check=new Array);for(var t=0,o=l.check.length;o>t;++t)if(l.check[t]==e)return"{}";l.check.push(e)}var o="",i="undefined"==typeof e.length?1:0,n="";for(var r in e)i&&(o="'"+r+"':"),n+="string"==typeof e[r]?o+"'"+e[r]+"',":"object"==typeof e[r]?o+l(e[r])+",":o+e[r]+",";return"object"==typeof e&&l.check.pop(),i?"{"+n.slice(0,-1)+"}":"["+n.slice(0,-1)+"]"};if("undefined"!=typeof t.debug_log)for(var c in t.debug_log)r+=l(t.debug_log[c])+"<br>";e.views.audit.element.innerHTML=r+"</td></tr></table>",t.CmdGotFocus(!0)},onclickFocus:!0}),this.views.audit={name:"audit",divStyle:"border:1px solid black;overflow:auto;",html:"Audit Trail"},this.tabnums.comment=this.tabs.length,this.tabs.push({name:"comment",text:"Comment",html:'<div id="%id.commenttools" style="display:none;"><table cellspacing="0" cellpadding="0"><tr><td><textarea id="%id.commenttext" style="font-size:small;height:32px;width:600px;overflow:auto;" onfocus="%s.CmdGotFocus(this);"></textarea></td><td style="vertical-align:top;"> <input type="button" value="%loc!Save!" onclick="%s.SpreadsheetControlCommentSet();" style="font-size:x-small;"></td></tr></table></div>',view:"sheet",onclick:t.SpreadsheetControlCommentOnclick,onunclick:t.SpreadsheetControlCommentOnunclick}),this.tabnums.names=this.tabs.length,this.tabs.push({name:"names",text:"Names",html:'<div id="%id.namestools" style="display:none;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;padding-right:24px;"> <div style="%tbt.">%loc!Existing Names!</div> <select id="%id.nameslist" size="1" onchange="%s.SpreadsheetControlNamesChangedName();" onfocus="%s.CmdGotFocus(this);"><option selected>[New]</option></select> </td> <td style="vertical-align:top;padding-right:6px;"> <div style="%tbt.">%loc!Name!</div> <input type="text" id="%id.namesname" style="font-size:x-small;width:75px;" onfocus="%s.CmdGotFocus(this);"> </td> <td style="vertical-align:top;padding-right:6px;"> <div style="%tbt.">%loc!Description!</div> <input type="text" id="%id.namesdesc" style="font-size:x-small;width:150px;" onfocus="%s.CmdGotFocus(this);"> </td> <td style="vertical-align:top;padding-right:6px;"> <div style="%tbt.">%loc!Value!</div> <input type="text" id="%id.namesvalue" width="16" style="font-size:x-small;width:100px;" onfocus="%s.CmdGotFocus(this);"> </td> <td style="vertical-align:top;padding-right:12px;width:100px;"> <div style="%tbt.">%loc!Set Value To!</div> <input type="button" id="%id.namesrangeproposal" value="A1" onclick="%s.SpreadsheetControlNamesSetValue();" style="font-size:x-small;"> </td> <td style="vertical-align:top;padding-right:6px;"> <div style="%tbt."> </div> <input type="button" value="%loc!Save!" onclick="%s.SpreadsheetControlNamesSave();" style="font-size:x-small;"> <input type="button" value="%loc!Delete!" onclick="%s.SpreadsheetControlNamesDelete()" style="font-size:x-small;"> </td> </tr></table></div>',view:"sheet",onclick:t.SpreadsheetControlNamesOnclick,onunclick:t.SpreadsheetControlNamesOnunclick}),this.tabnums.clipboard=this.tabs.length,this.tabs.push({name:"clipboard",text:"Clipboard",html:'<div id="%id.clipboardtools" style="display:none;"> <table cellspacing="0" cellpadding="0"><tr> <td style="vertical-align:top;padding-right:24px;"> <div style="%tbt."> </div> </td> </tr></table></div>',view:"clipboard",onclick:t.SpreadsheetControlClipboardOnclick,onclickFocus:"clipboardtext"}),this.views.clipboard={name:"clipboard",divStyle:"overflow:auto;",html:' <div style="font-size:x-small;padding:5px 0px 10px 0px;"> <b>%loc!Display Clipboard in!:</b> <input type="radio" id="%id.clipboardformat-tab" name="%id.clipboardformat" checked onclick="%s.SpreadsheetControlClipboardFormat(\'tab\');"> %loc!Tab-delimited format! <input type="radio" id="%id.clipboardformat-csv" name="%id.clipboardformat" onclick="%s.SpreadsheetControlClipboardFormat(\'csv\');"> %loc!CSV format! <input type="radio" id="%id.clipboardformat-scsave" name="%id.clipboardformat" onclick="%s.SpreadsheetControlClipboardFormat(\'scsave\');"> %loc!SocialCalc-save format! </div> <input type="button" value="%loc!Load SocialCalc Clipboard With This!" style="font-size:x-small;" onclick="%s.SpreadsheetControlClipboardLoad();"> <input type="button" value="%loc!Clear SocialCalc Clipboard!" style="font-size:x-small;" onclick="%s.SpreadsheetControlClipboardClear();"> <br> <textarea id="%id.clipboardtext" style="font-size:small;height:350px;width:800px;overflow:auto;" onfocus="%s.CmdGotFocus(this);"></textarea>'} |
| 13 | },t.SpreadsheetControl.prototype.InitializeSpreadsheetControl=function(e,o,i,n){return t.InitializeSpreadsheetControl(this,e,o,i,n)},t.SpreadsheetControl.prototype.DoOnResize=function(){return t.DoOnResize(this)},t.SpreadsheetControl.prototype.SizeSSDiv=function(){return t.SizeSSDiv(this)},t.SpreadsheetControl.prototype.ExecuteCommand=function(e,o){return t.SpreadsheetControlExecuteCommand(this,e,o)},t.SpreadsheetControl.prototype.CreateSheetHTML=function(){return t.SpreadsheetControlCreateSheetHTML(this)},t.SpreadsheetControl.prototype.CreateSpreadsheetSave=function(e){return t.SpreadsheetControlCreateSpreadsheetSave(this,e)},t.SpreadsheetControl.prototype.DecodeSpreadsheetSave=function(e){return t.SpreadsheetControlDecodeSpreadsheetSave(this,e)},t.SpreadsheetControl.prototype.CreateCellHTML=function(e){return t.SpreadsheetControlCreateCellHTML(this,e)},t.SpreadsheetControl.prototype.CreateCellHTMLSave=function(e){return t.SpreadsheetControlCreateCellHTMLSave(this,e)},t.SpreadsheetControl.prototype.ParseSheetSave=function(e){return this.sheet.ParseSheetSave(e)},t.SpreadsheetControl.prototype.CreateSheetSave=function(){return this.sheet.CreateSheetSave()},t.InitializeSpreadsheetControl=function(e,o,i,n,r){var a,s,l,c,u,d,h,p,f=t.Constants,m=t.LocalizeString,g=t.LocalizeSubstrings,v=e.tabs,b=e.views;for(e.requestedHeight=i,e.requestedWidth=n,e.requestedSpaceBelow=r,"string"==typeof o&&(o=document.getElementById(o)),null==o&&alert("SocialCalc.SpreadsheetControl not given parent node."),e.parentNode=o,e.spreadsheetDiv=document.createElement("div"),e.SizeSSDiv(),s=o.firstChild;null!=s;s=o.firstChild)o.removeChild(s);for(a="<div>",a+='<div style="'+e.tabbackground+'"><table cellpadding="0" cellspacing="0"><tr>',l=0;l<v.length;l++)a+=' <td id="%id.'+v[l].name+'tab" style="'+(0==l?e.tabselectedCSS:e.tabplainCSS)+'" onclick="%s.SetTab(this);">'+m(v[l].text)+"</td>";for(a+=" </tr></table></div>",a+='<div style="'+e.toolbarbackground+'padding:12px 10px 10px 4px;">',l=0;l<v.length;l++)a+=v[l].html;a+="</div>",a+="</div>",e.currentTab=0;for(d in e.tabreplacements)a=a.replace(e.tabreplacements[d].regex,e.tabreplacements[d].replacement);a=a.replace(/\%s\./g,"SocialCalc."),a=a.replace(/\%id\./g,e.idPrefix),a=a.replace(/\%tbt\./g,e.toolbartext),a=a.replace(/\%img\./g,e.imagePrefix),a=g(a),e.spreadsheetDiv.innerHTML=a,o.appendChild(e.spreadsheetDiv),e.Buttons={button_undo:{tooltip:"Undo",command:"undo"},button_redo:{tooltip:"Redo",command:"redo"},button_copy:{tooltip:"Copy",command:"copy"},button_cut:{tooltip:"Cut",command:"cut"},button_paste:{tooltip:"Paste",command:"paste"},button_pasteformats:{tooltip:"Paste Formats",command:"pasteformats"},button_lock:{tooltip:"Lock Cell",command:"lock"},button_unlock:{tooltip:"Unlock Cell",command:"unlock"},button_delete:{tooltip:"Delete Cell Contents",command:"delete"},button_filldown:{tooltip:"Fill Down",command:"filldown"},button_fillright:{tooltip:"Fill Right",command:"fillright"},button_movefrom:{tooltip:"Set/Clear Move From",command:"movefrom"},button_movepaste:{tooltip:"Move Paste",command:"movepaste"},button_moveinsert:{tooltip:"Move Insert",command:"moveinsert"},button_alignleft:{tooltip:"Align Left",command:"align-left"},button_aligncenter:{tooltip:"Align Center",command:"align-center"},button_alignright:{tooltip:"Align Right",command:"align-right"},button_borderon:{tooltip:"Borders On",command:"borderon"},button_borderoff:{tooltip:"Borders Off",command:"borderoff"},button_swapcolors:{tooltip:"Swap Colors",command:"swapcolors"},button_merge:{tooltip:"Merge/Unmerge Cells",command:"merge"},button_insertrow:{tooltip:"Insert Row Before",command:"insertrow"},button_insertcol:{tooltip:"Insert Column Before",command:"insertcol"},button_deleterow:{tooltip:"Delete Row",command:"deleterow"},button_deletecol:{tooltip:"Delete Column",command:"deletecol"},button_hiderow:{tooltip:"Hide Row",command:"hiderow"},button_hidecol:{tooltip:"Hide Column",command:"hidecol"},button_recalc:{tooltip:"Recalculate",command:"recalc"}};for(h in e.Buttons)p=document.getElementById(e.idPrefix+h),p?(p.style.border="1px solid "+f.ISCButtonBorderNormal,p.title=m(e.Buttons[h].tooltip),t.ButtonRegister(e.editor,p,{normalstyle:"border:1px solid "+f.ISCButtonBorderNormal+";background-color:"+f.ISCButtonNormalBackground+";",hoverstyle:"border:1px solid "+f.ISCButtonBorderHover+";background-color:"+f.ISCButtonHoverBackground+";",downstyle:"border:1px solid "+f.ISCButtonBorderDown+";background-color:"+f.ISCButtonDownBackground+";"},{MouseDown:t.DoButtonCmd,command:e.Buttons[h].command})):alert("Button "+(e.idPrefix+h)+" missing");e.formulabarDiv=document.createElement("div"),e.formulabarDiv.innerHTML='<input type="text" size="60" value=""> ',e.spreadsheetDiv.appendChild(e.formulabarDiv);new t.InputBox(e.formulabarDiv.firstChild,e.editor);for(h in e.formulabuttons)p=document.createElement("img"),p.id=e.idPrefix+h,p.src=(e.formulabuttons[h].skipImagePrefix?"":e.imagePrefix)+e.formulabuttons[h].image,p.style.verticalAlign="middle",p.style.border="1px solid #FFF",p.style.marginLeft="4px",p.title=m(e.formulabuttons[h].tooltip),t.ButtonRegister(e.editor,p,{normalstyle:"border:1px solid #FFF;backgroundColor:#FFF;",hoverstyle:"border:1px solid #CCC;backgroundColor:#FFF;",downstyle:"border:1px solid #000;backgroundColor:#FFF;"},{MouseDown:e.formulabuttons[h].command,Disabled:function(){return e.editor.ECellReadonly()}}),e.formulabarDiv.appendChild(p);var y=$("<input id='searchbarinput' value='' placeholder='Search sheet…'>"),C=$("<span id='searchbar'></span>");C.append("<div id='searchstatus'></div>"),C.append(y);for(h in e.findbuttons)p=document.createElement("img"),p.id=e.idPrefix+h,p.src=e.imagePrefix+e.findbuttons[h].image,p.style.verticalAlign="middle",p.style.border="1px solid #FFF",p.title=m(e.findbuttons[h].tooltip),t.ButtonRegister(e.editor,p,{normalstyle:"border:1px solid #FFF;backgroundColor:#FFF;",hoverstyle:"border:1px solid #CCC;backgroundColor:#FFF;",downstyle:"border:1px solid #000;backgroundColor:#FFF;"},{MouseDown:e.findbuttons[h].command,Disabled:function(){return!1}}),C[0].appendChild(p);for(y.on("input",t.SpreadsheetControl.FindInSheet),y.on("focus",function(){t.Keyboard.passThru=!0}),y.on("blur",function(){t.Keyboard.passThru=!1}),y.keyup(function(e){13==e.keyCode&&(e.shiftKey?t.SpreadsheetControl.SearchUp():t.SpreadsheetControl.SearchDown())}),e.formulabarDiv.appendChild(C[0]),l=0;l<v.length;l++)v[l].oncreate&&v[l].oncreate(e,v[l].name);t.CalculateSheetNonViewHeight(e),e.viewheight=e.height-e.nonviewheight,e.editorDiv=e.editor.CreateTableEditor(e.width,e.viewheight);var w=document.createElement("div");w.id="te_appView",w.appendChild(e.editorDiv),e.editorDiv=w;var x=document.createElement("div");x.id="te_formData",x.style.display="none",e.editorDiv.appendChild(x),e.spreadsheetDiv.appendChild(e.editorDiv),e.formDataViewer=new t.SpreadsheetViewer("te_FormData-"),e.formDataViewer.InitializeSpreadsheetViewer(x.id,180,0,200),e.formDataViewer.editor.ignoreRender=!0;for(c in b){a=b[c].html;for(d in b[c].replacements)a=a.replace(b[c].replacements[d].regex,b[c].replacements[d].replacement);a=a.replace(/\%s\./g,"SocialCalc."),a=a.replace(/\%id\./g,e.idPrefix),a=a.replace(/\%tbt\./g,e.toolbartext),a=a.replace(/\%img\./g,e.imagePrefix),u=document.createElement("div"),t.setStyles(u,b[c].divStyle),u.style.display="none",u.style.width=e.width+"px",u.style.height=e.viewheight+"px",u.id=e.idPrefix+b[c].name+"view",a=g(a),u.innerHTML=a,e.spreadsheetDiv.appendChild(u),b[c].element=u,b[c].oncreate&&b[c].oncreate(e,b[c])}if(b.sheet={name:"sheet",element:e.editorDiv},e.statuslineDiv=document.createElement("div"),e.statuslineDiv.style.cssText=e.statuslineCSS,e.statuslineDiv.style.height=e.statuslineheight-(e.statuslineDiv.style.paddingTop.slice(0,-2)-0)-(e.statuslineDiv.style.paddingBottom.slice(0,-2)-0)+"px",e.statuslineDiv.id=e.idPrefix+"statusline",e.spreadsheetDiv.appendChild(e.statuslineDiv),e.spreadsheetDiv.addEventListener)e.spreadsheetDiv.addEventListener("mousedown",function(){t.SetSpreadsheetControlObject(e)},!1),e.spreadsheetDiv.addEventListener("mouseover",function(){t.SetSpreadsheetControlObject(e)},!1);else{if(!e.spreadsheetDiv.attachEvent)throw t.Constants.s_BrowserNotSupported;e.spreadsheetDiv.attachEvent("onmousedown",function(){t.SetSpreadsheetControlObject(e)}),e.spreadsheetDiv.attachEvent("onmouseover",function(){t.SetSpreadsheetControlObject(e)})}},t.CalculateSheetNonViewHeight=function(e){e.nonviewheight=e.statuslineheight;for(var t=0;t<e.spreadsheetDiv.childNodes.length;t++)"SocialCalc-statusline"!=e.spreadsheetDiv.childNodes[t].id&&(e.nonviewheight+=e.spreadsheetDiv.childNodes[t].offsetHeight)},t.LocalizeString=function(e){var o=t.LocalizeStringList[e];return o||(o=t.Constants["s_loc_"+e.toLowerCase().replace(/\s/g,"_").replace(/\W/g,"X")]||e,t.LocalizeStringList[e]=o),o},t.LocalizeStringList={},t.LocalizeSubstrings=function(e){var o=t.LocalizeString;return e.replace(/%(loc|ssc)!(.*?)!/g,function(e,i,n){return"ssc"==i?t.Constants[n]||alert("Missing constant: "+n):o(n)})},t.GetSpreadsheetControlObject=function(){var e=null!=t.CurrentSpreadsheetControlObject?t.CurrentSpreadsheetControlObject:t.CurrentSpreadsheetViewerObject;return e?e:void 0},t.SetSpreadsheetControlObject=function(e){t.CurrentSpreadsheetControlObject=e,t.Keyboard.focusTable&&e&&(t.Keyboard.focusTable=e.editor)},t.DoOnResize=function(e){var t,o=e.views,i=e.SizeSSDiv();if(i){for(vname in o)t=o[vname].element,t.style.width=e.width+"px",t.style.height=e.height-e.nonviewheight+"px";e.editor.ResizeTableEditor(e.width,e.height-e.nonviewheight)}},t.SizeSSDiv=function(e){var o,i,n,r,a,s=10,l=10;return n=!1,o=t.GetViewportInfo(),i=t.GetElementPosition(e.parentNode),i.bottom=0,i.right=0,r=e.parentNode.style,r.marginTop&&(i.top+=r.marginTop.slice(0,-2)-0),r.marginBottom&&(i.bottom+=r.marginBottom.slice(0,-2)-0),r.marginLeft&&(i.left+=r.marginLeft.slice(0,-2)-0),r.marginRight&&(i.right+=r.marginRight.slice(0,-2)-0),a=e.requestedHeight||o.height-(i.top+i.bottom+l)-(e.requestedSpaceBelow||0),e.height!=a&&(e.height=a,e.spreadsheetDiv.style.height=a+"px",n=!0),a=e.requestedWidth||o.width-(i.left+i.right+s)||700,e.width!=a&&(e.width=a,e.spreadsheetDiv.style.width=a+"px",n=!0),e.spreadsheetDiv.style.position="relative",n},t.SetTab=function(e){var o,i,n,r,a,s,l,c={},u={},d=t.GetSpreadsheetControlObject(),h=d.tabs,p=d.views;if(o="string"==typeof e?e:e.id.slice(d.idPrefix.length,-3),d.editor.busy&&(!h[d.currentTab].view||"sheet"==h[d.currentTab].view))for(a=0;a<h.length;a++)if(h[a].name==o&&h[a].view&&"sheet"!=h[a].view)return;for(d.tabs[d.currentTab].onunclick&&d.tabs[d.currentTab].onunclick(d,d.tabs[d.currentTab].name),a=0;a<h.length;a++)i=h[a].name,c[i]=document.getElementById(d.idPrefix+i+"tab"),u[i]=document.getElementById(d.idPrefix+i+"tools"),i==o?(n=a,u[i].style.display="block",c[i].style.cssText=d.tabselectedCSS):(u[i].style.display="none",c[i].style.cssText=d.tabplainCSS);d.currentTab=n,h[n].onclick&&h[n].onclick(d,o);for(s in p)!h[n].view&&"sheet"==s||h[n].view==s?(p[s].element.style.display="block",r=s):p[s].element.style.display="none";h[n].onclickFocus?(l=h[n].onclickFocus,"string"==typeof l&&(l=document.getElementById(d.idPrefix+l),l.focus()),t.CmdGotFocus(l)):t.KeyboardFocus(),p[r].needsresize&&p[r].onresize&&(p[r].needsresize=!1,p[r].onresize(d,p[r])),"sheet"==r?(d.statuslineDiv.style.display="block",d.editor.ScheduleRender()):d.statuslineDiv.style.display="none"},t.SpreadsheetControlStatuslineCallback=function(e,t,o,i){var n,r,a=document.getElementById(i.statuslineid);switch(a&&(a.innerHTML=e.GetStatuslineString(t,o,i)),t){case"cmdendnorender":case"calcfinished":case"doneposcalc":if(n=document.getElementById(i.recalcid1),r=document.getElementById(i.recalcid2),!n||!r)break;"yes"==e.context.sheetobj.attribs.needsrecalc?(n.style.display="inline",r.style.display="inline"):(n.style.display="none",r.style.display="none")}},t.UpdateSortRangeProposal=function(e){var o=document.getElementById(t.GetSpreadsheetControlObject().idPrefix+"sortlist");o.options[0].text=e.range.hasrange?t.crToCoord(e.range.left,e.range.top)+":"+t.crToCoord(e.range.right,e.range.bottom):t.LocalizeString("[select range]")},t.LoadColumnChoosers=function(e){var o,i,n,r,a,s,l,c=t.LocalizeString;e.sortrange&&-1==e.sortrange.indexOf(":")?(i=t.Formula.LookupName(e.sheet,e.sortrange||""),"range"==i.type?(n=i.value.match(/^(.*)\|(.*)\|$/),o=n[1]+":"+n[2]):o="A1:A1"):o=e.sortrange;var u=t.ParseRange(o);s=document.getElementById(e.idPrefix+"majorsort"),l=s.selectedIndex,s.options.length=0,s.options[s.options.length]=new Option(c("[None]"),"");for(var r=u.cr1.col;r<=u.cr2.col;r++)a=t.rcColname(r),s.options[s.options.length]=new Option(c("Column ")+a,a);s.selectedIndex=l>1&&l<=u.cr2.col-u.cr1.col+1?l:1,s=document.getElementById(e.idPrefix+"minorsort"),l=s.selectedIndex,s.options.length=0,s.options[s.options.length]=new Option(c("[None]"),"");for(var r=u.cr1.col;r<=u.cr2.col;r++)a=t.rcColname(r),s.options[s.options.length]=new Option(a,a);s.selectedIndex=l>0&&l<=u.cr2.col-u.cr1.col+1?l:0,s=document.getElementById(e.idPrefix+"lastsort"),l=s.selectedIndex,s.options.length=0,s.options[s.options.length]=new Option(c("[None]"),"");for(var r=u.cr1.col;r<=u.cr2.col;r++)a=t.rcColname(r),s.options[s.options.length]=new Option(a,a);s.selectedIndex=l>0&&l<=u.cr2.col-u.cr1.col+1?l:0},t.CmdGotFocus=function(e){t.Keyboard.passThru=e},t.DoButtonCmd=function(e,o,i){t.DoCmd(i.element,i.functionobj.command)},t.DoCmd=function(e,o){var i,n,r,a,s,l,c,u,d,h,p,f,m,g,v,b,y,C,w,x,_,S=t.GetSpreadsheetControlObject(),k=S.editor;switch(o){case"undo":S.ExecuteCommand("undo","");break;case"redo":S.ExecuteCommand("redo","");break;case"fill-rowcolstuff":case"fill-text":for(r=o.substring(5),s=document.getElementById(S.idPrefix+r+"list"),s.length=0,a=0;a<t.SpreadsheetCmdTable[r].length;a++)s.options[a]=new Option(t.SpreadsheetCmdTable[r][a].t);o="changed-"+r;case"changed-rowcolstuff":case"changed-text":for(r=o.substring(8),s=document.getElementById(S.idPrefix+r+"list"),l=t.SpreadsheetCmdTable.slists[t.SpreadsheetCmdTable[r][s.selectedIndex].s],c=document.getElementById(S.idPrefix+r+"slist"),c.length=0,a=0;a<(l.length||0);a++)c.options[a]=new Option(l[a].t,l[a].s);return;case"ok-rowcolstuff":case"ok-text":r=o.substring(3),s=document.getElementById(S.idPrefix+r+"list"),c=document.getElementById(S.idPrefix+r+"slist"),i=t.SpreadsheetCmdTable[r][s.selectedIndex].c,n=c[c.selectedIndex].value,t.SpreadsheetControlExecuteCommand(e,i,n);break;case"ok-setsort":if(p=document.getElementById(S.idPrefix+"sortlist"),0==p.selectedIndex)S.sortrange=k.range.hasrange?t.crToCoord(k.range.left,k.range.top)+":"+t.crToCoord(k.range.right,k.range.bottom):k.ecell.coord+":"+k.ecell.coord;else{var T=p.options[p.selectedIndex].value;if("all"==T){var F=S.sheet.cells,E=-1,D=-1,P=-1,A=-1;for(var I in F){var M=t.coordToCr(I);(-1==P||M.row<P)&&(P=M.row),(-1==E||M.col<E)&&(E=M.col),(-1==A||M.row>A)&&(A=M.row),(-1==D||M.col>D)&&(D=M.col)}S.sortrange=t.crToCoord(E,P)+":"+t.crToCoord(D,A),p.options[p.selectedIndex].text+=" ("+S.sortrange+")"}else S.sortrange=p.options[p.selectedIndex].value}return f=document.getElementById(S.idPrefix+"sortbutton"),f.value=t.LocalizeString("Sort ")+S.sortrange,f.style.visibility="visible",t.LoadColumnChoosers(S),e&&e.blur&&e.blur(),void t.KeyboardFocus();case"dosort":if(S.sortrange&&-1==S.sortrange.indexOf(":")){if(g=t.Formula.LookupName(S.sheet,S.sortrange||""),"range"!=g.type)return;v=g.value.match(/^(.*)\|(.*)\|$/),m=v[1]+":"+v[2]}else m=S.sortrange;if("A1:A1"==m)return;u="sort "+m+" ",d=document.getElementById(S.idPrefix+"majorsort"),h=document.getElementById(S.idPrefix+"majorsortup"),u+=d.options[d.selectedIndex].value+(h.checked?" up":" down"),d=document.getElementById(S.idPrefix+"minorsort"),d.selectedIndex>0&&(h=document.getElementById(S.idPrefix+"minorsortup"),u+=" "+d.options[d.selectedIndex].value+(h.checked?" up":" down")),d=document.getElementById(S.idPrefix+"lastsort"),d.selectedIndex>0&&(h=document.getElementById(S.idPrefix+"lastsortup"),u+=" "+d.options[d.selectedIndex].value+(h.checked?" up":" down")),S.ExecuteCommand(u,"");break;case"merge":i=t.SpreadsheetCmdLookup[o]||"",n=t.SpreadsheetCmdSLookup[o]||"",S.ExecuteCommand(i,n),k.range.hasrange&&(k.MoveECell(t.crToCoord(k.range.left,k.range.top)),k.RangeRemove());break;case"movefrom":k.range2.hasrange?(S.context.cursorsuffix="",k.Range2Remove(),S.ExecuteCommand("redisplay","")):k.range.hasrange?(k.range2.top=k.range.top,k.range2.right=k.range.right,k.range2.bottom=k.range.bottom,k.range2.left=k.range.left,k.range2.hasrange=!0,k.MoveECell(t.crToCoord(k.range.left,k.range.top))):(k.range2.top=k.ecell.row,k.range2.right=k.ecell.col,k.range2.bottom=k.ecell.row,k.range2.left=k.ecell.col,k.range2.hasrange=!0),u=k.range2.hasrange?"":"off",f=document.getElementById(S.idPrefix+"button_movefrom"),f.src=S.imagePrefix+"movefrom"+u+".gif",f=document.getElementById(S.idPrefix+"button_movepaste"),f.src=S.imagePrefix+"movepaste"+u+".gif",f=document.getElementById(S.idPrefix+"button_moveinsert"),f.src=S.imagePrefix+"moveinsert"+u+".gif",k.range2.hasrange&&k.RangeRemove();break;case"movepaste":case"moveinsert":k.range2.hasrange&&(S.context.cursorsuffix="",i=o+" "+t.crToCoord(k.range2.left,k.range2.top)+":"+t.crToCoord(k.range2.right,k.range2.bottom)+" "+k.ecell.coord,S.ExecuteCommand(i,""),k.Range2Remove(),f=document.getElementById(S.idPrefix+"button_movefrom"),f.src=S.imagePrefix+"movefromoff.gif",f=document.getElementById(S.idPrefix+"button_movepaste"),f.src=S.imagePrefix+"movepasteoff.gif",f=document.getElementById(S.idPrefix+"button_moveinsert"),f.src=S.imagePrefix+"moveinsertoff.gif");break;case"swapcolors":b=S.sheet,y=b.GetAssuredCell(k.ecell.coord),x=b.attribs.defaultcolor?b.colors[b.attribs.defaultcolor]:"rgb(0,0,0)",_=b.attribs.defaultbgcolor?b.colors[b.attribs.defaultbgcolor]:"rgb(255,255,255)",C=y.color?b.colors[y.color]:x,C==_&&(C=""),w=y.bgcolor?b.colors[y.bgcolor]:_,w==x&&(w=""),S.ExecuteCommand("set %C color "+w+"%Nset %C bgcolor "+C,"");break;default:i=t.SpreadsheetCmdLookup[o]||"",n=t.SpreadsheetCmdSLookup[o]||"",S.ExecuteCommand(i,n)}e&&e.blur&&e.blur(),t.KeyboardFocus()},t.SpreadsheetCmdLookup={copy:"copy %C all",cut:"cut %C all",paste:"paste %C all",pasteformats:"paste %C formats",lock:"set %C readonly yes",unlock:"set %C readonly no","delete":"erase %C formulas",filldown:"filldown %C all",fillright:"fillright %C all",erase:"erase %C all",borderon:"set %C bt %S%Nset %C br %S%Nset %C bb %S%Nset %C bl %S",borderoff:"set %C bt %S%Nset %C br %S%Nset %C bb %S%Nset %C bl %S",merge:"merge %C",unmerge:"unmerge %C","align-left":"set %C cellformat left","align-center":"set %C cellformat center","align-right":"set %C cellformat right","align-default":"set %C cellformat",insertrow:"insertrow %C",insertcol:"insertcol %C",deleterow:"deleterow %C",deletecol:"deletecol %C",hiderow:"set %H hide yes",hidecol:"set %W hide yes",undo:"undo",redo:"redo",recalc:"recalc"},t.SpreadsheetCmdSLookup={borderon:"1px solid rgb(0,0,0)",borderoff:""},t.SpreadsheetControlExecuteCommand=function(e,o,i){var n=t.GetSpreadsheetControlObject(),r=n.editor,a={};a.P="%",a.N="\n",r.range.hasrange?(a.R=t.crToCoord(r.range.left,r.range.top)+":"+t.crToCoord(r.range.right,r.range.bottom),a.C=a.R,a.W=t.rcColname(r.range.left)+":"+t.rcColname(r.range.right),a.H=r.range.top+":"+r.range.bottom):r.ecell?(a.C=r.ecell.coord,a.R=r.ecell.coord+":"+r.ecell.coord,a.W=t.rcColname(t.coordToCr(r.ecell.coord).col),a.H=t.coordToCr(r.ecell.coord).row):(a.C="A1",a.R="A1:A1",a.W=t.rcColname(t.coordToCr("A1").col),a.H=t.coordToCr("A1").row),a.S=i,o=o.replace(/%C/g,a.C),o=o.replace(/%R/g,a.R),o=o.replace(/%N/g,a.N),o=o.replace(/%S/g,a.S),o=o.replace(/%W/g,a.W),o=o.replace(/%H/g,a.H),o=o.replace(/%P/g,a.P),r.EditorScheduleSheetCommands(o,!0,!1)},t.SpreadsheetControlCreateSheetHTML=function(e){var o,i,n,r="";return o=new t.RenderContext(e.sheet),i=document.createElement("div"),n=o.RenderSheet(null,{type:"html"}),i.appendChild(n),delete o,r=i.innerHTML,delete n,delete i,r},t.SpreadsheetControlCreateCellHTML=function(e,o,i){var n="",r=e.sheet.cells[o];return r?(n=void 0==r.displaystring?t.FormatValueForDisplay(e.sheet,r.datavalue,o,i||e.context.defaultHTMLlinkstyle):r.displaystring," "==n&&(n=""),n):""},t.SpreadsheetControlCreateCellHTMLSave=function(e,o,i){var n,r,a,s,l,c,u,d,h=[];for(d=o?t.ParseRange(o):{cr1:{row:1,col:1},cr2:{row:e.sheet.attribs.lastrow,col:e.sheet.attribs.lastcol}},n=d.cr1,r=d.cr2,h.push("version:1.0"),a=n.row;a<=r.row;a++)for(s=n.col;s<=r.col;s++)l=t.crToCoord(s,a),c=e.sheet.cells[l],c&&(u=void 0==c.displaystring?t.FormatValueForDisplay(e.sheet,c.datavalue,l,i||e.context.defaultHTMLlinkstyle):c.displaystring," "!=u&&h.push(l+":"+t.encodeForSave(u)));return h.push(""),h.join("\n")},t.SpreadsheetControl.DoFunctionList=function(){var e,o,i,n=t.Formula,r=t.Constants,a=r.function_classlist,s=t.GetSpreadsheetControlObject(),l=s.idPrefix+"function";if(i=document.getElementById(l+"dialog"),!i){for(n.FillFunctionInfo(),o='<table><tr><td><span style="font-size:x-small;font-weight:bold">%loc!Category!</span><br><select id="'+l+'class" size="'+a.length+'" style="width:120px;" onchange="SocialCalc.SpreadsheetControl.FunctionClassChosen(this.options[this.selectedIndex].value);">',e=0;e<a.length;e++)o+='<option value="'+a[e]+'"'+(0==e?" selected>":">")+t.special_chars(n.FunctionClasses[a[e]].name)+"</option>";o+='</select></td><td> </td><td id="'+l+'list"><span style="font-size:x-small;font-weight:bold">%loc!Functions!</span><br><select id="'+l+'name" size="'+a.length+'" style="width:240px;" onchange="SocialCalc.SpreadsheetControl.FunctionChosen(this.options[this.selectedIndex].value);" ondblclick="SocialCalc.SpreadsheetControl.DoFunctionPaste();">',o+=t.SpreadsheetControl.GetFunctionNamesStr("all"),o+='</td></tr><tr><td colspan="3"><div id="'+l+'desc" style="width:380px;height:80px;overflow:auto;font-size:x-small;">'+t.SpreadsheetControl.GetFunctionInfoStr(n.FunctionClasses[a[0]].items[0])+'</div><div style="width:380px;text-align:right;padding-top:6px;font-size:small;"><input type="button" value="%loc!Paste!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoFunctionPaste();"> <input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideFunctions();"></div></td></tr></table>';var c=document.createElement("div");c.id=l+"dialog",c.style.position="absolute";var u=t.GetViewportInfo(),d=t.GetElementPositionWithScroll(s.spreadsheetDiv);c.style.top=u.height/3-d.top+"px",c.style.left=u.width/3-d.left+"px",c.style.zIndex=100,c.style.backgroundColor="#FFF",c.style.border="1px solid black",c.style.width="400px",o='<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr><td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;"> %loc!Function List!</td><td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideFunctions();"> X </td></tr></table><div style="background-color:#DDD;">'+o+"</div>",o=t.LocalizeSubstrings(o),c.innerHTML=o,t.DragRegister(c.firstChild.firstChild.firstChild.firstChild,!0,!0,{MouseDown:t.DragFunctionStart,MouseMove:t.DragFunctionPosition,MouseUp:t.DragFunctionPosition,Disabled:null,positionobj:c},s.spreadsheetDiv),s.spreadsheetDiv.appendChild(c),i=document.getElementById(l+"name"),i.focus(),t.CmdGotFocus(i)}},t.SpreadsheetControl.GetFunctionNamesStr=function(e){var o,i,n=t.Formula,r="";for(i=n.FunctionClasses[e],o=0;o<i.items.length;o++)r+='<option value="'+i.items[o]+'"'+(0==o?" selected>":">")+i.items[o]+"</option>";return r},t.SpreadsheetControl.FillFunctionNames=function(e,o){var i,n,r=t.Formula;for(o.length=0,n=r.FunctionClasses[e],i=0;i<n.items.length;i++)o.options[i]=new Option(n.items[i],n.items[i]),0==i&&(o.options[i].selected=!0)},t.SpreadsheetControl.GetFunctionInfoStr=function(e){var o=t.Formula,i=o.FunctionList[e],n=t.special_chars,r="<b>"+e+"("+n(o.FunctionArgString(e))+")</b><br>";return r+=n(i[3])},t.SpreadsheetControl.FunctionClassChosen=function(e){var o=t.GetSpreadsheetControlObject(),i=o.idPrefix+"function",n=t.Formula;t.SpreadsheetControl.FillFunctionNames(e,document.getElementById(i+"name")),t.SpreadsheetControl.FunctionChosen(n.FunctionClasses[e].items[0])},t.SpreadsheetControl.FunctionChosen=function(e){var o=t.GetSpreadsheetControlObject(),i=o.idPrefix+"function";document.getElementById(i+"desc").innerHTML=t.SpreadsheetControl.GetFunctionInfoStr(e)},t.SpreadsheetControl.HideFunctions=function(){var e=t.GetSpreadsheetControlObject(),o=document.getElementById(e.idPrefix+"functiondialog");o.innerHTML="",t.DragUnregister(o),t.KeyboardFocus(),o.parentNode&&o.parentNode.removeChild(o)},t.SpreadsheetControl.DoFunctionPaste=function(){var e=t.GetSpreadsheetControlObject(),o=e.editor,i=document.getElementById(e.idPrefix+"functionname"),n=document.getElementById(e.idPrefix+"multilinetextarea"),r=i.value+"(";t.SpreadsheetControl.HideFunctions(),n?(n.value+=r,n.focus(),t.CmdGotFocus(n)):o.EditorAddToInput(r,"=")},t.SpreadsheetControl.DoMultiline=function(){var e,o,i,n=t.LocalizeSubstrings,r=(t.Constants,t.GetSpreadsheetControlObject()),a=r.editor,s=a.workingvalues,r=t.GetSpreadsheetControlObject(),l=r.idPrefix+"multiline";if(o=document.getElementById(l+"dialog"),!o){switch(a.state){case"start":s.ecoord=a.ecell.coord,s.erow=a.ecell.row,s.ecol=a.ecell.col,a.RangeRemove(),i=t.GetCellContents(a.context.sheetobj,s.ecoord);break;case"input":case"inputboxdirect":i=a.inputBox.GetText()}a.inputBox.element.disabled=!0,i=t.special_chars(i),e='<textarea id="'+l+'textarea" style="width:380px;height:120px;margin:10px 0px 0px 6px;">'+i+'</textarea><div style="width:380px;text-align:right;padding:6px 0px 4px 6px;font-size:small;">'+n('<input type="button" value="%loc!Set Cell Contents!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoMultilinePaste();"> <input type="button" value="%loc!Clear!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoMultilineClear();"> <input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideMultiline();"></div></div>');var c=document.createElement("div");c.id=l+"dialog",c.style.position="absolute";var u=t.GetViewportInfo(),d=t.GetElementPositionWithScroll(r.spreadsheetDiv);c.style.top=u.height/3-d.top+"px",c.style.left=u.width/3-d.left+"px",c.style.zIndex=100,c.style.backgroundColor="#FFF",c.style.border="1px solid black",c.style.width="400px",c.innerHTML='<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr><td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;">'+n(" %loc!Multi-line Input Box!")+'</td><td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideMultiline();"> X </td></tr></table><div style="background-color:#DDD;">'+e+"</div>",t.DragRegister(c.firstChild.firstChild.firstChild.firstChild,!0,!0,{MouseDown:t.DragFunctionStart,MouseMove:t.DragFunctionPosition,MouseUp:t.DragFunctionPosition,Disabled:null,positionobj:c},r.spreadsheetDiv),r.spreadsheetDiv.appendChild(c),o=document.getElementById(l+"textarea"),o.focus(),t.CmdGotFocus(o)}},t.SpreadsheetControl.HideMultiline=function(){var e=(t.Constants,t.GetSpreadsheetControlObject()),o=e.editor,i=document.getElementById(e.idPrefix+"multilinedialog");switch(i.innerHTML="",t.DragUnregister(i),t.KeyboardFocus(),i.parentNode&&i.parentNode.removeChild(i),o.state){case"start":o.inputBox.DisplayCellContents(null);break;case"input":case"inputboxdirect":o.inputBox.element.disabled=!1,o.inputBox.Focus()}},t.SpreadsheetControl.DoMultilineClear=function(){var e=t.GetSpreadsheetControlObject(),o=document.getElementById(e.idPrefix+"multilinetextarea");o.value="",o.focus()},t.SpreadsheetControl.DoMultilinePaste=function(){var e=t.GetSpreadsheetControlObject(),o=e.editor,i=o.workingvalues,n=document.getElementById(e.idPrefix+"multilinetextarea"),r=n.value;switch(t.SpreadsheetControl.HideMultiline(),o.state){case"start":i.partialexpr="",i.ecoord=o.ecell.coord,i.erow=o.ecell.row,i.ecol=o.ecell.col;break;case"input":case"inputboxdirect":o.inputBox.Blur(),o.inputBox.ShowInputBox(!1),o.state="start"}o.EditorSaveEdit(r)},t.SpreadsheetControl.DoLink=function(){var e,o,i,n,r,a,s=t.LocalizeString,l=(t.Constants,t.GetSpreadsheetControlObject()),c=l.editor,u=c.workingvalues,l=t.GetSpreadsheetControlObject(),d=l.idPrefix+"link";if(o=document.getElementById(d+"dialog"),!o){switch(c.state){case"start":u.ecoord=c.ecell.coord,u.erow=c.ecell.row,u.ecol=c.ecell.col,c.RangeRemove(),i=t.GetCellContents(c.context.sheetobj,u.ecoord);break;case"input":case"inputboxdirect":i=c.inputBox.GetText()}c.inputBox.element.disabled=!0,"'"==i.charAt(0)&&(i=i.slice(1));var h=t.ParseCellLinkText(i);i=t.special_chars(i),n=l.sheet.cells[c.ecell.coord],r=n&&n.textvalueformat?"":" checked",a=h.newwin?" checked":"",e='<div style="padding:6px 0px 4px 6px;"><span style="font-size:smaller;">'+s("Description")+'</span><br><input type="text" id="'+d+'desc" style="width:380px;" value="'+t.special_chars(h.desc)+'"><br><span style="font-size:smaller;">'+s("URL")+'</span><br><input type="text" id="'+d+'url" style="width:380px;" value="'+t.special_chars(h.url)+'"><br>',t.Callbacks.MakePageLink&&(e+='<span style="font-size:smaller;">'+s("Page Name")+'</span><br><input type="text" id="'+d+'pagename" style="width:380px;" value="'+t.special_chars(h.pagename)+'"><br><span style="font-size:smaller;">'+s("Workspace")+'</span><br><input type="text" id="'+d+'workspace" style="width:380px;" value="'+t.special_chars(h.workspace)+'"><br>'),e+=t.LocalizeSubstrings('<input type="checkbox" id="'+d+'format"'+r+'> <span style="font-size:smaller;">%loc!Set to Link format!</span><br><input type="checkbox" id="'+d+'popup"'+a+'> <span style="font-size:smaller;">%loc!Show in new browser window!</span></div><div style="width:380px;text-align:right;padding:6px 0px 4px 6px;font-size:small;"><input type="button" value="%loc!Set Cell Contents!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoLinkPaste();"> <input type="button" value="%loc!Clear!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.DoLinkClear();"> <input type="button" value="%loc!Cancel!" style="font-size:smaller;" onclick="SocialCalc.SpreadsheetControl.HideLink();"></div></div>');var p=document.createElement("div");p.id=d+"dialog",p.style.position="absolute";var f=t.GetViewportInfo(),m=t.GetElementPositionWithScroll(l.spreadsheetDiv);p.style.top=f.height/3-m.top+"px",p.style.left=f.width/3-m.left+"px",p.style.zIndex=100,p.style.backgroundColor="#FFF",p.style.border="1px solid black",p.style.width="400px",p.innerHTML='<table cellspacing="0" cellpadding="0" style="border-bottom:1px solid black;"><tr><td style="font-size:10px;cursor:default;width:100%;background-color:#999;color:#FFF;"> '+s("Link Input Box")+'</td><td style="font-size:10px;cursor:default;color:#666;" onclick="SocialCalc.SpreadsheetControl.HideLink();"> X </td></tr></table><div style="background-color:#DDD;">'+e+"</div>",t.DragRegister(p.firstChild.firstChild.firstChild.firstChild,!0,!0,{MouseDown:t.DragFunctionStart,MouseMove:t.DragFunctionPosition,MouseUp:t.DragFunctionPosition,Disabled:null,positionobj:p},l.spreadsheetDiv),l.spreadsheetDiv.appendChild(p),o=document.getElementById(d+"url"),o.focus(),t.CmdGotFocus(o)}},t.SpreadsheetControl.HideLink=function(){var e=(t.Constants,t.GetSpreadsheetControlObject()),o=e.editor,i=document.getElementById(e.idPrefix+"linkdialog");switch(i.innerHTML="",t.DragUnregister(i),t.KeyboardFocus(),i.parentNode&&i.parentNode.removeChild(i),o.state){case"start":o.inputBox.DisplayCellContents(null);break;case"input":case"inputboxdirect":o.inputBox.element.disabled=!1,o.inputBox.Focus()}},t.SpreadsheetControl.DoLinkClear=function(){var e=t.GetSpreadsheetControlObject(); |