OSDN Git Service

commit iepg adding on web function.
authorgn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 31 Aug 2009 14:20:06 +0000 (14:20 +0000)
committergn64_jp <gn64_jp@4e526526-5e11-4fc0-8910-f8fd03428081>
Mon, 31 Aug 2009 14:20:06 +0000 (14:20 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/rec10@138 4e526526-5e11-4fc0-8910-f8fd03428081

Rec10WEB/trunk/src/fin.htm
Rec10WEB/trunk/src/finover.htm
Rec10WEB/trunk/src/iepg_add.htm
Rec10WEB/trunk/src/iepg_fin.htm
Rec10WEB/trunk/src/iepg_show.htm
Rec10WEB/trunk/src/rec10web.py
Rec10WEB/trunk/src/rec10web_dbMySQL.py
Rec10WEB/trunk/src/rswi.htm
Rec10WEB/trunk/src/rswi_edit.htm
Rec10WEB/trunk/src/schedule.htm

index 8c773b4..386be00 100644 (file)
@@ -1,3 +1,4 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
     <head>
index 1a0b6ac..c2ab3d2 100644 (file)
@@ -1,3 +1,4 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
     <head>
index 53e0eb2..71b4439 100644 (file)
@@ -1,3 +1,4 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
         <style type="text/css">
             @import "./dojo/dojo/resources/dojo.css";
             @import "./dojo/dijit/themes/tundra/tundra.css";
-
-
         </style>
         <script type="text/javascript">
-
             dojo.require("dojo.parser");
             // ※ ここで、使用するウィジェットの読み込みを行う
             dojo.require("dijit.form.Button");
             dojo.require("dijit.form.TextBox");
             dojo.require("dijit.form.Form");
+            dojo.require("dijit.form.ValidationTextBox");
+            dojo.require("dijit.form.FilteringSelect");
         </script>
   </head>
   <body class="tundra">
index 861b789..3c410b4 100644 (file)
@@ -1,3 +1,4 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
index 0a376e3..71f27ca 100644 (file)
@@ -1,7 +1,10 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+    <meta http-equiv="Content-Style-Type" content="text/css">
+    <meta http-equiv="Content-Script-Type" content="text/javascript">
     <title>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ表示</title>
     <script src="./dojo/dojo/dojo.js" djConfig="parseOnLoad:true">
         </script>
         <style type="text/css">
             @import "./dojo/dojo/resources/dojo.css";
             @import "./dojo/dijit/themes/tundra/tundra.css";
-
-
+            @import "./dojo/dojox/grid/resources/Grid.css";
+            @import "./dojo/dojox/grid/resources/tundraGrid.css";
         </style>
         <script type="text/javascript">
-
             dojo.require("dojo.parser");
             // ※ ここで、使用するウィジェットの読み込みを行う
+            dojo.require('dojox.grid.DataGrid');
+            dojo.require("dijit.form.Form"); 
             dojo.require("dijit.form.Button");
             dojo.require("dijit.form.TextBox");
-            dojo.require("dijit.form.Form");
-            var iepgStore = new dojo.data.ItemFileWriteStore({data:{items:[
-                        <!--text_for_replace_iepg//-->
-            ]}});
+            dojo.require("dojo.data.ItemFileWriteStore");
+            dojo.require("dijit.form.ValidationTextBox");
+            dojo.require("dojox.data.CsvStore");
+            dojo.require("dijit.form.TextBox");
+            dojo.require("dojox.grid.cells.dijit")
+            var iepgstore = new dojox.data.CsvStore({url:'./iepgdatum.csv'});
+            //var iepgStructure=[
+            //    {name:"ID",field:"id",width:"30px"},
+            //    {name:"チャンネル",field:"name",width:"200px"},
+            //    {name:"chtxt",field:"chtxt",width:"100px"}
+            //]
+            function changeGrid(grid){
+                var s=dijit.byId("iepgGrid").store.getValue(dijit.byId("iepgGrid").getItem(grid.rowIndex),"id");
+                var str=dijit.byId("iepg_delnum").value;
+                str=str+","+s;
+                dijit.byId("iepg_delnum").setValue(str);
+            };
+            dojo.addOnLoad(function(){
+                dojo.connect(dijit.byId("iepgGrid"),"onRowClick",changeGrid);
+                dojo.connect(dijit.byId("del"),"onClick",function(e){
+                    dijit.byId("MainForm").submit();
+                });
+            });
         </script>
   </head>
   <body class="tundra">
-    <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()">
+    <div dojoType="dijit.form.Form" action="rec10web.py" onExecute="this.submit()" id="MainForm">
         <h1>Rec10 Simple Web Interface ver.0.7.0 iEPGデータ表示</h1><br>
-        <table dojoType="dojox.grid.DataGrid" id="iepggrid" store="iepgStore">
+        <table dojoType="dojox.grid.DataGrid"
+            id="iepgGrid"
+            jsid="iepgGrid"
+            store="iepgstore"
+            query="{id:'*'}"
+            autoHeight="true"
+            width="100%"
+            autoHeight="true"
+            autoWidth="true"
+            clientSort="true"
+            onRowClick="changeGrid"
+            >
             <thead>
                 <tr>
-                    <th field="name" width="auto">放送局名</th>
-                    <th field="chtxt" width="auto">内部放送局コード(chtxt)</th>
+                    <th field="id" width="30px">ID</th>
+                    <th field="name" width="200px">チャンネル</th>
+                    <th field="chtxt" width="100px">chtxt</th>
                 </tr>
             </thead>
         </table>
+        </div>
+        <div dojoType="dijit.form.Button" type="submit" id="del">DEL</div>
+        <div name="exec"
+             dojoType="dijit.form.ValidationTextBox"
+             value="iepg-del"
+             style="display:none">
+        </div>
+        <div name="iepg_delnum:"
+             id="iepg_delnum"
+             dojoType="dijit.form.TextBox"
+             value=""
+             style="display:none">
+        </div>
     </div>
   </body>
 </html>
index 1edceeb..f8bc820 100644 (file)
@@ -84,6 +84,17 @@ def getRecDate():
     f=open(path+"/recdatum.csv","w")
     f.write(recdata)
     f.close()
+def getiEPGDate():
+    dl=database.select_all_iepg()
+    recdata="id,name,chtxt\n"
+    #print dl
+    s=""
+    for d in dl:
+        s=s+d[0]+","+d[1]+","+d[2]+"\n"
+    recdata=recdata+s
+    f=open(path+"/iepgdatum.csv","w")
+    f.write(recdata)
+    f.close()
 def getchtxt():
     dl=database.select_all_chdata()
     chopt=""
@@ -211,7 +222,11 @@ def change_reserv(id,type,keyword,chtxt,btime,etime,deltatime,opt,deltaday):
     return rett
 def station2chtxt(station):
     ret=""
-    sta=database.select_by_station_iepg(station):
+    #try:
+    database.new_iepg()
+    #except:
+    #    ""
+    sta=database.select_by_station_iepg(station)
     if len(sta)>0:
         ret=sta[0][1]
     else:
@@ -269,10 +284,6 @@ def mode_iepg_fin():
     return htmdate
 def mode_iepg_show():
     htmdate=readiEPGshow()
-    lsts=database.select_all_iepg()
-    s=""
-    for lst in lsts:
-        s=s+"{name:\""+lst[0]+"\",chtxt:\""+lst[1]+"\"},\n"
     return htmdate
 def mode_schedule():
     htmdate=readRecSchedule()
@@ -302,9 +313,6 @@ type="res"
 bt=""
 station_name=""
 mode=""
-getRecDate()
-if f.getfirst('mode')=="schedule":
-    getRecDate()
 ###ここからiEPG用の読み出し
 if f.getfirst('station_name'):
     station=f.getfirst('station_name')
@@ -363,14 +371,17 @@ if f.getfirst('exec',""):
     exect=f.getfirst('exec',"")
 if exect=="schedule":
     mode="schedule"
+    getRecDate()
 elif re.search('edit:',exect):
     mode="edit"
 elif exect=="iepg-add":
     mode="iepg-add"
 elif exect=="iepg-show":
     mode="iepg-show"
-elif exect=="iepg-add_yes"
+elif exect=="iepg-add_yes":
     mode="iepg-add-yes"
+elif exect=="iepg-del":
+    mode="iepg-del"
 htmdate= readHtmlSrcSimple()
 htmdate=htmdate.replace("<!--text_for_replace_chtxt_input//-->",getchtxt())
 htmdate=htmdate.replace("<!--btime-value//-->",btime)
@@ -419,7 +430,6 @@ if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(exe
     exect=""
 if (chtxt != "")and(title != "")and(btime!="")and(etime!="")and(opts!="")and(re.search('edit-exec:',exect)):
     editnum=exect.replace("edit-exec:","")
-    #restxt=change_reserv(id, type, keyword, chtxt, btime, etime, deltatime, opt, deltaday)
     restxt=change_reserv(editnum,type, title, chtxt, btime, etime, deltahour, opts, deltaday)
     if restxt=="":
         htmdate=readRecFinisSimple()
@@ -431,14 +441,22 @@ if mode=="schedule":
 elif mode=="edit":
     htmdate=mode_edit()
 elif mode=="iepg-add":
-    htmdate=mode_iepg_add(f.getfirst('iepg_station'))
+    htmdate=mode_iepg_add(station_name)
 elif mode=="iepg-add-yes":
+    try:
+        database.new_iepg()
+    except:
+        ""
     if f.getfirst('iepg_station') and f.getfirst('iepg_chtxt'):
         database.add_iepg(f.getfirst('iepg_station'),f.getfirst('iepg_chtxt'))
     htmdate=mode_iepg_fin()
 elif mode=="iepg-show":
+    getiEPGDate()
     htmdate=mode_iepg_show()
-print "Content-Type: text/html\n"
+elif mode=="iepg-del":
+    print f
+print "Content-Type: text/html"
 print htmdate
-
+#print exect
+#print mode
 
index 6366402..b8b6f88 100644 (file)
@@ -186,47 +186,67 @@ class DB_MySQL:
         self.close_db(db)
     def new_iepg(self):
         db=self.connect_db()
-        db[1].execute("\
-        CREATE TABLE iepg \
+        try:
+            db[1].execute("CREATE TABLE iepg \
             (\
+            id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,\
             station VARCHAR(200) NOT NULL,\
-            chtxt VARCHAR(30) NOT NULL,\
-            UNIQUE uniepg(type,chtxt)\
+            chtxt VARCHAR(30) NOT NULL\
             )")
+        except:
+            ""
         self.close_db(db)
     def add_iepg(self,station,chtxt):
         db=self.connect_db()
-        db[1].execute('INSERT IGNORE INTO iepg VALUES (%s,%s)', (station,chtxt))
+        db[1].execute('INSERT IGNORE INTO iepg (station,chtxt) VALUES (%s,%s)', (station,chtxt))
         self.close_db(db)
     def select_by_chtxt_iepg(self,chtxt):
         db=self.connect_db()
         db[1].execute("\
         SELECT \
-        station,chtxt \
+        id,station,chtxt \
         FROM iepg \
         WHERE chtxt=%s "\
         ,(chtxt,))
         retall=db[1].fetchall()
         self.close_db(db)
-        return retall
+        rets=[]
+        if len(retall)>0:
+            for ret in retall:
+                a=list(ret)
+                a[0]=str(ret[0])
+                rets.append(a)
+        return rets
     def select_by_station_iepg(self,station):
         db=self.connect_db()
         db[1].execute("\
         SELECT \
-        station,chtxt \
+        id,station,chtxt \
         FROM iepg \
         WHERE station=%s "\
         ,(station,))
         retall=db[1].fetchall()
         self.close_db(db)
-        return retall
+        rets=[]
+        if len(retall)>0:
+            for ret in retall:
+                a=list(ret)
+                a[0]=str(ret[0])
+                rets.append(a)
+        return rets
     def select_all_iepg(self):
         db=self.connect_db()
         db[1].execute("\
         SELECT \
-        station,chtxt \
+        id,station,chtxt \
         FROM iepg "\
-        ,(station,))
+        )
         retall=db[1].fetchall()
         self.close_db(db)
-        return retall
\ No newline at end of file
+        rets=[]
+        if len(retall)>0:
+            for ret in retall:
+                a=list(ret)
+                a[0]=str(ret[0])
+                rets.append(a)
+        return rets
\ No newline at end of file
index 8b6c93d..e8d074f 100644 (file)
         <style type="text/css">
             @import "./dojo/dojo/resources/dojo.css";
             @import "./dojo/dijit/themes/tundra/tundra.css";
-
-
         </style>
         <script type="text/javascript">
-
             dojo.require("dojo.parser");
             // ※ ここで、使用するウィジェットの読み込みを行う
-
             dojo.require("dijit.form.Button");
             dojo.require("dijit.form.FilteringSelect");
             dojo.require("dijit.form.ValidationTextBox");
index 8c21b0f..f0f7730 100644 (file)
@@ -1,3 +1,4 @@
+
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 <html>
     <head>
index 93486a9..3f24689 100644 (file)
@@ -15,8 +15,6 @@
             dojo.require('dojo.data.ItemFileReadStore');
             dojo.require('dojox.data.CsvStore');
             dojo.require('dojo.parser');
-
-
             // グリッドに表示する元データをロード
             var store = new dojox.data.CsvStore({url:'./recdatum.csv'});
             -->