Explorer

html-ui.page-links

description
(en) The links to the previous and next 100 parts of a module page (response.json is the number of parts of the module; not shown when searching)
type
Fn(
  language: String,
  project: String,
  branch: String,
  module: String,
  search: String,
  start: Number,
  response: @html-ui.response
) -> List<@html.node>
expression
fn(language$990, project$0, branch$1, module$2, search$3, start$4, response$5) =>
  let total$6 = match @definy.json-get(value: $5.json, key: "count") {
      #some(value$10) =>
        match $10 {
          #number(count$7) =>
            $7,
          _ =>
            0
        },
      #none(_) =>
        0
    };
  let end$8 = @std.min(a: @core.plus(left: $4, right: 100), b: $6);
  let base$9 = @core.string-join(items: ["/p/", $0, "/", $1, "/", $2, "?start="], separator: "");
  match @core.or(
      left: @core.or(left: @core.equal(left: $2, right: ""), right: @core.not(value: @core.equal(left: $3, right: ""))),
      right: @core.less-than-or-equal(left: $6, right: 100)
    ) {
    true =>
      [],
    false =>
      [
        @html.element(
          name: "p",
          attributes: [],
          children: @html.concat(
            lists: [
              [
                @html.text(
                  text: @core.string-join(
                    items: [
                      @std.number-to-string(value: @core.plus(left: $4, right: 1)),
                      @html-ui.text(language: $990, en: "–", ja: "〜", eo: "–"),
                      @std.number-to-string(value: $8),
                      @html-ui.text(language: $990, en: " (of ", ja: " 個目 (全部で ", eo: " (el "),
                      @std.number-to-string(value: $6),
                      @html-ui.text(language: $990, en: ")", ja: " 個)", eo: ")")
                    ],
                    separator: ""
                  )
                )
              ],
              match @core.less-than(left: 0, right: $4) {
                true =>
                  [
                    @html.text(text: " "),
                    @html.element(
                      name: "a",
                      attributes: [
                        {
                          name: "href",
                          value: @core.string-concat(
                            left: $9,
                            right: @std.number-to-string(value: @std.max(a: 0, b: @core.minus(left: $4, right: 100)))
                          )
                        }
                      ],
                      children: [
                        @html.text(text: @html-ui.text(language: $990, en: "Previous 100", ja: "前の 100 個", eo: "Antaŭaj 100"))
                      ]
                    )
                  ],
                false =>
                  []
              },
              match @core.less-than(left: $8, right: $6) {
                true =>
                  [
                    @html.text(text: " "),
                    @html.element(
                      name: "a",
                      attributes: [{name: "href", value: @core.string-concat(left: $9, right: @std.number-to-string(value: $8))}],
                      children: [
                        @html.text(text: @html-ui.text(language: $990, en: "Next 100", ja: "次の 100 個", eo: "Sekvaj 100"))
                      ]
                    )
                  ],
                false =>
                  []
              }
            ]
          )
        )
      ]
  }
visibility
public
html-ui.page-links (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: 26mMalJE9Ml114jiGwWw-6xdicxxRGiDixWfvSzCQpE
content hash: _NHWjvToV8zMGrvsmvfq802v1kAchaF_IGpiQOwYyfI