+list.prototype.count = function() {
+ return this.elements.length;
+};
+
+
+/*
+ * resources, users, leases
+ */
+
+function resources() {
+ this.pending = {
+ toremove: new list(),
+ toadd: new list(),
+ };
+};
+
+function leases() {
+ this.pending = {
+ toremove: new list(),
+ toadd: new list(),
+ };
+};
+
+function users() {
+ this.pending = {
+ toremove: new list(),
+ toadd: new list(),
+ };
+};
+
+/*
+ * Slice
+ */
+function slice(name) {
+ this.name = name;
+ this.resources = new resources();
+ this.users = new users();
+ this.leases = new leases();
+
+};
+
+
+/*
+ * User
+ */
+function user(user) {
+ this.user = user;
+ this.testbeds = new list();
+ this.slices = new list();
+
+ for (i = 0; i < this.user.slices.length; i++) {
+ this.slices[this.user.slices[i]] = new slice(this.user.slices[i]);
+ }
+};
+
+user.prototype.slice = function(name) {
+ return this.slices[name];
+};
+
+user.prototype.list = function() {
+ for (s in this.slices) {
+ for (o in s) {
+ if (typeof o != 'function') {
+ console.log(o);
+ } else {
+ console.log("w "+o);
+ }
+ }
+ }
+};
+
+/*
+ * MySlice
+ */
+var myslice = {
+ user: {},
+
+ user: function() {
+ if ($.isEmptyObject(this.user)) {
+ //this.login(function() { return this.user; });
+ if(localStorage.getItem('user')!='undefined'){
+ this.user = JSON.parse(localStorage.getItem('user'));
+ }else{
+ return false;
+ }
+ }
+ return this.user;
+ },
+
+ login: function(fn) {
+ user = localStorage.getItem('user');
+ if($.isEmptyObject(user)){
+ $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
+ //myslice.user = new user(data[0]);
+ localStorage.setItem('user', JSON.stringify(data[0]));
+ });
+ }
+ },
+
+ getSlices: function(name) {
+