1 function AI_MemoryTag(typeUUIDStr){
4 this.type = typeUUIDStr;
5 this.createdDate = new Date();
7 AI_MemoryTag.prototype = {
8 Type_CandidateWord: "2fba8fc1-2b9a-46e0-8ade-455c0bd30637",
9 Type_Word: "d5eef85c-a796-4d04-bb72-8d45c94c5e4f",
10 //http://codedehitokoto.blogspot.jp/2012/01/javascriptuuid.html
13 var f = this.initUUIDSub;
14 this.uuid = f() + f() + "-" +
21 initUUIDSub: function(){
22 return (((1 + Math.random()) * 0x10000) | 0).toString(16).toLowerCase().substring(1);
24 parseToStringData: function(data){
30 d.cDate = this.createdDate.toUTCString();
34 return this.parseArrayToStringSource(d);
36 loadFromMemoryData: function(data){
38 this.type = data.type;
39 this.createdDate = new Date(data.cDate);
41 if(this.loadFromMemoryData != AI_MemoryTag.prototype.loadFromMemoryData){
42 this.loadFromMemoryData(data.data);
46 escapeForMemory: function(str){
47 return "\"" + str.replaceAll(":", "@:").replaceAll("\"", "\\\"") + "\"";
49 unescapeForMemory: function(str){
50 return str.replaceAll("@:", ":");
52 parseArrayToStringSource: function(anArray){
56 var srcstr = "var t=";
57 srcstr += this.parseArrayToStringSourceSub(anArray);
61 parseArrayToStringSourceSub: function(anArray){
66 for(var k in anArray){
68 var t = Object.prototype.toString.call(v);
69 if(v instanceof Array){
70 srcstr += k + ":" + this.parseArrayToStringSourceSub(v) + ",";
71 } else if(!isNaN(v) && v.toString().replace(/\s+/g, "").length > 0){
72 //isNaNだけでは数値判定できないので、文字列化後の空白文字を削除した長さも検査している。
73 srcstr += k + ":" + v + ",";
74 } else if(t == "[object String]"){
76 srcstr += k + ":'" + v + "',";
77 } else if(t == "[object Object]"){
78 srcstr += k + ":" + this.parseArrayToStringSourceSub(v) + ",";
80 srcstr += k + ":undefined,";
83 if(srcstr.charAt(srcstr.length - 1) == ","){
85 srcstr = srcstr.slice(0, srcstr.length - 1);