Master AJAX, Part 4: WEB response using DOM

xiaoxiao2021-04-11  1.8K+

Souce URL:

Like many web programmers, you may use HTML. HTML is the way the programmer began to deal with the web page; HTML is usually the last step in which they complete the application or site - adjust some layout, color or style. However, although HTML is often used, what happens when HTML is forwarded to the browser, and there is a misunderstanding. Before I analyze what you think may happen, I hope that you will be clear about the process of designing and serving the web page:

Some people (usually you!) Create HTML in a text editor or IDE. Then you upload HTML to a web server, such as Apache Httpd, and disclose it on the Internet or intranet. Users requested your web page with browsers such as Firefox or Safaria. The user's browser requests HTML to your server. The browser will present the page received from the server in graphics and text; the user sees and activates the web page.

This looks very foundation, but things will become interesting. In fact, the huge number of "stuff)" occurs between steps 4 and 5 is the focus of this article. The term "filler" is also very applicable because most programmers have never truly considered what happened to markers when the user browser requests the display tag.

Whether the browser just reads text in HTML and displays it? CSS? Especially when CSS is located outside the external file. JavaScript? It is also usually located in an external file. How does the browser handle these items, if the event handler, function, and style are mapped to this text tag?

Practice has proved that the answers to all these issues are Document Object Model. Therefore, less nonsense, directly study the DOM.

Web programmer and tag

For most programmers, their work is over when the web browser begins. That is to say, after putting an HTML file into the Directory of the web browser, you usually think it has been "completed", and (full of hope), you will not consider it again! When it is written, it is also a great goal; I hope that your taggers sides the browser, use a variety of version of CSS and JavaScript to display the content it should display, there is no mistake.

The problem is that this method limits the understanding of the truly happening in the browser. More importantly, it limits the ability to dynamically update, change, and reconstruct the web page with client JavaScript. Get rid of this restriction, so that your Web site has greater interactivity and creativity.

Programmers do

As a typical web programmer, you may start entering HTML, CSS, and even JavaScript after you start text editing and IDE. It is easy to think that these tags, selectors and properties are just a small task that makes the site correctly. However, at this point you need to expand your ideas and realize that you are organizing your content. Don't worry; I guarantee that this will not turn to label beauty, you have to recognize the true potential of the web page or a lecture of any other metamorphism. What you need to know is what role in the Web development.

Speaking of the appearance of the page, you can only mention suggestions. When you provide a CSS style sheet, users can override your style selection. When you provide a font size, the user browser can change these sizes for the visifison, or to reduce the proportion on large displays (with equivalent resolution). Even the colors and fonts you choose are also subject to fonts that the user display and the user installed on its system. Although doing do your design page style is very good, this is not your greatest impact on the web page. You absolutely control the structure of the web page. Your tag cannot be changed, users can't get tuned; their browser can only retrieve tags from your web server and display it (although the style is more in line with the user's taste rather than your own taste). But the page is organized, whether it is in this paragraph or other partitions, only by you separately. If you want to change your page (this is most of the most Ajax applications), you are working on the structure of the page. Although it is easy to change the color of a piece of text, adding text on existing pages or has a lot of things throughout the section. Regardless of how users design the style of this section, they are controlled by your organization.

What to do

Once you realize that your tag is truly related to the organization, you will see it again. Will not think that H1 causes the text to be a big name, black, bold, and will think that H1 is a title. How do users look at this issue and they use your CSS, their own CSS or the combination of both, this is a secondary consideration. Instead, we must realize that only tags can provide this level of organization; P is indicated in the paragraph, IMG represents images, divide the page into a section, and so on.

It should also be clear that style and behavior (event handler and JavaScript) are applied to the organization after things. The tag is ready to operate or design it. So, as you can save CSS in an external file of HTML, the tag of the tag is separated from its style, format, and behavior. Although you must use JavaScript to change the style or text style, it is more interesting to actually change your tag.

As long as your tag is only providing organization, framework for your page, you can stand in an invincible. Before entering a small step, you will understand how the browser accepts all the text organizations and transforms them into a super interesting thing, a set of objects, where each object can be changed, added, or deleted.

About other ideas for markers Edit: Is it wrong? Pure text is ideal for storage tags, but is not suitable for editing tags. The big way is to operate the web page tag using IDE, such as Microsoft® FrontPage®, or more Macromedia Dreamweaver or a more powerful point. These environments typically provide shortcuts and help to create a web page, especially when using CSS and JavaScript, both from the actual page tag. Many people still prefer to use ancient Notepad or VI (I admit me is also one of them), this is not tight. In any case, the end result is a text file full of tags. Text on the Internet: Good things have been said, the text is the best media of the document, such as HTML or CSS, which is transmitted thousands of times on the network. When I said that the browser indicates that the text is difficult, it is a visual graphic page that converts text to the user to the user. This doesn't matter how the browser actually retrieves the page from a web browser; in which case the text is still the best choice.

Advantages of text tag

Before discussing the web browser, it is worth considering why plain text is definitely the best choice for storage HTML. Do not consider excellent shortcomings, just recalling that HTML is sent to a web browser through the network (for simple, not considering cache, etc.). It's really no way to pass the text again. Binary objects, page graphical representations, reorganized tag blocks, etc., all all this is more difficult to pass network through network files. In addition, the browser also adds a bright color. Today's browser allows users to change text size, compact image, and download the CSS or JavaScript (most case), even more, which completely excludes the sending of any type of page graphic representation to the browser. However, the browser requires the original HTML so that it can apply any processing on the page in the browser instead of trusting the browser to process the task. Similarly, the CSS separates from JavaScript and separates CSS from HTML marking requirements to be easily separated format. Text files have become the best way to be the task again.

Last but equally, it is, remember, new standards (such as HTML 4.01 and XHTML 1.0 and 1.1) Commitment to separate content (data in the page) with representations and styles (usually applied by CSS applications). If the programmer wants to separate HTML with CSS, then forced the browser to retrieve some of the pages of each part of the bond page, this will lose most of these standards. Keeping these parts When they arrive at the browser, they have been separated so that the browser has unprecedented flexibility when you get HTML from the server.

To learn more about web browsers

For some web programmers, all content read in the previous article may be a funny story about your role in the web development process. However, the behavior of the browser, many of the most capable web designers and developers are usually not aware of the actual situation of "insider". I will talk about this section. Don't worry, the code is coming soon, but you want to make your encoded mood, because you really understand the exact behavior of the web browser is very important for your code correctly.

Disadvantages of text tag

As the text mark has an amazing advantage for designers and page creators, it also has quite shortcomings for browsers. Specifically, the browser is difficult to direct text tags to the user directly. Consider the following common browser tasks:

Based on element type, class, id, and its location in the HTML document, the CSS style (usually from multiple style sheets from external files) is applied to tags. Based on JavaScript code (usually located in an external file) to apply style and format to different parts of the HTML document. Change the value of the form field based on the JavaScript code. Based on JavaScript code, support visual effects, such as image flipping and image exchange.

The complexity is not to encode these tasks; each thing is quite easy. Complexity comes from a browser that actually implements a request action. If the tag is stored as text, for example, how to enter text (text-align: center) in the P element in the Center-Text class, how to implement it?

Add the inline style to the text? Apply the style to the HTML text in the browser and only keep the content or in the middle of the content? Apply an unmovable HTML, then apply the format after the event?

These very difficult problems are now very few reasons for writing browsers. (People who write browsers should accept the most sincere thanks)

Undoubtedly, plain text is not a good way to store browser HTML, although the text is the best solution for page tags. If you add JavaScript to change the ability to change the page structure, things become subtle. Should the browser restote the modified structure to disk? How can I keep the latest version of the document? Undoubtedly, text is not an answer. It is difficult to modify, it is very difficult to apply style and behavior, and the dynamic essence of the Web page today is very far away.

Help in tree view

The answer to this problem (at least the answer to the today's Web browser) is to use a tree structure to represent HTML. See Listing 1, this is a fairly simple and boring HTML page representing the tag of this article.

Listing 1. Simple HTML page in text tag

Trees, Trees, Everywhere </ title> </ head> <body> <h1> trees, trees, everywhere </ h1> <p> Welcome to a <em> really </ em > boring page. </ p> <div> come again soon. <img src = "com-again.gif" /> </ div> </ body> </ html></p> <p>The browser accepts this page and converts it to the tree structure, as shown in Figure 1.</p> <p>Figure 1. Tree view of the list 1</p> <p>In order to maintain the progress of this article, I did a little simplified. Experts from DOM or XML will realize that the blank has an impact of the document text represents and decomposes the way in the web browser tree structure. The skin's understanding will only make things ambiguous, so if you want to figure out the impact of the blank, it is best nothing; if you don't want it, you can continue to read, don't consider it. When it becomes a problem, you will understand everything you need.</p> <p>In addition to the actual tree background, it may first notice that everything in the tree contains an element with an outermost HTML, ie the HTML element begins. This is called a root element using the metaphor of the tree. So even if this is the bottom of the tree, when you view and analyze the tree, I usually start here. If it does work, you can put the entire tree down, but this does have some metaphor of the tree.</p> <p>The line out of the root represents the relationship between different marking parts. Head and body elements are children of HTML root elements; Title is a child of Head, while text "Trees, Trees, Everywhere" is Title's child. The whole tree is organized so until the browser obtains a structure similar to Figure 1.</p> <p>Some additional terms</p> <p>In order to follow the metaphor of the tree, Head and Body are called HTML branches (BRANCHES). The branch is because they have their own children. When arriving at the end of the tree, you will enter the main text, such as "Trees, Trees, Everywhere" and "Really"; these are often referred to as leaves because they have no children. You don't need to remember all of these terms, when you try to figure out the meaning of specific terms, as long as you think that the tree structure is much easier.</p> <p>Object value</p> <p>Since some basic terms are learned, you should now pay attention to the small rectangle containing the element name and text (Figure 1). Each rectangle is an object; the browser solves some text issues. By using an object to represent each part of the HTML document, you can easily change your organization, application style, allowing JavaScript to access documents, and so on.</p> <p>Object type and attribute</p> <p>Each possible type of tag has its own object type. For example, the elements in HTML are represented by the ELEMENT object type. The text in the document is represented by a text type, and the property is represented by Attribute type to use this class.</p> <p>So the web browser can not only use object models to represent documents (thus avoiding processing static text), but also use object types to immediately identify what is something. The HTML document is parsed and converted to an object collection, as shown in Figure 1, then a bracket and escape sequence (for example, using <indicating <indicating <, use> means>) or the like is no longer a problem. This makes the browser's work (at least after parsing the input HTML) easier. How to find something is element or attribute and determine how to handle this type of object, which is very simple.</p> <p>By using objects, web browsers can change the properties of these objects. For example, each element object has a parent element and a series of sub-elements. So add a new child element or text only needs to add a new sub-element to the child's sub-elements list. These objects also have a Style property, so the style of fast changing elements or text segments is very simple. For example, to change the height of the DIV using JavaScript, as shown below:</p> <p>Somediv.Style.height = "300px";</p> <p>In other words, the web browser uses object properties to easily change the appearance and structure of the tree. Compared with the browser, you must perform complex things that must be performed during the text, each change attribute or structure, you need a browser to rewrite static files, resolve and restrict on the screen. With an object, all this is solved.</p> <p>Now, spend some HTML documentation and tap it with a tree. Although this looks an unusual request (especially in such an article containing very little code), if you want to manipulate these trees, you need to be familiar with them.</p> <p>In this process, some weird things may be found. For example, consider the following:</p> <p>What happened attribute? Decompose the text of elements (such as EM and B)? Is incorrect structure (such as the HTML that is missing when the P mark is missing?</p> <p>Once you are familiar with these issues, you can better understand the following sections.</p> <p>Strictly sometimes good things</p> <p>If you try the practice i, you may find some potential problems in the tree view of the tag (if you don't practice, then listen to me!). In fact, some problems will be found in Listing 1 and Figure 1, first look at how the P element is decomposed. If you ask the usual web developer "What is the text content of P element", the most common answer will be "Welcome to a really boring web page.". If it is compared to Figure 1, this answer will be found (although logic) is incorrect.</p> <p>In fact, the P element has three different sub-objects, with no complete "Welcome to a really boring web page." Text. You will find part of the text, such as "Welcome to A" and "Boring Web Page", but not all. To understand this, remember that any content in the tag must be converted to some type of object.</p> <p>In addition, the order is insignificant! If the browser displays the correct object, but the display order is different from the order provided in HTML, then you can imagine how users will respond to a web browser? Paragraph clip in the middle of the page title and article title, and this is not the style when you organize documents yourself? Obviously, the browser must maintain the order of elements and text. In this example, the P element has three different parts:</p> <p>Text EM element itself after the EM element</p> <p>If you disrupt this order, you may focus on the wrong part of the text. In order to keep all normal, the P element has three sub-objects, and its sequence is the order shown in the HTML of Listing 1. Moreover, the focus text "Really" is not a sub-element of the P; it is a child element of the sub-element EM of the P.</p> <p>It is very important to understand this concept. Although "real" text may be displayed with other P element text, it is still the direct child element of the EM element. It can have different formats that are different from other P texts and can be moved every other text.</p> <p>To keep it in mind, try to use the figure to represent the HTML in Listing 2 and 3, ensuring that the text has the correct parent element (regardless of how the text will eventually display on the screen).</p> <p>Listing 2. Tags with smart elements</p> <p><html> <head> <title> this is a little tricky </ title> </ head> <body> <h1> pay <u> close </ u> attention, ok? </ h1> <div> <p > This p really isn't <em> Necessary </ em>, but it makes the <span id = "bold-text"> structure <i> and </ i> the Organization </ span> of the point easier to Keep Up with. </ p> </ div> </ body> </ html></p> <p>Listing 3. More smart elements Nested</p> <p><html> <head> <title> Trickier Nesting, Still </ title> </ head> <body> <div id = "main-body"> <div id = "contents> <table> <tr> <TH > Steps </ TH> <TH> Process </ TH> </ TD> <TD> Figure Out The <em> root element </ em>. </ Td> < / TR> <tr> <TD> 2 </ td> <TD> DEAL with the <span id = "code"> Head </ span> first, as it's usually easy. </ td> </ tr> <TR > <TD> 3 </ TD> <TD> Work Through the <span id = "code"> body </ span>. Just <em> Take Your time </ em>. </ td> </ tr> < / Table> </ div> <div id = "closing"> this link is <em> not </ em> active, but if it were, the answers to this <a href="answers.html"> <IMG SRC = "EXERCISE.GIF" /> <... Would Be There. But <em> do the supercise anyway! </ em> </ div> </ div> </ body> </ html> at the end of this article GIF The answers of these exercises will be found in the trickier-soliion.gif in Figure 2 in Trickier-Solution.gif in Figure 3. Don't peek, take some time to answer it. This will help you understand how stringent rules applied when you organize trees, and truly help you master HTML and their tree structure.</p> <p>What about the property?</p> <p>Are you experiencing some problems when you try to figure out how to deal with properties? Before you mention, the property does have your own object type, but the property does not show the child elements of its elements, nested elements and text are not in the same property "level", you will notice that Listing 2 and 3 Answers There is no display attribute.</p> <p>The attribute is in fact stored in the object model used by the browser, but they have some special situations. Each element has a list of available properties and is separated from the sub-object list. So the DIV element may have a list of "id" and another attribute "class".</p> <p>Remember, the properties of the elements must have the only name, that is, one element cannot have two "id" or two "class" properties. This makes the list easy to maintain and access. In the next article, you will see that you can simply call methods such as GetAttribute ("ID") to obtain the value of the attribute by name. You can also use a similar method to add a value of an attribute or setting (reset) existing attribute. It is worth noting that the uniqueness of the attribute name makes the list different from the list of child objects. The P element may have multiple EM elements, so the child object list can contain multiple repetitions. Although the operation mode of the sub-list and the attribute list is similar, one can contain duplicate (sub items for objects), and one cannot (attributes of the element object). Finally, only the elements have attributes, so the text object does not have additional lists for storing properties.</p> <p>Messy HTML</p> <p>Before proceeding, talk about how the browser converts the tag to a tree, there is a topic worth exploring, that is, how to handle the browser is not a formatted tag. The format is a widely used term in XML, there are two basic elections:</p> <p>Each start tag has a matching end tag. So each <p> matches </ p> in the document, each <div> and </ div> match, and so on. The innermost start tag matches the most inside end tag, and then the start mark inside matches the end tag of the times, and so on. So <B> <i> bold and italics </ b> </ i> is illegal, because the most inside start tag <i> is not properly matched with the innermost end tag <b>. To make it work well, switch the start tag order, or switch the sequence of end tags. (If both switches, there will be problems).</p> <p>In-depth study of these two rules. These two rules not only simplify the organization of documents, but also eliminate uncertainty. Is it necessary to apply a bold after bold? Or just the opposite? If this order and umbellar are not a big problem, please remember that the CSS allows the rules to overwrite other rules, so, for example, if the text of the text in the B element is different from the font in the I element, the format application order will change It is very important. Therefore, the format of HTML has a good role.</p> <p>If the browser receives a document that is not a format, it will only do our best. The tree structure will be approximate to the original page of the author's hopes, worst unrecognizable. If you have filed the page into the browser, you can see how you should have the structure when you see the browser results and continue to work in frustration. Of course, it is quite simple to get this question: Make sure the document is well format! If you don't know how to write standardized HTML, please consult the reference information to get help.</p> <p>DOM introduction</p> <p>So far, you already know that the browser converts the web page to an object, maybe you will even guess, the object is DOM tree. Dom said Document Object Model is a specification that can be obtained from World Wide Web Consortium (W3C) (you can see some DOM related links in the reference).</p> <p>But more importantly, the DOM defines the type and attribute of the object, allowing the browser to represent the tag. (This series will specifically describe the specification of DOM in JavaScript and Ajax code.)</p> <p>Document object</p> <p>First, you need to access the object model itself. This is very easy; you want to use the built-in Document variable in any JavaScript code running on the web page, you can write the following code: Var Domtree = Document;</p> <p>Of course, the code itself is not used, but it demonstrates that each web browser allows the Document object to be used for JavaScript code and demonstrates the full tree indicating the mark (Figure 1).</p> <p>Every item is a node</p> <p>Obviously, the Document object is important, but this is just starting. Before further in-depth, you need to learn another term: node. You already know that each part of the tag is represented by an object, but it is not just an arbitrary object, it is a specific type of object, a DOM node. More specific types, such as text, elements, and attributes inherit from this basic node type. So there are text nodes, element nodes, and attribute nodes.</p> <p>If there are many JavaScript programming experience, you may already use the DOM code. If you have been tracking this Ajax series so far, you must now use the DOM code for a while. For example, the code line var number = document.getlementByid ("Phone"). Value; use the DOM to find a specific element, then retrieve the value of the element (in this example is a form field). So even if you don't realize this, you will use the DOM each time you type a Document.</p> <p>Detailed explanation The term has been learned, the DOM tree is the tree of the object, but more specifically, it is the tree of the node object. In a AJAX application or in any other JavaScript, you can use these nodes to generate the following effects, such as removing elements and their content, highlighting specific text, or adding new image elements. Because all occur in the client (the code running in the web browser), these effects immediately occur, not communicating with the server. The final result is usually the application feels faster because the content changes on the web page do not have a long pause when requesting a steering server and interpreting a response.</p> <p>In most programming languages, you need to learn the actual object name of each node type, learn the available properties, and figure out the type and forced conversion; but in JavaScript is not required. You can only create a variable and assign you the object you want (as you have seen):</p> <p>Var Domtree = Document; var phoneenumbelement = document.getlementByid ("Phone"); var phoneenumber = phonenumbelement.value;</p> <p>There is no type, JavaScript creates a variable as needed and assigns the correct type for it. As a result, using DOM from JavaScript is slightly insignificant (in the future, there will be a special DOM associated with XML, which will be harder.).</p> <p>Conclude</p> <p>Here, I want to leave you a little suspense. Obviously, this is not a complete detailed description of the DOM; in fact, this article is just the introduction of the DOM. The content of the DOM is far more than what I introduced today!</p> <p>The next article of this series will extend these views and discuss how to use DOM to update the web page in JavaScript, quickly change HTML and create a more interactive experience for your users. In the back of the AJAX request, I will return to discuss DOM again in the AJAX request. So I am familiar with the DOM, which is a major part of the AJAX application. At this point, in-depth understanding of the DOM will be very simple, such as how to move in the DOM tree, get the value of the elements, and the list, etc., but this may have this impression, that is, DOM is about code. And in fact is not the case.</p> <p>Before reading the next article, try to think about the tree structure and use some of your own HTML practice to see how the web browser converts HTML to tagged tree views. In addition, think about the organization of the DOM tree, and practice with the special circumstances introduced herein: attribute, there is a text in which the element is mixed, and there is no element of the text (such as an IMG element).</p> <p>If these concepts have been summied, then learn the syntax of JavaScript and DOM (the next article), it will make the response easier.</p> <p>And don't forget, there are answers to lists 2 and 3 here, which also contain sample code!</p> <p>Figure 2. Answer of Listing 2</p> <p>Figure 3. Answer of Listing 3</p> <p>Reference</p> <p>Learn</p> <p>You can see this article in our website on our world. Learn the first few articles on this developerWorks series of Ajax:</p> <p>"Master AJAX, Part 1: AJAX" Part 1 demonstrate how Ajax component technology works together, and exposes the core concept of Ajax, including XMLHttpRequest objects (January 2006). "Master AJAX, Part 2: Use JavaScript and AJAX Send Asynchronous Request" Part 2 to show how to create an XMLHttpRequest instance, construct, and send requests in cross-browser mode, and response servers (February 2006). "Advanced Requests and Responds in Ajax" Section 3 demonstrates how standard Web forms in Ajax execute and show how to master the HTTP status code, the read state, and the understanding of the XMLHttpRequest object (2006 3 month). DOM homepage on the World Wide Web: All DOM-related contents. Dom Level 3 Core Specification: Defines the core Document Object Model covering the available types and properties and the usage of DOM in a variety of languages. ECMAScript language bindings for DOM: If you are a JavaScript programmer and want to use DOM in your code, the appendix for this appendix will be good. "AJAX: Building Dynamic Java Application": This article comes from the Java angle to observe the server-side Ajax, introduced a breakthrough method for creating a dynamic web application experience (developerWorks, September 2005) . "JAVA developer's AJAX: Ajax Java Object Series": Five ways of serialization of Java objects and discussed how to send objects through the network and how to interact with AJAX (DEVELOPERWORKS, Oct 2005). "Use ajax to call SOAP Web services, Part 1: Build a Web Server": This quite advanced article in-depth explores the integration of Ajax with existing SOAP-based web services; show how to use AJAX design mode implementation SOAP web service client based on web browsers (DeveloperWorks, October 2005). "Ajax: a New Approach to Web Applications": This article creates this name, which is the must-read of all Ajax developers. HTTP Status Code: View the full list of status code from W3C. Head Rush Ajax, Author Elisabeth Freeman, Eric Freeman and Brett McLaughlin (February 2006, O'Reilly Media, Inc.): Put the concept of this article into your brain in a deep-depth-in-depth manner. Java and XML, Second Edition, Author Brett McLaughlin (August 2001, O'Reilly Media, Inc.): Read the author's discussion of XHTML and XML conversion.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:</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="133583" 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.047</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 = 'PpBJlhPzbxOX6G3CU9AqUmeqoZXNRjunqTTlOi3LMRGjykchf6Gwj_2Binjx7CNoqtJvNjHCzBQYxWyl9ClJbj7g_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>