-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontract.js
More file actions
71 lines (48 loc) · 1.08 KB
/
contract.js
File metadata and controls
71 lines (48 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"use strict"
var JokerItem = function(text) {
if(text) {
// 解析json
var obj=JSON.parse(text);
this.content = obj.content;
this.account = obj.account;
}else {
this.content = "";
this.account = "";
}
};
JokerItem.prototype ={
toString :function() {
return JSON.stringify(this);
}
};
var Connotations = function (){
LocalContractStorage.defineMapProperty(this,"JokerMap",{
parse: function (text) {
return new JokerItem(text);
},
stringify: function (o) {
return o.toString();
}
});
LocalContractStorage.defineProperty(this, "length",null);
}
Connotations.prototype ={
init: function(){
this.length=0;
},
save: function(value){
var from= Blockchain.transaction.from;
var jokerItem = new JokerItem();
jokerItem.content=value;
jokerItem.account=from;
this.JokerMap.put(this.length,jokerItem);
this.length=this.length+1;
},
getJoker:function(x){
return this.JokerMap.get(x-1);
},
getlength: function(){
return this.length;
}
};
module.exports = Connotations;