Go to pimshell (4)-web page architecture htm/XML/JS

Source: Internet
Author: User

The interfaces in pimshell are implemented in the form of web pages. The website architecture used by pimshell generally contains three files,. Htm/. xml/. js.. The HTM file defines the DOM elements in the interface. The. xml file is the behavior required for Dom element appending (behavior), and The. js file implements JavaScript code. For example, you need to create three files: list.htm/list.htm. xml/list.htm. js. The Code is as follows:

1、list.htm File

  1. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  2. <Head>
  3. <Title> User List </title>
  4. <Link type = "text/CSS" rel = "stylesheet" href = "/CSS/main.css"/>
  5. <XML src = "list.htm. xml"> </XML>
  6. <SCRIPT type = "text/JavaScript" src = "list.htm. js" Language = "JavaScript"> </SCRIPT>
  7. </Head>
  8. <Body>
  9. <Div id = "list1"> </div>
  10. </Body>
  11. </Html>
  • Row 4: defines the page style. InMain.cssThe following style is set for the body in the file:

    1. Body
    2. {
    3. Behavior: URL (# default # pimshell );
    4. }

    This style adds a default behavior called pimshell to the body element. This action is responsible for parsing the subsequent XML file and initiating the onpageload event to execute the code in the JS file.

  • Row 5: defines the XML file and attaches a behavior to the DOM element on the page.

  • Row 6: defines the JS file and contains the required JavaScript code.

  • Row 9: defines a div element named list1 to display list information.

22.16list.htm. xml file

    1. <? XML version = "1.0" encoding = "UTF-16"?>
    2. <Page>
    3. <Root enableframe = "false" enablecontextmenu = "false">
    4. <Controls>
    5. <Control ID = "list1">
    6. <Behaviors>
    7. <Listview autofitrows = "false" allowpage = "false">
    8. <Header>
    9. <Cols>
    10. <Col name = "name" text = "name" width = "60">
    11. <Bind>
    12. <Text> [# name #] </text>
    13. </Bind>
    14. </COL>
    15. <Col name = "sex" text = "gender" width = "40">
    16. <Bind>
    17. <Text> [# Sex #] </text>
    18. </Bind>
    19. </COL>
    20. <Col name = "email" text = "email" width = "80">
    21. <Bind>
    22. <A href = "mailto: [* Email *]"> </a>
    23. </Bind>
    24. </COL>
    25. </Cols>
    26. </Header>
    27. </Listview>
    28. </Behaviors>
    29. </Control>
    30. </Controls>
    31. <Events>
    32. <Onpageload handler = "onpageload"/>
    33. </Events>
    34. </Root>
    35. </Page>
  • Row 5: Define element list1 as a part
  • Row 7: Add behavior listview for list1
  • Row 8-26: Define the attribute columns used in the list
  • Row 32: bind the event onpageload

32.16list.htm. JS File

    1. // Event: onpageload
    2. Function onpageload ()
    3. {
    4. // Prepare the record set
    5. VaR oentityset =__ prepareentityset ();
    6. // Bind
    7. $ ("List1"). datasource = oentityset;
    8. $ ("List1"). databind ();
    9. }
    10. // Prepare the record set
    11. VaR g_susers = "Zhang San, male, zhangsan@msn.com; Li Si, male, lisi@msn.com; Wang Xia, female, wangxia@msn.com ";
    12. Function _ prepareentityset ()
    13. {
    14. //
    15. VaR oentityset = SYS. entityset;
    16. //
    17. VaR ouserarray = g_susers.split (";");
    18. For (VAR I = 0; I <ouserarray. length; I ++)
    19. {
    20. // Add a new record
    21. Oentityset. addnew ();
    22. //
    23. VaR oproparray = ouserarray [I]. Split (",");
    24. Oentityset ("name") = oproparray [0];
    25. Oentityset ("sex") = oproparray [1];
    26. Oentityset ("email") = oproparray [2];
    27. }
    28. // Move to the header
    29. Oentityset. movefirst ();
    30. Return oentityset;
    31. }
  • Row 2: RESPONSE event onpageload
  • Row 5: Construct an oentityset for testing.
  • Line 8-9: bind the record set oentityset to the element list1 to display the list.

4. webpage Running Effect

     

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.