XSL entry (transfer)

xiaoxiao2021-03-06  56

Good article in XSL entry

[Author: the universe of people] from this article you learned the most important thing is not just apply XSL style. When using an XML processor, the information in the XSL source document will be evaluated, rearranged, and then reassemble. We finally get a lovely version of XML data - but can be easily added, modified, and reordered flexible source information. This final product is called the result tree (RESULT TREE).

This is generated by a series of tests. Here is a simple example:

The first thing to explain is that the marker ended with "/" is empty. That is, the start of this type of marker does not take anything before the end of the marker. Similar examples in HTML are the tag. Since all information required for an image is included in a tag, there is no need to have end tag . The tissue XML document can accept empty markings, while the XSL style sheet must be an organization's good XML.

Let's go back to an example, it tells the XSL processor if you find a set of tag, you should separate the content and surrounded by

and . Or, if you want to show off your XSL knowledge, you can say "Add to the results tree."

This is a fairly simple test and is very typical. The content of the XML element is surrounded by performance information.

Now let's take a look at the complete example of the XSL style sheet written by the recipe.

Before I tell more XSL tags, I want to explain a problem that may be asked. Everyone knows that "P> itself in html is enough, then why should I use the endless marker?

Can someone answer? The answer is: There is no corresponding end tag, that part is not an organization's good XML, which will produce a fatal error. [Center] Section III: A XSL Style Table [/ Center] Below is a complete style sheet.

's fabulous

Eat for:

directions

ingredients

< / xsl: template>

The result will not give me any Design award, but it is an XSL that can work. This may only explain only the following commands:

The "/" of the first line tells the processor This node is applied to the root of the XML document. Thus, the commands in this section are the foundation of the results tree. The processor defendant puts the and tag at the beginning and end of the document, and then processes or prints all sub-elements. Because it is the root element, it means "print all things."

Now, if you consider a few seconds, you will feel a bit weird. If the roots of the process-children command passes the source code to the results tree, all nodes that match the template can work with the source code that has been processed. However, the problem is that the XSL has a set of rules that determine which content being passed to the results tree, the most important rule is that the most specific match will win. Obviously, the form of the element name is more specific than the root layer. Therefore, all templates match nodes will transcend rules of the roots.

Note how easy it is to add HTML tags with XML data. When the XSL processor sees those markers that are not in the XSL vocabulary, they will pass them to the results tree. If you spend some time, you may find huge potential. XSL can be used as a conversion language. Data stored in an XML file can be converted to another with a completely different tag. Also, information can be modified to work with XML applications that can correspond to a different set of marker sets.

And not only these, if people expect, the style sheet can open and close with the matching tag, which is a set of well-organized units. Very good, but there are restrictions.

[Center] Section II: Select XSL [/ Center] Simple Not fully met our request. For example, I want to cancel the contents of the tag when the tag appears. In this case, I don't have to worry about "DINNER" and "APPETIZER" on the front surface. I may also want to adjust the layout by inserting a large number of blank in the last Ingredient.

Like some of the advertising parties: All of this is possible - more. SL has a tool for matching elements with their father members or sub-members. It also allows a position to match. For example, a specific format can be applied to the first and last particular elements, and the like.

Now let us consider some more complex things, such as the task of sweating in the dream. I need a list of recipe names and their ingredients. Now, if my web page is not connected to the database, I have to write a query statement. Because I am not very familiar with SQL, I need to get the DBA help. But if you know XSL, I will get rid of these troubles.



The result is not magical. But there will be no problem in the Table marker. Obviously, I store information in XML, but I think it is best to take a closer look.

The first line is familiar, but simply matches the template. But the second line is somewhat different - each of the recipe elements that appear in the element list, until the tag. Then I started the HTML form, using the tag to output the contents of the Recipe_name element into the table unit. After closing the first table unit, things start cool. Next line () starts an additional nested loop, allowing me to output all Ingredient into the appropriate display information. The rest of the style sheet should be well understood.

But wait, I know you are thinking: "Is he said cool? What is this cool?"

The For-Each function is one of several programming features of XSL. There is also if-life and selection functions. These features allow anyone to easily manipulate the XML content in any manner (or at least a feasible manner). If you can achieve these features, it is cool.

[Center] Section 5: From Specification to Implementation [/ Center] Since you have seen some of the XML's features, then I want to propose a question: XML to these contents by separating the content into the well-organized and effective XML file What can't do it? As I am displayed in front, the data can be manipulated and then put it in the layout of your choice. Or data can be processed into a form that can be used by other applications. So, is there any other?

We will once again face the core of the extensibility. Once the data is defined, we can do anything you want to do. If we come to a time that can handle XML, spreadsheets, and performance programs, the same set of data can almost be used in any use.

But, hehe! This is still a dream.

We can only want the browser to implement these features, but we have no reason to optimize. Even if Tim Bray, XML's godfather also said that the Try to XSL can only be implemented after the CSS standard is fully implemented. Who knows when can I achieve it? And this is not the only problem.

XSL To exclude another barrier. The XSL specification has two distinct parts. The first part is the processing data structure we discussed here. Another part is a set of formatted objects for applying style. This part needs to do a lot of work. In my opinion, now I need a lot of people to do a lot. For example, there should be a command that is suitable for both screens and printouts. This specification will eventually be ultimately difficult to achieve, and end users are also difficult to implement this "unparalleled" attempt. But now, we can't do what - I can only pass our own happy little days, and I hope that my comrades who are responsible should be messy. Edit XML document online with XSL and ASP

[Author: the universe of people]

In this paper, a method of editing XML document data online is described herein. Since NetScape is relatively weak supporting XML, the processing of data must be performed on the server side. To edit the XML document, what you want to do is how to extract these data and display to visitors, XSL provides us with a good solution to our XML file. The following example is to display the XML document with the XSL style to the user to edit, and then submit the edited data to the server and update the data on the server. Here is an ASP (Active Server Pages) to complete our task.

First, load the XML document we want to edit, using Microsoft's document object model (Microsoft XMLDOM Object) and XSL, the XML document can be converted to the server side to the HTML file content that can be displayed on the client. Let's take a look at what we use the XML and XSL files. XML file: UserData.xml

Value> Mencius

Value>

Value> Male

Value>

Value> China Network Technology Development Company Beijing Branch

Value>

Value> 102 layers of Beijing Kerry Center

Value>

Value> 1391139136 *

Value>

Value> amxh@21cn.com

Value>

'

Www.knowsky.com

XSL file: UserData.xsl

User Information Edit:

Value-of select = "@ id" />

Value-of select = "@ id" />

Value-of select = "@ id" />

Value "/>


Value = "Complete Editing" />

The XSL file uses the XSL: for-each element to traverse the entire XML file, "ID" attributes for each "Field" element in the XML file, and the "ID" and "Name" of the HTML form text input box. Thus, the text input box of the HTML form shows the element value of the XML file. This file is responsible for the transformation of the XML document in the server side so that it can be displayed on various browsers.

The following is a key program that implements the function of opening and updating the XML document, and decides whether it is updated according to the submission of the form. It contains two functions, LoadXMLFile is responsible for loading and converting the XML files to be displayed; UpdateXML functions are responsible for updating XML files.

The EditUserData.asp program is as follows:

<%

'' ------------------------------------------------ -----------

'' Define Functions LoadXmlfile (), receive two parameters:

'' strXmlfile - XML ​​file path and file name

'' strxslfilee - path and file name of the XSL file

'' '

Www.knowsky.com

'' ------------------------------------------------ -----------

Function loadXMLFile (strxmlfile, strxslfile)

'' Declare Local Variables

DIM Objxml

DIM Objxsl

'' Instance XMLDOM objects to load an XML file.

Set objxml = server.createObject ("Microsoft.xmldom")

'' Turn off the file asynchronous load mode.

Objxml.async = false

'' Load XML file!

Objxml.Load (strXmlfile) 'instantiates the XMLDOM object to load the XSL file.

Set objxsl = server.createObject ("Microsoft.xmldom")

'' Turn off the file asynchronous load mode.

Objxsl.async = false

'' Load XSL file!

Objxsl.Load (strxslfile)

'' Using XMLDOM's TransformNode method, apply the XSL style sheet to the XML document and output it to the client.

Response.write (objxml.transformnode (objxsl))

END FUNCTION

'' ------------------------------------------------ ------------------

'' Function UpdateXML () Receives a parameter: strXmlfile - the path and file name of the XML file.

'' ------------------------------------------------ ------------------

Function updateXML (strXmlfile)

'' Declaration partial variable.

DIM Objdom

Dim objRoot

DIM Objfield

DIM X

'' Instance XMLDOM object.

Set objdom = Server.createObject ("Microsoft.xmldom")

'' Turn off the file asynchronous load mode.

Objdom.async = false

'' Load an XML file.

Objdom.Load Strxmlfile

'' Set the root element.

Set objRoot = objDom.documentelement

'' Traverse the Form collection and write the submitted data into the XML file.

For x = 1 to request.form.count

'' Check if the submitted data contains a button. If so, ignore this data.

IF INSTR (1, Request.Form.Key (x), "btn") = 0 THEN

'' Follow the XSL query mode to establish an objfield variable, corresponding to the elements of the form to the corresponding elements in the XML document [Field_

Value].

Set objfield = objRoot.selectsinglenode ("Field [@ ID = ''" & recommended.form.key (x) & "'] / field_

Value ")

'' Put the data submitted by the form and the node value in the XML document.

Objfield.text = request.form (x)

END IF

NEXT

'' Save the edited XML file.

Objdom.save strxmlfile

'' Release all references to objects.

Set objdom = Nothing

Set objRoot = Nothing

Set objfield = Nothing

'' Call the loadXmlfile function, display the new edited XML file with the UpdatedUserData.xsl style list to the client.

LoadXmlFile strXmlfile, server.mappath ("updatedUserData.xsl) End Function

'' Check if the form is successfully submitted, such as submitting, updating XML files; otherwise, go to the editing state.

IF Request.form ("btnsubmit") = "" ""

LoadxmlFile Server.mappath ("UserData.xml"), Server.MAppath ("UserData.xsl")

Else

UpdateXML Server.mappath ("UserData.xml")

END IF

%>

When the form is submitted, we use UpdatedUserData.xsl to display the data we just edited.

UpdatedUserData.xsl is as follows:

Updated user information is as follows:

Value-of select = "@ id" />

Value-of select = "field_

Value "/>

Value = "Return"

Onclick = "history.go (-1)" />

The above is just a simple example of XML cross-platform applications, combining specific needs, we can write more powerful programs to complete our more negative work. All programs are debugged in the Win98se PWS IE5.5 Netscape 4.75 Netscape 6 MSXML3.DLL environment.

Use XSL and ASP to retrieve and update XML file content

[Author: the universe of people]

With XML file storage data, you can realize a real cross-platform, which gives our data to achieve a lot of convenience. Examples of this article show you how to add, delete, and modify the XML files. For the convenience of the description, the "personal data" of everyone in this example is sometimes also recorded.

First, we list all the records of the XML file, then use the server-side ASP program and XSL style single file to display the XML file to the HTML file to display in any browser. Now suppose having a customer data file UserData.xml as follows:

Value> Zhang 3

Value>

Value> Male

Value>

Value> Beijing No. 999 Mailbox

Value>

Value> 100000

Value>

Value> 86-10-88886666

Value>

Value> zhangsan@examdomain.com

Value>

Value> Lee 4

Value>

Value> Women

Value>

Value> 11th, Block A, Huangpu Building, 1208 Huangpu District, Shanghai

Value>

Value> 200200

Value>

Value> 86-21-6666888

Value>

Value> Lisi@examdomain.com

Value>

Value> Yang Y / FIELD_

Value>

Value> Male

Value>

Value> God Carving Heroes Peach Foodo Island

Value>

Value> 888888

Value>

Value> 800-810-8080

Value>

Value> yangguo@examdomain.com

Value>

Value> Dragon Women

Value>

Value> Female

Value>

Value> God Carving Heroes of the ancient Musai

Value>

Value> 999999

Value>

Value> 800-810-9090

Value>

Value> xiaolongnv@examdomain.com

Value>

We write UserData.xsl style single files as follows:

Customer Data Sheet

Name

email

userdata.asp? mode = viewdail & email =

Value-of select = "Field [@ id = 'email'] / field_

Value "/>

Value-of select = "Field [@ ID = 'Name"] / Field_

Value "/>

Value-of select = "Field [@ id = 'email'] / field_

Value "/>


Add new record

The XSL style single file traverses the content of the entire XML file and uses HTML Table tag to display it. This allows the visitor to view the details of the customer by clicking the customer name, you can also add new customer information.

Below, we write UserData.asp programs to complete XML file conversion, data browsing, modification, deletion:

<%

'------------------------------------- ------------------

'Delete Record Function DeleteTail' Parameter Description: [Program Details Please refer to "Using ASP and XSL online editing XML file"]

'link address:

http://www.ccw.com.cn/htm/app/aprog/01_3_28_4.asp

'StrxmlFile - The XML file to be loaded.

'strxslfile - Displays the XSL style single file of the XML file.

'stremail - To delete the customer's email.

'------------------------------------- ------------------

Function deleteTail (Strxmlfile, StrxslFile, stremail)

DIM Objdom

Dim objRoot

DIM ObjNode

Set objxml = server.createObject ("Microsoft.xmldom")

Objxml.async = false

Objxml.Load Strxmlfile

Set objroot = objxml.documentelement

Set objNode = ObjRoot.selectsinglenode ("Personal Information" Field / Field_

Value = '"& stremail &"] ")

ObjRoot.removechild (ObjNode)

Objxml.save strXmlfile

Loadxmlfile strxmlfile, strxslfile

END FUNCTION

'------------------------------------- ------------------

'Update Record Function UpdatedTail

'------------------------------------- ------------------

Function UpdatedTail (Strxmlfile, StrxSLFILE, STREMAIL)

'Declare Local Variables.

DIM Objdom

Dim objRoot

DIM Objcontact

DIM Objfield

DIM STRNEWEMAIL

StrneWemail = Request.form ("Email")

Set objxml = server.createObject ("Microsoft.xmldom")

Objxml.async = false

Objxml.Load Strxmlfile

Set objroot = objxml.documentelement

Set objcontact = objRoot.selectsinglenode ("Personal Information)" Field / Field_

Value = '"& stremail &"] ")

For Each Objitem in Request.form

Set objfield = Objcontact.selectsinglenode ("Field [@ ID = '" & objitem & ") / field_

Value ")

Objfield.text = request.form (Objitem)

NEXT

Objxml.save strXmlfile

ViewDetail strxmlfile, strxslfile, strneWemailend Function

'------------------------------------- ------------------

'Show your personal details ViewDetail

'------------------------------------- ------------------

Function ViewDetail (Strxmlfile, StrxslFile, stremail)

DIM Objxml

DIM ObjNode

DIM Objxsl

Set objxml = server.createObject ("Microsoft.xmldom")

Objxml.async = false

Objxml.Load (strXmlfile)

Set objNode = Objxml.selectsinglenode ("Customer Data Sheet / Personal Information" [Field / Field_

Value = '"& stremail &"] ")

Set objxsl = server.createObject ("Microsoft.xmldom")

Objxsl.async = false

Objxsl.Load (strxslfile)

Response.write (ObjNode.TransformNode (Objxsl))

END FUNCTION

'------------------------------------- ------------------

'Show all information functions loadXMLFile

'------------------------------------- ------------------

Function loadXMLFile (strxmlfile, strxslfile)

DIM Objxml

DIM Objxsl

Set objxml = server.createObject ("Microsoft.xmldom")

Objxml.async = false

Objxml.Load (strXmlfile)

Set objxsl = server.createObject ("Microsoft.xmldom")

Objxsl.async = false

Objxsl.Load (strxslfile)

Response.write (objxml.transformnode (objxsl))

END FUNCTION

DIM STRMODE

DIM stres

Strmode = request.QueryString ("Mode")

STREMAIL = Request.QueryString ("email")

SELECT CASE STRMODE

Case "viewdetail"

ViewDetail Server.mappath ("UserData.xml"), Server.MAppath ("ViewDetail.xsl"), stremail

Case "editdetail"

ViewDetail Server.Mappath ("UserData.xml"), Server.MAppath ("EditDetail.xsl"), stremail

Case "UpdatedTail"

UpdatedTail Server.mappath ("UserData.xml"), Server.MAppath ("ViewDetail.xsl"), strestetable "deleteTail"

DeleteTail Server.mappath ("UserData.xml"), Server.Mappath ("UserData.xsl"), stremail

Case Else

LoadxmlFile Server.mappath ("UserData.xml"), Server.MAppath ("UserData.xsl")

End SELECT

%>

We can use the following files to complete the input of new customer information, file addNewData.htm as follows:

Customer Information Enter </ Title> </ head></p> <p><body bgcolor = "# 0099ff"></p> <p><form action = "processadd.asp" method = "post"></p> <p><h3> Please enter your customer information </ h3></p> <p>Name: <input type = "Text" ID = "Name =" Name "></p> <p>Sex: <input type = "text" ID = "Gender" Name = "Sex"></p> <p>Address: <input type = "text" id = "address" name = "address"></p> <p>Postal Code: <Input Type = "Id =" Postal Code "Name =" Postal Coding "></p> <p>Tel: <input type = "text" ID = "Phone" Name = "Phone"></p> <p>Email: <input type = "text" ID = "Email" Name = "Email"></p> <p><input type = "submit" id = "btnsub" name = "btnsub" value = "Fill, send"> </ form> </ body> </ html> After filling out the above form, submit to the data Handling program processAdd.asp, this program can determine if the userData.xml file exists, if there is no existence, establish a new file; otherwise add the submitted data to the userData.xml. Then displays the success and failure of the data saving according to the success of the submission.</p> <p>The ProcessAdd.asp program is as follows: <% '--------------------------------------- ------------------------- 'Add Data Function AddNewDataToxml' ---------------- -------------------------------------------------- - Function addNewdatatoXML (strFileName) Dim objDom Dim objRoot Dim objRecord Dim objField Dim objFieldvalue Dim objattID Dim objattTabOrder Dim objPI Dim blnFileExists Dim x Set objDom = server.CreateObject ( "Microsoft.XMLDOM") objDom.preserveWhiteSpace = True blnFileExists = objDom.Load (strFileName) If blnFileExists = True Then Set objRoot = objDom.documentElement Else Set objRoot = objDom.createElement ( "client information Statement") objDom.appendChild objRoot End If Set objRecord = objDom.createElement ( "personal information") objRoot.appendChild objRecord For x = 1 to request.form.count if INSTR (1, request.form.key (x), "btn") = 0 THEN SET OBJFIELD = ObjDom.createElement ("Field") set objattid = ObjDom.createAttribute (" ID ") objattid.text = request.form.key (x) objfield.setttributenode objattid set objattaborder = ObjDom.createAttri bute ( "taborder") objattTabOrder.Text = x objField.setAttributeNode objattTabOrder Set objFieldvalue = objDom.createElement ( "field_value") objFieldvalue.Text = Request.Form (x) objRecord.appendChild objField objField.appendChild objFieldvalue End If Next If blnFileExists = false then Set objPI = objDom.createProcessingInstruction ( "xml", "version = '1.0' encoding = 'gb2312'") objDom.insertBefore objPI, objDom.childNodes (0) End If objDom.save strFileName Set objDom = Nothing Set objRoot = Nothing set objRecord =</p> <p>Nothing Set objField = Nothing Set objFieldvalue = Nothing Set objattID = Nothing Set objattTabOrder = Nothing Set objPI = Nothing End Function On Error Resume Next addNewdatatoXML server.MapPath ( "Userdata.xml") If err.number <> 0 then Response.write ( <html> <body bgcolor = '# 0099ff'> <center> <font color = red> <b> The form you submit is not saved successfully, please re-submit !! </ b> <a href = 'JavaScript: History .go (-1) '> Click here to re-submit. </a> </ body> </ html> ") else response.write (" <html> <body bgcolor =' # 0099ff "> <center> < Font Color = Red> <b> The form you submit has been successfully saved !!! </ b></p> <p><a href='UserData.asp'> Click here to view the addition of customer information sheet </a> </ body> </ html> ") end if%> To this, we complete data to XML files to add, browse, and modify All the work deleted. Of course, you can sort all records according to the needs, just use the order-by attribute of the XSL: for-Each element. All programs are debugged under PWS IE5.5 and Netscape By. Quick conversion XML file via XSL</p> <p>[Author: small cupboard]</p> <p>XML can only focus on data and file formats, while the display work is handed over to the typographic style sheet.</p> <p>Type of style: CSS and XSL. Where XSL is ideal for XML. (Do not discuss CSS here!)</p> <p>Start switch now!</p> <p>XSL contains two parts: XSLT and XSL Formatting Object</p> <p>XSLT (XSL Transformations) A language for converting an XML file.</p> <p>XSL Formatting Object: A group of words used to format (typography).</p> <p>Step 1: Conversion</p> <p>The XSL processor first has to read XML tag and data through the analyzer (DOM or SAX) technology.</p> <p>DOM (Document Object Model) file object model. (XML applications often use DOM technology to access XML data files.)</p> <p>When the browser reads the XML tree structure with the data through the XML DOM object, the XML tree structure re-ranks a temporary numerical structure, which is called the result tree.</p> <p>After this result tree is generated, if new tags or data appear, it must be incorporated with the result tree.</p> <p>Step 2: Format Conversion</p> <p>The result tree is also a tree structure, and the data of the DOM technology can be used to access the results tree, and the data is displayed in node, and the location of a record style can be reserved.</p> <p>XSL Processing The program converts these data transitions (formatted) to another Well-Formed XML file (eg WML, HTML, VoiceXML, etc.).</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-82135.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="82135" 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.033</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 = 'ApT7lvQrSiUgAwD7Fy3rrL6z_2F5S6yfyo3a_2B4fcAEDo_2FCD3MLwl2qn9phrDJVGfz5Lhq3DgynaUJVWsY8ZA1_2Bkg_3D_3D'; 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>