9 list.prototype.save = function() {
10 for (var prop in this) {
11 if (typeof this[prop] != 'function') {
12 console.log("prop: " + prop);
14 console.log("func: " + prop);
17 //localStorage.setItem(name, JSON.stringify(value));
20 list.prototype.load = function(name) {
21 this.pending = JSON.parse(localStorage.getItem(name));
27 list.prototype.add = function(element) {
28 if (!this.has(element)) {
29 this.elements.push(element);
33 list.prototype.del = function(element) {
34 if (this.has(element)) {
35 this.elements.splice(index, 1);
39 list.prototype.has = function(element) {
40 index = $.inArray( element, this.elements );
47 list.prototype.count = function() {
48 return this.elements.length;
53 * resources, users, leases
56 function resources() {
80 function slice(name) {
82 this.resources = new resources();
83 this.users = new users();
84 this.leases = new leases();
87 slice.prototype.pending = function() {
90 slice.prototype.reserve = function() {
93 slice.prototype.unreserve = function() {
105 for (i = 0; i < this.u.slices.length; i++) {
106 this.slices[this.u.slices[i]] = new slice(this.u.slices[i]);
110 user.prototype.slice = function(name) {
111 return this.slices[name];
114 user.prototype.list = function() {
115 for (s in this.slices) {
117 if (typeof o != 'function') {
132 getSlices: function(name) {
136 refreshUser: function() {
142 //$('div#loading').show();
145 //setTimeout(function(){
146 //$('div#loading').hide();
147 //window.location.href = '/resources/' + this.slice + '?message=true';
152 $.post("/rest/slice/", { 'fields': ['resource','slice_hrn'], 'filters': { 'slice_hrn' : this.slice } }, function(data) {
157 if ('resource' in data[0]) {
158 $.each(data[0].resource, function(idx, r) {
159 resources.push(r.urn);
163 console.log(myslice.pending);
164 console.log(resources);
165 $.each(resources.concat(myslice.pending), function(idx, v) {
169 $.post("/update/slice/", { 'filters': { 'slice_hrn' : myslice.slice }, 'params' : update }, function(data) {
173 console.log(this.slice);
181 // var Reflector = function(obj) {
182 // this.getProperties = function() {
183 // var properties = [];
184 // for (var prop in obj) {
185 // if (typeof obj[prop] != 'function') {
186 // properties.push(prop);
187 // console.log("prop: " + prop);
189 // console.log("func: " + prop);
192 // return properties;
195 // var reflector = new Reflector(myslice.slices[0].resources.pending);
196 // reflector.getProperties();
199 $(document).ready(function() {
200 // $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function(data) {
201 // myslice.user = new user(data[0]);
202 // console.log(myslice.user.slices);
203 // myslice.user.list();
205 // }).fail(function() {
206 // throw "error retreiving user data";
208 // Put the object into storage
209 //localStorage.setItem('testObject', JSON.stringify(testObject));
211 // Retrieve the object from storage
217 // add a resource to pending
219 myslice.user.slice('ple.upmc.myslicedemo').resources.pending.add(resource);