Author: scottbw
Date: Thu Mar 24 11:51:41 2011
New Revision: 1084916
URL: http://svn.apache.org/viewvc?rev=1084916&view=rev
Log:
Added some widgets that perform admin functionality - managing the whitelist
and policy entries. These can be used instead of the admin JSP pages.
Added:
incubator/wookie/trunk/scratchpad/widgets/warp/
incubator/wookie/trunk/scratchpad/widgets/warp/build.xml
incubator/wookie/trunk/scratchpad/widgets/warp/config.xml
incubator/wookie/trunk/scratchpad/widgets/warp/images/
incubator/wookie/trunk/scratchpad/widgets/warp/images/icon.png (with
props)
incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_16x16.png
(with props)
incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_32x32.png
(with props)
incubator/wookie/trunk/scratchpad/widgets/warp/index.html
incubator/wookie/trunk/scratchpad/widgets/warp/legal/
incubator/wookie/trunk/scratchpad/widgets/warp/lib/
incubator/wookie/trunk/scratchpad/widgets/warp/scripts/
incubator/wookie/trunk/scratchpad/widgets/warp/scripts/controller.js
incubator/wookie/trunk/scratchpad/widgets/warp/style/
incubator/wookie/trunk/scratchpad/widgets/whitelist/
incubator/wookie/trunk/scratchpad/widgets/whitelist/build.xml
incubator/wookie/trunk/scratchpad/widgets/whitelist/config.xml
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon.png (with
props)
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_16x16.png
(with props)
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_32x32.png
(with props)
incubator/wookie/trunk/scratchpad/widgets/whitelist/index.html
incubator/wookie/trunk/scratchpad/widgets/whitelist/legal/
incubator/wookie/trunk/scratchpad/widgets/whitelist/lib/
incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/
incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/controller.js
incubator/wookie/trunk/scratchpad/widgets/whitelist/style/
Added: incubator/wookie/trunk/scratchpad/widgets/warp/build.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/build.xml?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/warp/build.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/warp/build.xml Thu Mar 24
11:51:41 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="build-widget" basedir="." name="widget build file">
+ <property name="wookie.widgets.dir" location="../"/>
+ <property name="widget.shortname" value="warp"/>
+
+ <import file="../build.xml"/>
+</project>
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/widgets/warp/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/config.xml?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/warp/config.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/warp/config.xml Thu Mar 24
11:51:41 2011
@@ -0,0 +1,48 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<widget xmlns="http://www.w3.org/ns/widgets"
+ id="http://wookie.apache.org/widgets/warp"
+ version="0.1"
+ width="320"
+ height="480"
+ >
+ <name>warp</name>
+ <description>Administration Widget for Wookie's WARP feature</description>
+ <content src="index.html"/>
+ <icon src="images/icon.png"/>
+ <author>Apache Wookie (Incubating) Team</author>
+ <feature name="http://jquerymobile.com" required="true"/>
+
+ <licence>Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.</licence>
+
+</widget>
+
+
+
Added: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/images/icon.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_16x16.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_16x16.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_16x16.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_32x32.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_32x32.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/wookie/trunk/scratchpad/widgets/warp/images/icon_32x32.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/warp/index.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/index.html?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/warp/index.html (added)
+++ incubator/wookie/trunk/scratchpad/widgets/warp/index.html Thu Mar 24
11:51:41 2011
@@ -0,0 +1,72 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="pragma" content="no-cache"/>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <script type="text/javascript" src="scripts/controller.js"
charset="utf-8"></script>
+ <title>warp</title>
+ </head>
+ <body onLoad="Controller.init()">
+ <div data-role="page" id="warp">
+
+ <div data-role="header">
+ <h4>Access Policies</h4>
+ <a onClick="Controller.update()"
data-role="button" data-icon="refresh" data-iconpos="notext">Refresh</a>
+ </div> <!-- /header -->
+
+ <div data-role="content">
+ <p>Select the widget you want to view, grant or
revoke widget access request policies for from the list below.</p>
+ <br>
+ <ul data-role="listview" id="widgets-listview">
+ </ul>
+ </div><!-- /content -->
+ </div><!-- /page -->
+
+ <div data-role="page" id="widget">
+ <div data-role="header">
+ <h4 class="widget-title">Widget Title Goes Here</h4>
+ </div> <!-- /header -->
+ <div data-role="content">
+ <ul data-role="listview" id="policies-listview"
data-filter="true">
+ </ul>
+ </div><!-- /content -->
+ </div><!-- /page -->
+
+ <div data-role="page" id="policy">
+ <div data-role="header">
+ <h4 id="policy-title">Policy Details</h4>
+ </div> <!-- /header -->
+ <div data-role="content">
+ <p><b>Widget</b> <span class="widget-title"></span></p>
+ <p><b>Origin</b> <span id="policy-origin"></span></p>
+
+ <div id="policy-field" data-role="fieldcontain">
+ <fieldset id="policy-fieldset" data-role="controlgroup"
data-type="horizontal">
+ <input type="radio" name="radio-view"
id="granted-radio-button" value="granted"/>
+ <label
for="granted-radio-button">Granted</label>
+ <input type="radio" name="radio-view"
id="denied-radio-button" value="denied"/>
+ <label for="denied-radio-button">Denied</label>
+ </fieldset>
+ </div>
+
+ </div><!-- /content -->
+ </div><!-- /page -->
+
+ </body>
+</html>
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/widgets/warp/scripts/controller.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/warp/scripts/controller.js?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/warp/scripts/controller.js (added)
+++ incubator/wookie/trunk/scratchpad/widgets/warp/scripts/controller.js Thu
Mar 24 11:51:41 2011
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * The Controller object
+ * This is used to wire up the view and model with actions
+ */
+var Controller = {
+
+ init:function() {
+ Controller.update();
+ },
+
+ update:function() {
+ $.get("/wookie/warp?format=xml", Controller.parseTopLevel);
+ },
+
+ // Parse the complete policy list for all Widgets
+ // and construct a list of widgets with a count of the
+ // number of policies that apply to them
+ parseTopLevel: function(xml){
+ var widgets = new Array();
+ $(xml).find("policy").each(function(){
+ var widget = {};
+ widget.id = $(this).attr("widget");
+ widget.title = $(this).attr("widget_title");
+ widget.count = 1;
+ var exists = false;
+ for(var i=0;i<widgets.length;i++){
+ if (widgets[i].id == widget.id){
+ widgets[i].count++;
+ exists = true;
+ }
+ }
+ if (!exists){
+ widgets.push(widget);
+ }
+ });
+ Controller.widgets = widgets;
+ Controller.updateListView(widgets);
+ },
+
+ // Update the list of widgets and the number of policies that they have
+ // and attach an OnClick even to view that widget
+ updateListView: function(widgets){
+ var index = $('#widgets-listview');
+ index.empty();
+ for(var i=0;i<widgets.length;i++){
+ var widget = widgets[i];
+ index.append($("<li/>")
+ .append($("<a/>")
+ .attr("onClick", "Controller.viewWidget(" +
widget.id + ")")
+ .text(widget.title)
+ )
+ .append($("<span/>")
+ .attr("class","ui-li-count")
+ .text(widget.count)
+ ));
+ index.listview("refresh");
+ }
+ },
+
+ // At Widget level we can see the list of policies
+
+ // Set the current widget, and load its policies from the server
+ viewWidget: function(widget_id){
+ var widget = Controller.getWidget(widget_id);
+ Controller.widget = widget;
+ $(".widget-title").text(widget.title);
+ $.mobile.changePage("#widget");
+ $.get("/wookie/warp?format=xml&widgetId="+widget.id,
Controller.parseWidgetLevel);
+ },
+
+ // Refresh the list view of policies for the current Widget
+ parseWidgetLevel: function(xml){
+ var index = $('#policies-listview');
+ index.empty();
+ $(xml).find("policy").each(
+ function(){
+ var id = $(this).attr("id");
+ var origin = $(this).attr("origin");
+ var granted = $(this).attr("granted");
+ var theme = "";
+ var decorator = "";
+ if (granted == "false") theme = "e";
+ if (granted == "false") decorator = "(not granted)";
+ index.append( $("<li/>")
+ .attr("data-theme", theme)
+ .append($("<a/>")
+ .text(origin)
+ .attr("onClick", "Controller.policy =
Controller.viewPolicy("+id+",\""+granted+"\",\""+origin+"\")")
+ )
+ .append($("<p/>").attr("class",
"ul-li-aside").text(decorator))
+ )
+
+ });
+ index.listview('refresh');
+ },
+
+ // Utility method for getting the cached widget from its id
+ getWidget: function(id){
+ if (!Controller.widgets) return null;
+ for (var i=0;i<Controller.widgets.length;i++){
+ if (Controller.widgets[i].id == id) return Controller.widgets[i];
+ }
+ },
+
+ // At Policy level we can grant/revoke
+
+ // Set the current policy id, and update the form
+ // buttons to reflect its status. Finally, re-bind
+ // an onChange event to the status radio buttons
+ viewPolicy: function(id, granted, origin){
+ Controller.policy_id = id;
+ $("#policy-origin").text(origin);
+ // Remove any existing change event bound to this control before
+ // we change its value
+ $("input[name='radio-view']").unbind("change");
+
+ $("input[name='radio-view']:checked").removeAttr("checked");
+ if (granted == "true"){
+ $("input[name='radio-view']:eq(0)").attr("checked","checked");
+ $("input[name='radio-view']:eq(1)").removeAttr("checked");
+ } else {
+ $("input[name='radio-view']:eq(0)").removeAttr("checked");
+ $("input[name='radio-view']:eq(1)").attr("checked","checked");
+ }
+
+ $("input[name='radio-view']").change(function(){
+ if ($("input[name='radio-view']:checked").val() == 'granted')
+ Controller.put("true");
+ else
+ Controller.put("false");
+ });
+ $.mobile.changePage("#policy");
+ $("input[name='radio-view']").checkboxradio("refresh");
+ },
+
+ // Set the status of a policy (granted or not granted)
+ // When complete, refreshes the policy list
+ put: function(state){
+ $.ajax({
+ type: "PUT",
+ url: '/wookie/warp/'+Controller.policy_id+'?granted='+state,
+ datatype:'json',
+ success: function(msg) {
+ $.get("/wookie/warp?format=xml&widgetId="+Controller.widget.id,
Controller.parseWidgetLevel);
+ }
+ });
+ }
+}
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/build.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/build.xml?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/whitelist/build.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/whitelist/build.xml Thu Mar 24
11:51:41 2011
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project default="build-widget" basedir="." name="widget build file">
+ <property name="wookie.widgets.dir" location="../"/>
+ <property name="widget.shortname" value="whitelist"/>
+
+ <import file="../build.xml"/>
+</project>
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/config.xml
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/config.xml?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/whitelist/config.xml (added)
+++ incubator/wookie/trunk/scratchpad/widgets/whitelist/config.xml Thu Mar 24
11:51:41 2011
@@ -0,0 +1,48 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<widget xmlns="http://www.w3.org/ns/widgets"
+ id="http://wookie.apache.org/widgets/whitelist"
+ version="0.1"
+ width="320"
+ height="480"
+ >
+ <name>whitelist</name>
+ <description>Administration Widget for Wookie's whitelist
feature</description>
+ <content src="index.html"/>
+ <icon src="images/icon.png"/>
+ <author>Apache Wookie (Incubating) Team</author>
+ <feature name="http://jquerymobile.com" required="true"/>
+
+ <licence>Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.</licence>
+
+</widget>
+
+
+
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_16x16.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_16x16.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_16x16.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_32x32.png
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_32x32.png?rev=1084916&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
incubator/wookie/trunk/scratchpad/widgets/whitelist/images/icon_32x32.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/index.html
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/index.html?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/whitelist/index.html (added)
+++ incubator/wookie/trunk/scratchpad/widgets/whitelist/index.html Thu Mar 24
11:51:41 2011
@@ -0,0 +1,74 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="pragma" content="no-cache"/>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <script type="text/javascript" src="scripts/controller.js"
charset="utf-8"></script>
+ <title>whitelist</title>
+ </head>
+ <body onLoad="Controller.init()">
+ <div data-role="page" id="home">
+
+ <div data-role="header">
+ <h4>Whitelist</h4>
+ <a onClick="Controller.update()"
data-role="button" data-icon="refresh" data-iconpos="notext">Refresh</a>
+ <a href="#add" data-rel="dialog"
data-transition="pop" data-role="button" data-icon="plus">Add</a>
+ </div> <!-- /header -->
+
+ <div data-role="content" class="ui-content">
+ <ul data-role="listview" id="entries-listview">
+ </ul>
+ </div><!-- /content -->
+ </div><!-- /page -->
+
+ <div data-role="dialog" id="detail">
+ <div data-role="header">
+ <h4>Entry Details</h4>
+ </div> <!-- /header -->
+
+ <div data-role="content" class="ui-content">
+ <p><b>URL:</b> <span id="detail-url"></span></p>
+ <p>We could put some stats here from the
proxy...</p>
+ <button id="revoke-button">Remove this
entry</button>
+ <button id="cancel-button"
onclick="$('#detail').dialog('close')">Cancel</button>
+ </div><!-- /content -->
+ </div>
+
+ </div><!-- /page -->
+
+ <div data-role="dialog" id="add">
+
+ <div data-role="header">
+ <h4>Add New Entry</h4>
+ </div> <!-- /header -->
+ <div data-role="content" class="ui-content">
+ <div data-role="fieldcontain">
+ <label for="input-url">URL:</label>
+ <input type="text" name="input-url"
id="input-url" value="" />
+ </div>
+ <button id="submit-button"
onclick="Controller.add()">OK</button>
+ <a href="#home" data-transition="pop"
data-direction="reverse" data-role="button">Cancel</div>
+
+ </div><!-- /content -->
+ </div>
+
+ </div><!-- /page -->
+
+ </body>
+</html>
\ No newline at end of file
Added: incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/controller.js
URL:
http://svn.apache.org/viewvc/incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/controller.js?rev=1084916&view=auto
==============================================================================
--- incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/controller.js
(added)
+++ incubator/wookie/trunk/scratchpad/widgets/whitelist/scripts/controller.js
Thu Mar 24 11:51:41 2011
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * The Controller object
+ * This is used to wire up the view and model with actions
+ */
+var Controller = {
+ init:function() {
+ Controller.update();
+ },
+
+ /**
+ * Update whitelist entries from the REST API
+ */
+ update:function() {
+ $.getJSON("/wookie/whitelist?format=json", Controller.updateList);
+
+ },
+
+ updateList:function(data){
+ var index = $('#entries-listview');
+ index.empty();
+ for(entry in data.entries){
+ index.append($("<li/>")
+ .append($("<a/>")
+ .attr("onClick", "Controller.viewEntry(" +
data.entries[entry].id +",\"" + data.entries[entry].url + "\")")
+ .text(data.entries[entry].url)
+ )
+ );
+ }
+ index.listview("refresh");
+ },
+
+ viewEntry:function(id, url){
+ $("#detail-url").text(url);
+ $("#revoke-button").unbind();
+ $("#revoke-button").click(function(){
+ Controller.revokeEntry(id);
+ });
+ $.mobile.changePage("#detail");
+ },
+
+ revokeEntry: function(id){
+ $.ajax({
+ url: "/wookie/whitelist/"+id,
+ type:"DELETE",
+ success: function(){
+ Controller.update();
+ $('#detail').dialog('close');
+ }
+ });
+ },
+
+ add: function(){
+ var url = $("#input-url").val();
+ $.ajax({
+ url: "/wookie/whitelist/",
+ data: {"url": url},
+ type:"POST",
+ success: function(){
+ Controller.update();
+ $('#add').dialog('close');
+ }
+ });
+ },
+
+}
\ No newline at end of file