[Modify] JS graphics report

xiaoxiao2021-03-06  14

#Region statement // --------------------------------------------- ------------------------- //// Modification: Li Wei (Nick.lee) /// js graphics report

// Time: 2005-3-17

// Boyorgril@msn.com// qq: 16503096 // Note: Please indicate the modified place, thank you // ------------------------- -------------------------------------------- # endregion

HTML:

test vml chart for version 1.0.1 </ title> <style> v /: * {behavior: URL (# default # VML)} </ style> <script language = "javascript" src = "vmlgraph1_0_1.js"> </ script> </ HEAD></p> <p><Body> <div id = TEST1> <script language = "javascript"> <! - var tmp = new array ();</p> <p>// Columnar graph VAR Chart = new verticalbarchart ();</p> <p>// Line map // var chart = new verticalLinechart ();</p> <p>Chart.text.font.size = 24; chart.text.font.style = fstbold; chart.shadow = true; chart.Container = test1; chart.initialise ();</p> <p>Var s = new series (); var label = new array ("Jan", "Feb", "Mar", "APR", "May", "Jun", "Jul", "AUG", "SEP", "OCT", "NOV", "DEC");</p> <p>For (var i = 0; i <label.Length; i ) {v = math.Round (Math.random () * 1000); TMP [Tmp.Length] = V; S.Adddata (Label [i], V );} s.Title = "Series 1"; s.color = "red"; chart.addseries (s);</p> <p>S = new series (); for (var i = 0; i <label.length; i ) {v = math.Round (Math.random () * 1000); S.Adddata (Label [i], v); } S.Title = "Series 2"; S.COLOR = "Green"; chart.addseries (s);</p> <p>S = new series (); for (var i = 0; i <label.length; i ) {v = math.Round (Math.random () * 1000); S.Adddata (Label [i], v); } S.Title = "SERIES 2"; S.Color = "blue"; chart.addseries (s); chart.draw ();</p> <p>// -> </ script> </ div> </ body> </ html></p> <p>JS:</p> <p>Var bstsingle = 0; // Chart border is single line var bstdouble = 1; // CHART border is double line var fstsolid = 0; // chart background solid fill var fstTexture = 1; // Chart Background material Filled var fstregular = "regular "// Font: Normal var fstitalic =" italic "; // font: Intragonal var fstbold =" bold "; // font: bold var atleft =" left "; // chart title Left align VAR atcenter =" center " ; // CHART title huena var Atright = "right"; // chart title right alignment</p> <p>/ / Define VML Chart base class Function graph () {this.text = new text (); this.border = new border (); this.width = 500; this.height = 300; this.Fill = new Fill () "This.Legend = new legend (); this.seriescollection = []; this.container = null; this.shadow = false; THIS.VMLOBJECT = NULL;}</p> <p>// Get a reference var_p = graph.prototype; // by the base class, CHART_P.INITIALISE = function () {if (this.container == null) return; var o; // Picture outside box VAR Group = Document.createElement ("v: group"); group.style.width = this.width "pt"; group.style.height = this.height "pt"; group.coordsize = this.width * 10 ", " this.Height * 10; group.id =" group1 ";</p> <p>// Add a background layer var vrect = document.createElement ("v: Rect"); vRect.Style.Width = (this.width * 10-100) "px"; vRect.Style.Height = this.Height * 10 "PX"; VRECT.COORDSIZE = "21600, 21600";</p> <p>Group.appendchild (vRect); o = vRect; // Set the border size vRect.Strokeweight = this.border.width; // Set the border color vRect.StrokeColor = this.border.color; // Set the background IF (this.fill .Style == fstSolid) {vRect.fillcolor = this.Fill.Color;}! else {if (this.Fill.background = null) vRect.style.backgroundImage = this.Fill.background; else vRect.fillcolor = this. Fill.color;} // border is double line IF (this.border.style == bstdouble) {var TMP = Document.createElement ("v: Rect"); tmp.style.width = (this.width * 10 -300) "PX"; tmp.style.Height = (this.Height * 10-200) "px"; tmp.style.top = "100px"; tmp.style.left = "100px"; TMP. strokecolor = this.border.color; if (this.fill.style == fstsolid) {tmp.fillcolor = this.fill.color;} else {if (this.Fill.Background! = null) TMP.Style.BackgroundImage = this.Fill.background; else tmp.fillcolor = this.Fill.Color;} var filltmp = document.createElement ( "v: fill"); filltmp.type = "Frame"; tmp.appendChild (filltmp); group.appendChild (TMP); o = tmp;}</p> <p>// Draw title Var vcaption = document.createElement ("v: textbox"); vcAption.style.fontsize = this.text.font.size "px"; vcAption.style.color = this.Text.font.color; VcAption.style.height = this.text.height "px"; vcAption.style.fontweight = this.text.fontweight = this.innerhtml = this.text.text; vcAption.Style.TextAlign = this.Text. Alignment;</p> <p>O.Appendchild (VcAption);</p> <p>// Draw Shadow IF (this.Shadow) {var vshadow = document.createElement ("v: shadow"); vshadow.on = "t"; vshadow.type = "single"; vshadow.color = "graytext"; vshadow .offset = "4px, 4px"; vRect.Appendchild (vshadow);} this.vmlobject = group; this.container.Appendchild (group);}; // draw specific graph_p.draw = function () {Alert "Base class is not able to instantiate specific data");</p> <p>// Add sequence _p.addseries = function (o) {var iCount = this.seriescollection.Length; if (o.title == null) o.title = "series" icount; this.seriescollection [icount] = O };</p> <p>// Value_p.maxs = function () {var max = 0; for (var i = 0; I <this.seriescollection.Length; i ) {IF (Max <this.seriescollection [i] .max ()) MAX = this.seriescollection [i] .max ();} return max;</p> <p>/ / Re-serve Object's TOSTRING method_P.TOString = function () {return "OGRAPH";</p> <p>// Define the VML Chart Border Class Function Border () {this.color = "Black"; this.style = bstsingle; this.width = 1;};</p> <p>// Define VML Chart Background Function Fill () {this.color = "White"; this.background = null; this.style = fstsolid;};</p> <p>/ / Define VML Chart Title Function Text () {this.alignment = atcenter; this.Height = 24; this.Font = New font (); this.text = "VML Chart Version 1.0";</p> <p>/ / Define VML Chart font class function font () {this.color = "black"; this.family = "arial"; this.size = 12; this.style = fstregular;};</p> <p>// Define the VML Chart map class Function legend () {this.font = new font ();</p> <p>/ / Define VML Chart Sequence Class Function Series () {this.color = Series.getColor (); this.title = null; this.all = [];}; // Get a color series.getColor = Function ) {RETURN</p> <p>RGB (" Math.Round (Math.random () * 255) " Math.Round (Math.rand (Math.Radom () * 255 ) ")";}; var _p = series.prototype; // increase specific data _P.adddata = function (sname, svalue, shref, stooltiptext) {var odata = new object (); odata.name = sname; oData.Value = sValue; oData.Href = sHref; if (sTooltipText == null || sTooltipText == "undefined") oData.TooltipText = "value of this item:" sValue; else oData.TooltipText = sTooltipText; var iCount = this.all.Length; this.all [iCount] = odata;}; // to ask the maximum value_p.max = function () {var max = 0; for (var i = 0; i <this.all .length; i ) {IF (this.all [i] .value> max) Max = this.all [i] .value;} return max;</p> <p>// Rear dash Object's TSTRING method_P.toString = function () {return "oseries";</p> <p>/ / Define VML Chart Time Series Function TimeSeries () {series.call (this);}; var _p = TimeSeries.Prototype = new series; // Add specific data _p.adddata = function (Stime, Svalue, Stype, Shref, stooltiptext) {var = new object (); var dt = new date (EVAL (STIME * 1000)); if (stype == "minute") {odata.name = dt.getHours () ":" DT.GETMINUTES ();} else if (stype == "hour") {odata.name = dt.GetHours ();} else if (stype == "day") {odata.name = evAl (Dt.getMonth () 1) "Month" DT.Getdate () "Day";} else} (stype == "month") {odata.name = dt.getYear () "Year" Eval (DT. GetMonth () 1) "Month";} else {odata.name = dt.getyear () "Year"}}}} odata.value = svalue; odata.href = shref; odata.tooltiptext = "This item is: " Svalue ", Time: " DT.Getyear () " Year " Eval (DT.GETMONTH () 1) " Month " DT.Getdate () " Day " Dt.GetHours () ":" DT.GETMINUTES () ":" Dt.getSeconds (); var iCount = this.all.length; this.all [iCount] = ODATA;};</p> <p>/ / Re-serve Object's TSTRING method_P.TOString = function () {return "otimeseries";</p> <p>/ / Define VML Chart Coordinate Eserts Function Axis () {this.color = "Black"; this.ln = 0; this.Numberformat = 0; this.prefix = null; this.suffix = null; this.spacing = 30 Id.width = 0; this.ShowPoint = 12;};</p> <p>// VerticalChart class, inherited graphfunction verticalchart () {graph.call (this); this.margin = new array (300, 100, 300, 200); this.axisx = new axis (); this.axisy = new axis ();}; var_p = VERTICALCHART.PROTIPE = New graph; // Painting coordinate _P.drawcoord = function (OCONTAINER) {this.AxiSy.ln = Eval (this.height * 10 - this.margin [3]) - this.margin [1 ] - 400; VAR VLINE = Document.createElement ("v: line"); vline.id = "idcoordy"; VLINE.FROM = this.margin [0] "," this.margin [1]; VLINE. To = this.margin [0] "," EVAL (this.Height * 10 - this.margin [3]); vline.style.zindex = 8; VLINE.Style.Position = "absolute"; Vline.StrokeColor = this.AxiSy.color; VLINE.STROKEWEIGHT = 1; var vStroke = Document.createElement ("v: stroke"); vStroke.startarrow = "classic";</p> <p>VLINE.APpendChild (vStroke); OContainer.Appendchild (VLINE);</p> <p>THIS.AXISx.ln = evAl (this.width * 10 - this.margin [0]) - this.margin [2] - 300; var Vline = document.createElement ("v: line"); VLINE.ID = " IDCOORDX "; VLINE.FROM = this.margin [0] ", " EVAL (this.height * 10 - this.margin [3]); VLINE.TO = EVAL (this.width * 10 - this.margin [ 2]) "" EVAL (this.height * 10 - this.margin [3]); VLINE.Style.zindex = 8; VLINE.StyLe.Position = "absolute"; Vline.StrokeColor = this.axisx. Color vline.strokeweight = 1;</p> <p>VAR vStroke = Document.createElement ("v: stroke"); vStroke.endarrow = "classic";</p> <p>Vline.Appendchild (vStroke); OContainer.Appendchild (VLINE);</p> <p>// Draw X-axis scale _p.drawlinex = function (OCONTAER) {var TotalPoint = this.seriescollection [0] .all.Length; var iCol = TotalPoint 1; var fcolwidth = math.fllor (this.axisx.ln / Icol); this.axisx.width = fcolwidth; var showpoint = this.axisx.showpoint, step = 1; if (TotalPoint> showpoint) {if (TotalPoint <showpoint * 2) showpoint = math.Round (3 * showpoint / 5 ); Step = Math.round (totalPoint / showPoint);} else showPoint = totalPoint; this.AxisX.showPoint = showPoint; var newLine, newStroke, newShape, newText; var px, ln; var y = eval (this.Height * 10 - this.margin [3]);</p> <p>For (var i = 1; i <= showpoint; i ) {ln = i * step; if (ln> totalpoint) Break; newline = document.createElement ("v: line"); px = this.margin [0] (i-1) * fcolwidth * step; newline.from = px "," y; newline.to = px "," evAl (y this.axisx.spacing); newline.style.zindex = NEWLINE.Style.Position = "absolute";</p> <p>Newstroke = document.createElement ("<v: stroke color = '" this.axisx.color ""); newline.Appendchild (newstroke);</p> <p>Ocontainer.Appendchild (newline);</p> <p>Newshape = document.createElement ("<v: shape style = 'position: absolute; left: evAl (PX-80) "; TOP: " </p> <p>Eval (Y this.axisx.spacing "; width: 200px; height: 150px; z-index: 8 'coordsize =' 21600, 21600 '</p> <p>FillColor = 'White'> </ v: shape> ");</p> <p>NEWTEXT = Document.createElement ("<v: textbox INSET = '0pt, 0pt, 0pt, 0pt'</p> <p>Style = 'font-size: 12px; v-text-anchor: Top-right-baseline; color: " this.AxiSy.color " "</ v: textbox>"); newText.innerHtml = this.seriescollection [0] .all [ln-1] .name; newshape.Appendchild (newtext); ocontainer.appendchild (newshape);}};</p> <p>// Draw Y-axis scale _p.drawliney = function (OCONTAER) {var maxdata = this.maxs (); maxdata = (4 - maxdata% 4) var showpoint = this.axisy.showpoint; var DCS = 1; for (VAR i = showpoint; i> 0; i -) {if (MaxData% i == 0) {dcs = i; this.axiiSy.showpoint = i; break;}} var newline, newstroke, newshape, newtext; Var py; var x = this.margin [0]; var FrowHeight = math.floor (this.axisy.ln / dcs); this.axisy.width = maxdata; // Y axis stores maximum</p> <p>For (var i = 0; i <= dcs; i ) {py = evAl (this.Height * 10 - this.margin [3]) - i * flowheight; if (i! = 0) {newline = document.createElement ("v: line"); newline.From = evacing "," py; newline.to = x "," py; newline.style.zindex = 8; newline .Style.Position = "absolute";</p> <p>Newstroke = Document.createElement ("<v: stroke color = '" this.axisy.color ""); newline.Appendchild (newstroke);</p> <p>Ocontainer.Appendchild (newline);</p> <p>Newshape = document.createElement ("<v: shape style = 'position: absolute; left: evAl (x-200) "; TOP: " </p> <p>EVAL (PY-50) "; Width: 200px; Height: 150px; Z-Index: 8 'Coordsize =' 21600, 21600 'FillColor =' White '> </ v: shape>");</p> <p>NEWTEXT = Document.createElement ("<v: textbox INSET = '0pt, 0pt, 0pt, 0pt'</p> <p>Style = 'font-size: 12px; v-text-anchor: Top-right-baseline; color: " this.axisy.color " "" </ v: textbox> "); newText.innerHtml = i * ( MaxData / DCS); newshape.Appendchild (newText); ocontainer.appendchild (newshape);}};</p> <p>{Var Arrseries = function (OCONTAER) {var arrseries = this.seriescollection; for (var i = 0; i <arrseries.length; i ) {var newRect = Document.createElement ("v: Rect") NewRect.Style.Left = evAl (this.width * 10 - this.margin [2] * 2) - 200; newRect.Style.top = this.margin [1] 200 i * 120; newRect.Style. Height = "100px"; newRect.style.Width = "100px"; newRect.FillColor = arrseries [i] .color; newRect.Strokeweight = "1"; newRect.StrokeColor = "white"; newRect.Style.zIndex = 10 Ocontainer.Appendchild (newRect);</p> <p>Var newshape = document.createElement ("<v: shape style = 'position: absolute; left: evAl (this.width * 10 -</p> <p>THISMARGIN [2] * 2 - 70) "; TOP:" EVAL (this.margin [1] 200 i * 120) "; width: 600px; height: 100px; z-index: 8 '</p> <p>Coordsize = '21600, 21600' FillColor = 'White'> </ v: shape> ");</p> <p>VAR newText = Document.createElement ("<v: textbox INSET = '0pt, 0pt, 0pt, 0pt'</p> <p>STYLE = 'font-size: " this.lend.font.size " px; v-text-anchor: top-right-baseline; color: " this.lend.font.color</p> <p> "; CURSOR: Default 'Title ='" arrseries [i] .title "'> </ v: Textbox>");</p> <p>NEWTEXT.INNNERHTML = "" arrseries [i] .title;</p> <p>Newshape.Appendchild (newText); OContainer.Appendchild (newshape);}}; // ------------------------------- -----------------------------------------------//vertical To the columnar graph, inherit the verticalChart () {VerticalChart (this);}; var _p = verticalbarchart.prototype = new verticalChart; // Heavy flower X-axis scale _p.drawlinex = function (Ocontainer) {var Totalpoint = this.seriescollection [0] .all.Length; var iCol = TotalPoint 1; var fcolwidth = math.floor (this.axisx.ln / icol); this.axisx.width = fcolwidth; var showpoint = this.axisx .ShowPoint, Step = 1; IF (TotalPoint> showpoint) {if (TotalPoint <showpoint * 2) showpoint = math.Round (3 * showpoint / 5); step = math.Round (TotalPoint / showpoint);} else showpoint = Totalpoint;</p> <p>THIS.AXISx.ShowPoint = showpoint; var newline, news; newshape, newtext; var px, ln; var y = evAl (this.height * 10 - this.margin [3]);</p> <p>For (var i = 1; i <= showpoint; i ) {ln = i * step; if (ln> totalpoint) Break; newline = document.createElement ("v: line"); px = this.margin [0] i * fcolwidth * step; newline.from = px "," y; newline.to = px "," evAl (y this.axisx.spacing); newline.style.zindex = 8; newline. Style.Position = "absolute";</p> <p>Newstroke = Document.createElement ("<v: stroke color = '" this.axisy.color ""); newline.Appendchild (newstroke);</p> <p>Ocontainer.Appendchild (newline);</p> <p>Newshape = document.createElement ("<v: shape style = 'position: absolute; left: evAl ((PX-FCOLWIDTH / 2) -50)</p> <p> "; TOP:" evacing "; width: 200px; Height: 150px; z-index: 8 'Coordsize =' 21600, 21600'fillcolor = 'White'> </ v : Shape> ");</p> <p>NEWTEXT = Document.createElement ("<v: textbox INSET = '0pt, 0pt, 0pt, 0pt'</p> <p>Style = 'font-size: 12px; v-text-anchor: Top-right-baseline; color: " this.AxiSy.color " "</ v: textbox>");</p> <p>NEWTEXT.INNNERHTML = this.seriescollection [0] .all [ln-1] .name; newshape.Appendchild (NewText);</p> <p>Ocontainer.appendchild (newshape);}};</p> <p>// Videos VerticalBarChart_p.draw = function () {var oContainer = this.VMLObject; this.AxisY.showPoint = 10; this.drawCoord (oContainer); this.drawLineX (oContainer); this.drawLineY (oContainer); this.drawSmallSeries (OCONTAINER); this.drawbar (OCONTAINER);</p> <p>// Data of VerticalBarchart_P.Drawbar = function (OCONTAER) {var arrseries = this.seriescollection; var fcolwidth, dcs; fcolwidth = this.axisx.width; dcs = this.axisy.ln / this.AxiSy.Width Var ivalueln, iSeriesln; iSeriesln = arrseries.length var barwidth = fcolwidth / (iSeriesln 1); var newshape = null; var newshape = null; var newshape = null; var newshape = null; var newshape = null; var newshape = null; var newshape = null; var newshape = null; var newshape = null; Var L, T, Barheight; for (var i = 0; iSeriesln; i ) {ivalueln = Arrseries [I] .all.length; for (var k = 0; k <ivalueln; k ) {BarHeight = DCS * EVAL (Arrseries [i] .all [k] .value) L = ev by (this.margin [0 ] k * fcolwidth i * barwidth barwidth / 2); t = evAl (this.height * 10 - this.margin [3] - barHeight); newshape = document.createElement ("<v: Rect style = 'position : Absolute; Left: " L "; TOP: " T "; Width: " Barwidth</p> <p> "PX; Height:" BarHeight "PX; Z-Index: 9; Border-Width: 0 'FillColor ='" Arrseries [i] .COLOR "'Title ='" arrseries [i] .all [k] .tooltiptext "'> </ v: Rect>");</p> <p>//Alart(this.axisx.width) oContainer.Appendchild (newshape);}}}; // --------------------------- -------------------------------------------------- / / -------------------------------------------------------------------------------------------- ---------------------------- // vertical line graphics, inherit the verticalChart class function verticallineChart () {VerticalChart.call (this); this.isdrawpoint = true;}; var _p = verticalLinechart.prototype = new verticalChart;</p> <p>// Draw verticalLineChart_p.draw = function () {if (this.border.style == 1) {this.margin = new Array (400, 200, 400, 300);}</p> <p>var oContainer = this.VMLObject; this.AxisY.showPoint = 10; this.drawCoord (oContainer); this.drawLineX (oContainer); this.drawLineY (oContainer); this.drawSmallSeries (oContainer); this.drawLine (oContainer); }</p> <p>// Data of VerticalLineChart_P.drawLine = Function (Ocontainer) {var arrseries = this.seriesCollection; var fcolwidth, dcs; fcolwidth = this.axisx.width; dcs = this.axisy.ln / this.axiSy.Width Var ivalueln, iSeriesln; iSeriesln = arrseries.length var Points = New Array (iSeriesln); Var L, T, Barheight; for (var i = 0; i <iSeriesln; i ) {ivalueln = arrseries [i] .all. Length; Points [i] = new array (); for (var k = 0; k <ivalueln; k ) {Barheight = DCS * EVAL (Arrseries [i] .all [k] .value) L = evAl (this. Margin [0] k * fcolwidth); t = evAl (this.height * 10 - this.margin [3] - barHeight); Points [i] [k] = L "," T;}} // painting PolyLine for (var i = 0; i <points.length; i ) {var newPolyLine = document.createElement ( "v: polyline"); newPolyLine.filled = false; newPolyLine.style.zIndex = 8; newPolyLine.style.position = "absolute"; newpolyline.strokecolor = arrseries [i] .color; newpolyline.strokeEight = "1.5pt"; for (var k = 0; k <pointx [i] .length; k ) {IF (k == 0 NewPolyline.Points = Points [i] [k]; else newpolyline .points = "" Points [i] [k]; if (this.isdrawpoint) {var newoval = document.createElement ("v: oval"); TMP = Points [i] [k] .split (", "); Newoval.style.zindex = 9; newoval.style.position =" absolute "; newoval.style.Left = TMP [0] -20; newoval.style.top = TMP [1] -20; newoval.style .width = 40; newoval.style.Height = 40; newoval.StrokeColor = arrseries [i] .color; newoval.fillcolor = arrseries [i] .color; newoval.title =</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-46417.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="46417" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.039</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'n1Ju1ACC53edcGDO6PpQT9IMfrnITXxhb09MjO5E7iBOz2tIpfarn98vzOeHvy0mFt_2B_2FBqMXPz1yeFSu'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>