SOURCE CODE: Domain List Editor

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
  <title>Domain List Editor | JavaScript Examples | UIZE JavaScript Framework</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="keywords" content="widget form Uize.Widget.ListEditor"/>
  <meta name="description" content="See an example of a domain list editor that lets the user add domains to a list, or select items from the list to remove or modify and then re-add."/>
  <link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href=""/>
  <link rel="stylesheet" href="../css/page.css"/>
  <link rel="stylesheet" href="../css/page.example.css"/>
  <style type="text/css">
    .listEditor {
      background:#becacd url(../images/page-contents-bg.gif) repeat-x left top;
      border:1px solid #899;
    .listEditor input {
    .listEditor select {
    .listEditor h4 {
      margin:4px 0;
    .listEditor .domains {
      border-top:1px dotted #555;
    .note {


<script type="text/javascript" src="../js/Uize.js"></script>

<h1 class="header">
  <a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
  <a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>

<div class="main">
  <h1 class="document-title">
    <a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
    Domain List Editor
    <div class="pageActionsShell">
      <div id="page-actions" class="pageActions"><a href="source-code/domain-list-editor.html" class="buttonLink">SOURCE</a></div>

  <!-- explanation copy -->

  <div class="explanation">
    <p>In this example, an instance of the <a href="../reference/Uize.Widget.ListEditor.html"><code>Uize.Widget.ListEditor</code></a> class is being used to create an interface that lets the user build up a list of domain names. This could be for something like a domain whitelist, or a domain based, blacklist style content filter. Domains can be entered in the text input and then added by either pressing the enter key or clicking the <b>"ADD"</b> button. Domains can be removed by selecting them in the multi-select box and then pressing the delete key or clicking the <b>"REMOVE SELECT"</b> button. Below the widget is a demonstration of some of the widget's programmatic interface, with an up-to-date display of the value of the widget's <code>list</code> state property, and some links for setting the value of this property.</p>

  <!-- HTML for the Domain List Editor widget -->

    <div class="listEditor">
      <h4>Add a Domain:</h4>
        <input type="text" id="page_listEditor_input-input" size="50"/>
        <a id="page_listEditor_add" href="javascript://" class="button">ADD</a>
        <div class="note">example:</div>
      <div class="domains">
        <h4>Your Domains:</h4>
          <select id="page_listEditor-list" size="6" multiple="multiple"></select>
          <a id="page_listEditor_remove" href="javascript://" class="button">REMOVE SELECTED</a>

  <!-- programmatic interface examples -->

  <div class="programmaticInterface">
      <li>Current State
          <li><b>listEditor.get ('list') == </b> <span id="page-listEditorValue"></span></li>
      <li>Set Value
          <li><a href="javascript://" class="linkedJs">listEditor.set ({list:['']})</a></li>
          <li><a href="javascript://" class="linkedJs">listEditor.set ({list:['','','']})</a></li>
          <li><a href="javascript://" class="linkedJs">listEditor.set ({list:['','','','','','']})</a></li>

<!-- JavaScript code to wire up the page UI -->

<script type="text/javascript">

Uize.require (
  function () {
    'use strict';

    /*** create the example page widget ***/
      var page = = UizeSite.Page.Example ({evaluator:function (code) {eval (code)}});

    /*** add the Domain List Editor child widget ***/
      var listEditor = page.addChild (
        {itemConformer:function (value) {return value.replace (/(^\s*(https?\:\/\/)?|(\/)+\s*$)/gi,'')}}

    /*** functions for updating state display ***/
      function updateStateDisplay () {
        page.setNodeValue ('listEditorValue', (listEditor.get ('list'),'mini'));
      listEditor.wire ('Changed.list',updateStateDisplay);

    /*** wire up the page widget ***/
      page.wireUi ();

    /*** initialization ***/
      updateStateDisplay ();