root/lang/javascript/nohada/textEdit.html @ 20319

Revision 20319, 3.1 kB (checked in by drry, 6 years ago)
  • fixed the CSS.
  • et cetera.
  • Property svn:mime-type set to text/html
Line 
1<html>
2<head>
3<meta http-equiv="Content-type" content="text/html; charsrt=utf-8">
4<title>テキストエディタ</title>
5<script src="js/prototype.js"></script>
6<script src="js/suggest.js"></script>
7<script src="js/common.js"></script>
8<script src="js/jsonScr.js"></script>
9<script src="js/findForm.js"></script>
10<script src="js/tag.js"></script>
11<script src="js/gui.js"></script>
12<script src="js/objEdit.js"></script>
13<link rel="Stylesheet" type="text/css" href="css/default.css">
14<script>
15var content="";
16var tagEditor;
17// JavaScript
18function onLoad() {
19   nagameru();
20   tagEditor=new ObjectEditor("tags");
21   tagEditor.setRelationFilter(function (rel) {
22       return rel.name!="content";
23
24   });
25}
26function nagameru() {
27  progn(
28   [dbGet, {category:"memo", content:["*"]} ],
29   [setView, gv("_")]
30  );
31}
32function setView(r) {
33   $("view").innerHTML="";
34   elem($("view"),
35      r.map(function (e) {
36         return ["span",
37            //[abutton,{onclick: [[yomu,e.id]]},"Edit"],["br"],
38            ["a", {
39               href:"javascript:void 0;",
40               onclick: function() {yomu(e.id);}
41            }, e.id],
42            ["br"],
43            digest(e.content),
44            ["br"]
45         ];
46      })
47   );
48}
49function digest(s) {
50   if (s.length<50) return s;
51   return s.substring(0,50)+"...";
52}
53function yomu(id) {
54  progn(
55   [dbGet,{id: id, content:["*"]}],
56   [function (o) {
57      obj=o[0];
58      $("id").innerHTML=obj.id;
59      $("text").value=obj.content;
60      content=obj.content;
61      tagEditor.setObjectID(obj.id);
62   },gv("_")]
63  );
64}
65var obj;
66function dispID() {
67   $("id").innerHTML=obj.id;
68}
69function save(next) {
70  if (obj==null) {
71    obj={category:"memo"};
72  }
73  if (next==null) next=NOP;
74  obj.content=$("text").value;
75  progn(
76    [dbPut, obj],
77    [print, "ほぞんしました: "],
78    function () {content=obj.content;},
79    dispID,
80//    [print, gv(obj,"id")],  // ちえんひょうか
81//  [print, obj.id]  //これはしっぱい
82    next
83  );
84}
85save.async=true;
86
87function mekuru() {
88   progn(save,clear);
89}
90function clear() {
91   $("text").value="";
92   content="";
93   $("id").value="";
94   obj=null;
95}
96var chgCnt=0;
97function changeLoop() {
98   if (content!=$("text").value) {
99      $("changed").innerHTML="へんこうあり";
100      chgCnt++;
101      if (chgCnt>5) {
102         chgCnt=0;
103         save();
104      }
105   } else {
106      $("changed").innerHTML="";
107      chgCnt=0;
108   }
109}
110setInterval(changeLoop, 1000);
111</script>
112</head>
113<body id=body onLoad="onLoad()">
114<span id=menu>
115<button onclick="save()">ほぞん</button>
116<button onclick="mekuru()">めくる</button>
117<button>やぶく</button>
118<button onclick="nagameru()">ながめる</button>
119さがす:<input type=text name=word>
120</span>
121
122<span id="view" class="view"></span>
123<div class="main">
124ID: <span id="id"></span> <span id="changed"></span> <BR>
125<textarea rows=30 cols=80 id=text></textarea>
126<BR>
127たぐ:
128<span id="tags"></span>
129<HR>
130<a href="./">Home</a><BR>
131<span id="console"></span>
132</div>
133</body>
134</html>
135
Note: See TracBrowser for help on using the browser.