Seventh: Database programmer

zhaozj2021-02-16  47

Open white: See you still remember that I don't remember that I am in the "fifth article" "MYDOG" can be "MyDog"? Now you can't, I will tell you how you can tell you. "

Program requirements: The program starts, the first page is displayed, with such information, a drop-down box is used to select "The user's department name", this drop-down box is from the "department information table" (when the page It is also available when it is generated. Then press the "Submit" button to display all the staff of the department.

Analysis: Because the page will get data from the "Department", I have to use a way to generate the Action to get data. The display of data is no longer single data, so it is designed to a loop on the page. A data displayed is no longer a data.

Create a data table: Remember the database we established in the previous one.

The database name is "User" already has a table called "useertable", and we now build one in this database.

Table "DepatTable"

Department number depatno text

Department name depatname text

Fill in a few values:

001 Production Department

002 Engineering Department

003 Personnel Department

Program start

From now on, we will do according to the idea of ​​true project development, the division of the module will be meticulously

A Module: Provide database connections

B Module: ActionandForm Module

C Module: Business Logic, Providing Data Operation

D Module: Data Entity Package

These modules are actually the concept of "package", and I don't want to say "package" in Eclipse.

A module (2 classes) - Package DataConnectFactory

ConnectFactory class

// Data Connection Factory

Package DataconnectFactory;

Import java.sql. *;

Public Class ConnectFactory

{

/ / Define the driver of the database (hereinafter given below is to connect the ODBC database)

Private static string strodr = "sun.jdbc.odbc.jdbcodbcdriver";

/ / Define the URL of the database (name)

Private static string strconnection = "JDBC: ODBC: User";

// Username

Private static string strusername = "";

// Database Access password

Private static string strpassword = "";

Public Static Connection getConnectionBydriver ()

Throws myexception

{

Connection conn = NULL;

Try

{

Class.Forname (strDriver); // Register driver

CONN = // Get a connection

Drivermanager.getConnection (STRCONNECTION,

Strusername,

Strpassword;

}

Catch (ClassNotFoundException EX1)

{

EX1.PRINTSTACKTRACE ();

Throw New MyException ("Class Not Found!");

}

Catch (SQLEXCEPTION EX2)

{

EX2.PRINTSTACKTRACE ();

Throw new myexception ("sql error");

Finally {}

Return conn;

}

}

MyException class

Package DataconnectFactory;

// Define your own anomaly

Public class myexception extends Exception

{

Public myException ()

{

Super ();

}

Public myException (String Message)

{

SUPER (Message);

}

}

B module (3 classes) - Package Action

UserAction class

Package action;

// Get the information of the department and give the page when the first query page is generated.

Import javax.servlet.http.httpservletRequest;

Import javax.servlet.http.httpservletResponse;

Import org.apache.struts.Action.Actionerror;

Import org.apache.struts.Action.Actionerro;

Import org.apache.struts.Action.actionform;

Import org.apache.struts.Action.actionForward;

Import org.apache.struts.action.actionmapping;

Import org.apache.struts.Actions.dispatchaction;

Import Biz.Searchbiz;

Import Entity. *;

Public Class UseerAction Extends Dispatchction

{

// Go to the query interface

Public ActionForward Tosearch (ActionMapping Mapping,

Actionform Form,

HTTPSERVLETREQUEST REQUEST,

Httpservletresponse response

Throws Exception

{

/ / Define Error Information Package

ActionerroS Errors = NULL;

// Get page form information

Userform uf = (userform) Form;

// Define an array of departmental entities

Departmentity [] departs = null;

Searchbiz searchbizdept = null;

Try

{

Searchbizdept = new searchbiz ();

DEPARTS =

Searchbizdept.selectDeptentitys

New departmentent ());

Uf.setDeparts (departs);

}

Catch (Exception E)

{

ERRORS = New ActionerRORS ();

E.PrintStackTrace ();

Errors.Add (ActionerRors.global_ERROR, New Actionerror ("System.exception");

Return mapping.findforward ("error");

}

Finally

{

IF (ErrorS! = NULL)

{

SaveerRors (Request, Errors);

}

}

Return mapping.findforward ("tosearch");

}

}

Package action;

Userform class

// Pack all solid into FORM

Import org.apache.struts.action.Actionform; import entity. *;

Public Class Userform Extends ActionForm

{

Private uSERENTITY USER = new useERENTITY ();

Private uSERENTITY [] Users = NULL;

PRIVATE DEPARTENTENTITY Department ();

Private departmentity [] departs = null;

Public departmentity getDepart ()

{

Return depart;

}

Public departmententity [] getDeparts ()

{

Return departs;

}

Public useERENTITY GETUSER () {

Return User;

}

Public useerentity [] getUsers ()

{

Return User;

}

Public void setDepart (DepartMentent Repart)

{

THIS.DEPART = DEPART;

}

Public void setDeparts (departmentity [] departs)

{

THIS.DEPARTS = departs;

}

Public void setuser (UserErentity User)

{

THIS.USER = User;

}

Public void setUsers (useers)

{

THIS.USERS = User;

}

}

ResultAction

Package action;

/ / When the page is submitted, check according to the conditions submitted by the page.

Import javax.servlet.http.httpservletRequest;

Import javax.servlet.http.httpservletResponse;

Import org.apache.struts.Action.Actionerro;

Import org.apache.struts.Action.actionform;

Import org.apache.struts.Action.actionForward;

Import org.apache.struts.action.actionmapping;

Import org.apache.struts.Actions.dispatchaction;

Import Biz.Searchbiz;

Import Entity. *;

Public Class ResultAction Extends Dispatchction

{

Public ActionForward Execute (ActionMapping Mapping,

Actionform Form,

HTTPSERVLETREQUEST REQUEST,

Httpservletresponse response

Throws Exception

{

/ / Define Error Information Package

ActionerroS Errors = NULL;

// Get page form information

Userform uf = (userform) Form;

/ / Define the user entity array

Userentity [] useERENTITYS = NULL;

/ / Define user entities

UseERENTITY = New useERENTITY ();

// Get the data submitted on the page

Userentity = uf.getuser ();

System.out.println (Userentization.getDepartNo ()); Searchbiz Searchbiz = NULL;

Try

{

Searchbiz = new searchbiz ();

Userentitys = Searchbiz.SelectUserentitys (UseERENTITY);

Uf.setUsers (useERENTITYS);

}

Catch (Exception E)

{

Return mapping.findforward ("error");

}

Finally

{

}

Return mapping.findforward ("Success");

}

}

C Module (1 class) - Package Biz

Searchbiz class

Package Biz;

// Here, complete all data of all data such as query and data conversion operations.

Import java.sql.connection;

Import java.sql.preparedStatement;

Import java.sql.resultset;

Import java.sql.sqlexception;

Import java.util.arraylist;

Import DataconnectFactory.ConnectFactory;

Import DataconnectFactory.myException;

Import Entity. *;

Public Class Searchbiz

{

PRIVATE STRING STRDRIVER;

PRIVATE STRING STRCONNECTION;

Private string strusename;

PRIVATE STRING STRPASSWORD;

// Query user information

Public useERENTITY [] SELECTUSERENTITITYS (UserErentity Userentity)

Throws myexception

{

Userentity [] Employeeentitys = NULL;

Connection conn = NULL;

PreparedStatement PSTMT = NULL;

ResultSet RS = NULL;

StringBuffer SBSQL = New StringBuffer ();

ArrayList List = NULL;

Try

{

CONN = ConnectFactory.getConnectionBydriver ();

/ / Generate SQL

SBSQL.Append ("SELECT");

SBSQL.Append ("UserTable.Userno,");

SBSQL.Append ("UserTable.DepartNo,");

SBSQL.Append ("DEPArtTable.DepartName);

SBSQL.Append ("from userTable, departtable);

SBSQL.Append ("WHERE

UserTable.Departno = '" uSrentity.getDEPartNO () "' ");

SBSQL.Append ("and");

SBSQL.Append ("useertable.Departno = departtable.Departno);

System.out.println (sbsql.tostring ());

PSTMT = conn.preparestatement (sbsql.tostring ()); rs = pstmt.executeQuery ();

List = Parsearray (RS, 1);

List.trimtosize ();

Employeentitys = new useERENTITY [list.size ()];

IF (Employeeentitys! = null && list.size ()> 0)

{

EMPLOYEETITYS =

(UseERENTITY []) List.toArray (Employeeentitys);

}

}

Catch (MyException EX1)

{

EX1.PRINTSTACKTRACE ();

Throw EX1;

}

Catch (SQLEXCEPTION EX2)

{

EX2.PRINTSTACKTRACE ();

Throw new myexception ("sql error");

}

Finally // Database Access is completed, close the relevant connection,

// Release the resources, you should do it

{

Try

{

IF (rs! = null)

{

Rs.close ();

RS = NULL;

}

IF (PSTMT! = NULL)

{

PSTMT.Close ();

PSTMT = NULL;

}

}

Catch (SQLException E)

{

E.PrintStackTrace ();

}

}

Return Employeeentitys;

}

// Query department information

Public Departmentity [] SelectDeptentitys (DepartMentent Department "

Throws myexception

{

Departmententity [] departmententitys = NULL;

Connection conn = NULL;

// previously used Statement, now use PrepareStatement

// This is because PrepareStatement has a precompiled process

PreparedStatement PSTMT = NULL;

ResultSet RS = NULL;

StringBuffer SBSQL = New StringBuffer ();

ArrayList List = NULL;

Try

{

CONN = ConnectFactory.getConnectionBydriver ();

SBSQL.Append ("SELECT Departmentno, DepartName from Dep AttersTable");

PSTMT = conn.preparestatement (sbsql.tostring ()); // Precompiled

RS = pstmt.executeQuery (); //

List = Parsearray (RS, 2); // Convert the result set to entity arrays

List.trimtosize ();

DEPARTMENTENTITYS = new departmentity [list.size ()];

IF (departmententitys! = null && list.size ()> 0)

{

Departmententitys =

(DEPARTMENTENTINTINTINTIN (DEPARTMENTENTITYS);

}

}

Catch (MyException EX1)

{

EX1.PRINTSTACKTRACE ();

Throw EX1;

}

Catch (sqlexception ex2) {

EX2.PRINTSTACKTRACE ();

Throw new myexception ("sql error");

}

Catch (Exception EX3)

{

EX3.PRINTSTACKTRACE ();

Throw new myexception ("exception");

}

Finally // Database Access is completed, close the relevant connection,

// Release the resources, you should do it

{

Try

{

IF (rs! = null)

{

Rs.close ();

RS = NULL;

}

IF (PSTMT! = NULL)

{

PSTMT.Close ();

PSTMT = NULL;

}

}

Catch (SQLException E)

{

E.PrintStackTrace ();

}

}

Return departmententitys;

}

/ / Convert the result set to the method of entity arrays

Protected Arraylist Parsearray (ResultSet RS, Long LTYPE) THROWS SQLEXCEPTION

{

ArrayList List = New ArrayList ();

UserErentity Userentity = NULL;

DEPARTMENTENTENTITY Department;

Object Object = NULL;

Try {

While (rs.next ())

{

IF (LTYPE == 1)

{

Userentity = new useERENTITY ();

Userentity.setUserno ("Userno");

Userentity.SetDepartNO (RS.GetString ("departno");

Userentity.setDepartName (RS.GetString ("departname"));

Object = (Object) uSrentity;

}

Else

{

DEPARTMENTENTITY = New departmentent ();

Departmententity.SetDepartmentNo (Rs.getstring ("departno");

Departmententity.SetDePartmentName (Rs.getstring ("DepartName"));

Object = (Object) DEPARTMENTENTENTITY;

}

List.add (Object);

}

}

Catch (SQLException EX)

{

EX.PrintStackTrace ();

Throw EX;

}

Finally {}

Return List;

}

}

D Module (2 classes) - package entity

Userentity class

Package Entity;

// user information entity

Public Class useERENTITY

{

PRIVATE STRING Userno = NULL;

Private string userpassword = null;

PRIVATE STRING DEPARTNO = NULL;

PRIVATE STRING Departmentname = NULL;

Public String getDepartName ()

{

RETURN DepartName == NULL? ": DepartName.trim ();

}

Public string getDepartno () {

RETURN Departno == NULL? ": Departno.trim ();

}

Public string getuserno ()

{

RETURN Userno == NULL? ": Userno.trim ();

}

Public String getUserpassword ()

{

RETURN Userpassword == NULL? "": Userpassword.trim ();

}

Public void setDepartName (String Departname)

{

this.DepartName = departname;

}

Public void setDepartNO (String Departno)

{

THIS.DEPARTNO = DEPARTNO;

}

Public void setUserno (String Userno)

{

THIS.USERNO = Userno;

}

Public void setuserpassword (String Userpassword)

{

THIS.USERPASSWORD = Userpassword;

}

}

Departmententity class

Package Entity;

// Department information entity

Public class departmententity

{

PRIVATE STRING DepartmentNO = NULL;

Private string departmentname = null;

Public String getDepartmentName ()

{

RETURN DepArtmentName == NULL? "": DepartmentName.trim ();

}

Public String getDepartmentNo ()

{

RETURN DepArtNO == NULL? ": DepartmentNo.trim ();

}

Public void setDepartmentName (String DepartmentName)

{

THIS.DEPARTMENTNAME = DepartmentName;

}

Public void setDepartmentno (String Department "

{

THIS.DEPARTNO = DEPARTNO;

}

}

Profile: struts-config.xml

"- // Apache Software Foundation // DTD Struts Configuration 1.1 // En"

"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

This Is The Struts Configuration File for the Example Application,

Using the proposed New Syntax.

NOTE: You Would Only Flesh Out The Details in The "Form-Bean"

Declarations if you had a generator Tool That Used Them To create

THE CORRESPONDING JAVA CLASSES for you. Otherwise, you would notlement only the "form-bean" Element itself, with the corresponding

"Name" and "type" attributes.

->

TYPE = "action.useraction"

Name = "Userform"

Scope = "request"

Parameter = "Operate"

VALIDATE = "false"

INPUT = "Search.jsp">

Type = "action.resultation" name = "userform"

Scope = "request"

INPUT = "Search.jsp">

JSP page

Search.jsp

<% @ Page ContentType = "text / html; charset = GB2312"%>

<% @ Taglib Uri = "/ Web-INF / STRUTS-TILES.TLD" prefix = "tiles"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%>

<% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%>

search Employee </ Title> </ hEAD></p> <p><body></p> <p><center></p> <p><html: form action = "searchinfo.do" method = "post"></p> <p><table></p> <p><tr></p> <p><TD> Department </ TD></p> <p><TD></p> <p><html: select proteth = "user.Departno"></p> <p><logic: Notempty Name = "Userform" property = "departs"></p> <p><logic: Itereate Name = "Userform" property = "departs" id = "dept" type = "entity.Departmentent"></p> <p><html: option value = "<% = String.Valueof (dept.getDepartmentNo ())%>> <% = dept.getDepartmentName ()%> </ html: option></p> <p></ logic: Iterate></p> <p></ logic: NOTEMPTY></p> <p></ html: select></p> <p></ td></p> <p></ TR></p> <p><tr></p> <p><TD> <html: Submit value = "Submit" /> </ td> <td> <html: reset value = "reset" /> </ td></p> <p></ TR></p> <p></ TABLE></p> <p></ html: form></p> <p></ center></p> <p></ body></p> <p></ html></p> <p>Success.jsp</p> <p><% @ Page ContentType = "text / html; charset = GB2312"%></p> <p><% @ page language = "java"%></p> <p><% @ Page Import = "Java.util. *;"%></p> <p><% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%></p> <p><% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%></p> <p><% @ Taglib URI = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%></p> <p><html: html></p> <p><body></p> <p><center></p> <p><Table Width = "80%" border = "1"></p> <p><tr></p> <p><TH> User No. </ TH></p> <p><TH> Site No. </ TH></p> <p><TH> The department name is </ TH></p> <p></ TR></p> <p><logic: Iterate</p> <p>Name = "Userform"</p> <p>Property = "Users"</p> <p>ID = "UE"</p> <p>TYPE = "Entity.Userentity"></p> <p><tr></p> <p><TD> <% = u.getuserno ()%> </ td></p> <p><TD> <% = UE.GETDEPARTNO ()%> </ td></p> <p><TD> <% = UE.GETDEPARTNAME ()%> </ td></p> <p></ TR></p> <p></ logic: Iterate></p> <p></ TABLE></p> <p></ center></p> <p></ body></p> <p></ html: html></p> <p>Error.jsp</p> <p><html></p> <p>Error !!</p> <p></ html></p> <p>Hurry up</p> <p>http: // localhost: 8080 / temp3 / search.do? Operate = Tosearch</p> <p>Little prompt:</p> <p>Discover? When running the program, what is the thing that IE the IE address is not the same?</p> <p>There is no Execute method in the useERAction, replaced with the Tosearch method. Ok, now I will allow you to change this tosearch casually, change a MyDog? Then enter on your IE:</p> <p>Http: // localhost: 8080 / temp3 / search.do? Operate = MyDog</p> <p>Haha, the same thing.</p> <p>I would like to remind you, but I want to see yourself is not stupid: After the Java program is changed, it is necessary to re-save the compile.</p> <p>After any program changes or configuration file changes, please restart your Tomcat</p> <p>After any JSP page is changed, you don't need to restart Tomcat, you can refresh it.</p> <p>Focus here:</p> <p>How to connect Oracle Database:</p> <p>1: To import a classes12.jar this JAR package, it provides the driver of the Oracle database</p> <p>2: strDriver = "Oracle.jdbc.driver.OracleDriver";</p> <p>StrConnection = "JDBC: Oracle: Thin: @ ¥¥¥¥¥¥¥¥¥¥¥¥¥¥</p> <p>Strusename = "******";</p> <p>Strpassword = "######";</p> <p>¥¥¥¥¥¥¥: Database server IP address</p> <p>! ! ! ! ! : The name of the database</p> <p>******: Name of the database</p> <p>######: Access the password of the database</p> <p>How to connect the database using the connection pool</p> <p>1: In D: / Tomcat-</p> <p>4.1.18</p> <p>/ confessed in the server.xml</p> <p></ Host> </ engine> </ service> </ server></p> <p>Add Add before this paragraph:</p> <p><Context path = "/ -----" DocBase = "/ ------" Debug = "0" Reloadable = "true"></p> <p><Resource Name = "JDBC / %%%" Auth = "Container" type = "javax.sql.datasource" /></p> <p><ResourceParams Name = "JDBC / %%%"></p> <p><parameter></p> <p><name> Username </ name></p> <p><value> ****** </ value></p> <p></ parameter></p> <p><parameter></p> <p><name> Password </ name></p> <p><value> ###### </ value></p> <p></ parameter></p> <p><parameter></p> <p><name> driverclassname </ name></p> <p><value> Oracle.jdbc.driver.Oracledriver </ value></p> <p></ parameter></p> <p><parameter></p> <p><name> URL </ name></p> <p><value> jdbc: Oracle: Thin: @ ¥¥¥¥¥¥:! ! ! ! </ value></p> <p></ parameter></p> <p><parameter></p> <p><name> maxactive </ name></p> <p><value> 30 </ value> </ parameter></p> <p><parameter></p> <p><name> maxidle </ name></p> <p><Value> 10 </ value></p> <p></ parameter></p> <p><parameter></p> <p><name> maxwait </ name></p> <p><Value> 5000 </ Value></p> <p></ parameter></p> <p></ Resourceparams></p> <p></ Context></p> <p>-----: You have to use the application engineering directory of this connection pool, for example: User</p> <p>%%%: Just take a name, for example: userdb</p> <p>2: Modify the web.xml corresponding to your application</p> <p>Add before </ web-app></p> <p><resource-ref></p> <p><Description> ((((((((((((((((Description>)</p> <p><res-ref-name> JDBC / %%% </ res-ref-name></p> <p><Res-Type> javax.sql.datasource </ res-Type></p> <p><res-auth> container </ res-auth></p> <p></ resource-ref></p> <p></ web-app></p> <p>(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((,</p> <p>3: This is used</p> <p>Remember your public class connectFactory?</p> <p>Recreated into the following</p> <p>Package connectDatabase;</p> <p>Import java.sql. *;</p> <p>Import javax.sql.datasource;</p> <p>Import javax.naming.context;</p> <p>Import javax.naming.initialcontext;</p> <p>Import javax.naming.namingexception;</p> <p>Public Class ConnectFactory</p> <p>{</p> <p>Public Static Connection getConnectionBydriver ()</p> <p>Throws myexception</p> <p>{</p> <p>DataSource DS;</p> <p>Connection conn = NULL;</p> <p>// Buffer pool connection</p> <p>Try</p> <p>{</p> <p>CONTEXT INITCTX = New InitialContext ();</p> <p>Context envctx = (context) INITCTX.LOOKUP ("Java: Comp / ENV");</p> <p>DS = (DataSource) Envctx.lookup ("JDBC / %%%");</p> <p>IF (ds! = null)</p> <p>{</p> <p>CONN = ds.getConnection ();</p> <p>}</p> <p>}</p> <p>Catch (Namingexception E)</p> <p>{</p> <p>E.PrintStackTrace ();</p> <p>}</p> <p>Catch (SQLEXCEPTION E1)</p> <p>{</p> <p>E1.PrintStackTrace ();</p> <p>}</p> <p>Finally {}</p> <p>Return conn;</p> <p>}</p> <p>}</p> <p>Conclusion:</p> <p>Although in this article, I didn't explain it more, but I believe that you can get some experience and conclusions through your own exploration. If you feel that I have a big doubt, then this is what I want. The effect is, because I sincerely hope that you can exercise your programming ideas, not Ctrl V my code.</p> <p>In the previous article, we define some properties directly in the form, but now we have started to encapsulate entities, and we will operate in other programs. We have begun to separate the query operations of the data to the action, and we must also separate the database access to the business operation logic. We have also come into contact with the logic: Itereate this important page loop label.</p> <p>In the future, we also have to provide "interface" of various databases in the Public Class ConnectFactory, let us become a class that is practical in any place.</p> <p>The segmentation of these modules is rich in "interface". Will make our code make great reuse, let you write, permanent use. Remember those JAR packages we imported, that is, some people write well, we use it. Let me look forward to writing a JAR bag to release it, let people around the world use the class you written, through the class you wrote, to reduce the workload for the majority of programmers. . . . . . . .</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-20951.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="20951" 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.057</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 = 'pV8OyOhn25AD3IR_2BbtQMvVm_2B0VLMeCUx6mOTawA8zcH2MgvEjeU9ECqLsfU06RclRAr953WozeDy4XJULOe6AA_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>