Page files
Copy codeThe Code is as follows:
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> </title>
<Script type = "text/javascript" src = "jquery-1.6.min.js"> </script>
<Script type = "text/javascript" src = "queryi18n. js"> </script>
<Script type = "text/javascript">
</Script>
</Head>
<Body oncontextmenu = "return false">
<Form id = "i18nform">
<Div id = "i18ntablediv" style = "width: 90%;">
<Table id = "i18ntable" border = "1px" width = "90%">
<Tr>
<Th width = '20px '> key </th>
<Th width = '20px '> value </th>
<Th width = '5% 'height = '20px'> value </th>
</Tr>
</Table>
</Div>
<Div id = "addtrdiv" style = "width: 10%; float: right;">
<A href = "#" class = "easyui-linkbutton" iconCls = "icon-add" onclick = "addtr () "> <span key =" ss "class =" paltform-i18n "> Add row </span> </a>
</Div>
<Div class = "button_area_absolute">
& Lt; table width = "90%" & gt;
<Tr>
<Td align = center> <a href = "#" class = "easyui-linkbutton" iconCls = "icon-OK" onclick = "savei18ninfo () "> <span key =" save "class =" paltform-i18n "> save </span> </a> </td>
</Tr>
</Table>
</Div>
</Form>
</Body>
</Html>
Js files
Copy codeThe Code is as follows:
// Save the International File
Function savei18ninfo (){
Var i18ninfo = geti18ninfo ();
Alert (i18ninfo );
}
// Obtain the i18n Value
Function geti18ninfo (){
Var key = "";
Var value = "";
Var i18ndata = "";
Var table = $ ("# i18ntable ");
Var tbody = table. children ();
Var trs = tbody. children ();
For (var I = 1; I <trs. length; I ++ ){
Var tds = trs. eq (I). children ();
For (var j = 0; j <tds. length; j ++ ){
If (j = 0 ){
If (tds. eq (j). text () = null | tds. eq (j). text () = ""){
Return null;
}
Key = "key \": \ "" + tds. eq (j). text ();
}
If (j = 1 ){
If (tds. eq (j). text () = null | tds. eq (j). text () = ""){
Return null;
}
Value = "value \": \ "" + tds. eq (j). text ();
}
}
If (I = trs. length-1 ){
I18ndata + = "{\" "+ key +" \ ", \" "+ value + "\"}";
} Else {
I18ndata + = "{\" "+ key +" \ ", \" "+ value + "\"},";
}
}
I18ndata = "[" + i18ndata + "]";
Return i18ndata;
}
Var clientWidth = document.doc umentElement. clientWidth;
Var clientHeight = document.doc umentElement. clientHeight;
Var div_left_width = 200;
Var tempWidth = 0;
/**
* Description: Page adaptation.
*/
$ (Window). bind ("resize", function (){
ResizeLayout ();
});
Function resizeLayout (){
Try {
ClientWidth = document.doc umentElement. clientWidth;
Var div_left_width = $ ("# left"). width () + 11;
$ ("# Cc"). layout ("resize ");
$ ('# Userquery'). panel ('resize', {width: clientWidth-div_left_width });
$ ('#10100801'). datagrid ('resize', {width: clientWidth-div_left_width });
$ ('# Userrange'). combobox ({
Width: $ ('# right'). width () * 0.35
});
} Catch (e ){
}
}
Function initResize (){
// Automatically adapt to the page size
$ (". Layout-button-left"). bind ("click", function (){
$ ('# Userquery'). panel ('resize', {width: clientWidth-28 });
$ ('#10100801'). datagrid ('resize', {width: clientWidth-28 });
$ (". Layout-button-right"). bind ("click", function (){
$ ('# Userquery'). panel ('resize', {width: tempWidth });
$ ('#10100801'). datagrid ('resize', {width: tempWidth });
});
});
}
Function tdclick (tdobject ){
Var td = $ (tdobject );
Td. attr ("onclick ","");
// 1. Extract the text in the current td and save it.
Var text = td. text ();
// 2. Clear the content in td
Td.html (""); // you can also use td. empty ();
// 3. Create a text box, that is, the input element node.
Var input = $ ("<input> ");
// 4. Set the value of the text box to the saved text content.
Input. attr ("value", text );
Input. bind ("blur", function (){
Var inputnode = $ (this );
Var inputtext = inputnode. val ();
Var tdNode = inputnode. parent ();
TdNode.html (inputtext );
TdNode. click (tdclick );
Td. attr ("onclick", "tdclick (this )");
});
Input. keyup (function (event ){
Var myEvent = event | window. event;
Var kcode = myEvent. keyCode;
If (kcode = 13 ){
Var inputnode = $ (this );
Var inputtext = inputnode. val ();
Var tdNode = inputnode. parent ();
TdNode.html (inputtext );
TdNode. click (tdclick );
}
});
// 5. Add the text box to td.
Td. append (input );
Var t = input. val ();
Input. val (""). focus (). val (t );
// Input. focus ();
// 6. Clear click events
Td. unbind ("click ");
}
Function addtr (){
Var table = $ ("# i18ntable ");
Var tr = $ ("<tr> <td height = '20px 'onclick = 'tdclick (this) '> "+" </td> <td height = '20px' onclick = 'tdclick (this) '> "+" </td> <td height = '20px' align = 'center' onclick = 'deleter (this) '> <font size = '2' color = 'red'> "+" delete "+" </font> </td> </tr> ");
Table. append (tr );
}
Function deletetr (tdobject ){
Var td = $ (tdobject );
Td. parents ("tr"). remove ();
}