Sfoglia il codice sorgente

small border ajustment

Juergen 'eTM' Mangler 3 anni fa
parent
commit
7453f17eda
4 ha cambiato i file con 24 aggiunte e 49 eliminazioni
  1. 8 42
      frames
  2. 2 0
      frames.xml
  3. 2 2
      template/css/frames.css
  4. 12 5
      template/js/ui.js

+ 8 - 42
frames

@@ -68,7 +68,6 @@ class InitFrame < Riddl::Implementation
   #end
 end
 
-
 #https://coderwall.com/p/atyfyq/ruby-string-to-boolean
 #showbutton
 class String
@@ -79,7 +78,6 @@ class String
   end
 end
 
-
 class NewFrameSet < Riddl::Implementation
   def response
 
@@ -95,16 +93,15 @@ class NewFrameSet < Riddl::Implementation
       end
     end
 
-    urls = JSON::parse(@p[6].value);
+    urls = JSON::parse(@p[7].value);
 
 
-    if @p[7].value == ""
-      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, default: "{}", callback: @h['CPEE_CALLBACK']};
+    if @p[8].value == ""
+      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, style: @p[6].value, default: "{}", callback: @h['CPEE_CALLBACK']};
     else
-      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, default: JSON::parse(@p[7].value), callback: @h['CPEE_CALLBACK']};
+      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value,  style: @p[6].value, default: JSON::parse(@p[8].value), callback: @h['CPEE_CALLBACK']};
     end
 
-
     data_hash["data"].push(hash)
     File.write(path, JSON.dump(data_hash))
 
@@ -119,8 +116,6 @@ class NewFrameSet < Riddl::Implementation
   end
 end
 
-
-
 class NewFrameWait < Riddl::Implementation
   def response
     path = File.join('data',@r.last,'frames.json')
@@ -134,11 +129,11 @@ class NewFrameWait < Riddl::Implementation
       end
     end
 
-    urls = JSON::parse(@p[6].value);
-    if @p[7].value == ""
-      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, default: "{}", callback: @h['CPEE_CALLBACK']};
+    urls = JSON::parse(@p[7].value);
+    if @p[8].value == ""
+      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, style: @p[6].value, default: "{}", callback: @h['CPEE_CALLBACK']};
     else
-      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, default: JSON::parse(@p[7].value), callback: @h['CPEE_CALLBACK']};
+      hash = {lx: @p[1].value.to_i, ly: @p[2].value.to_i, rx: (@p[1].value.to_i + @p[3].value.to_i - 1), ry: (@p[2].value.to_i + @p[4].value.to_i - 1), url: urls, showbutton: @p[5].value, style: @p[6].value, default: JSON::parse(@p[8].value), callback: @h['CPEE_CALLBACK']};
     end
     data_hash["data"].push(hash)
     File.write(path, JSON.dump(data_hash))
@@ -156,7 +151,6 @@ class NewFrameWait < Riddl::Implementation
   end
 end
 
-
 class DeleteFrame < Riddl::Implementation
   def response
     path = File.join('data',@r.last,'frames.json')
@@ -173,7 +167,6 @@ class DeleteFrame < Riddl::Implementation
   end
 end
 
-
 def doOverlap(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
   if l1x > r2x || l2x > r1x
       return false;
@@ -184,10 +177,6 @@ def doOverlap(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y)
   return true;
 end
 
-
-
-
-
 class Delete < Riddl::Implementation
   def response
     if cbu = File.read(File.join('data',@r.last,'callback'))
@@ -212,7 +201,6 @@ class Delete < Riddl::Implementation
   end
 end
 
-
 class GetFrames < Riddl::Implementation #{{{
   def response
     fname = File.join('data',@r[-2],'frames.json')
@@ -235,7 +223,6 @@ class GetFrames < Riddl::Implementation #{{{
   end
 end #}}}
 
-
 class SetDataElements < Riddl::Implementation #{{{
   def response
     savejson = @p.map { |o| Hash[o.name, o.value] }.to_json
@@ -272,7 +259,6 @@ class GetDataElements < Riddl::Implementation #{{{
   end
 end #}}}
 
-
 class GetInfo < Riddl::Implementation #{{{
   def response
     fname = File.join('data',@r[-2],'info.json')
@@ -343,18 +329,12 @@ class GetCpeeInstance < Riddl::Implementation #{{{
   end
 end #}}}
 
-
-
 class OutputTest < Riddl::Implementation #{{{
   def response
     puts "Test"
   end
 end #}}}
 
-
-
-
-
 class Handler < Riddl::Implementation
   def response
     puts "handler"
@@ -389,10 +369,6 @@ class Handler < Riddl::Implementation
   end
 end
 
-
-
-
-
 class SSE < Riddl::SSEImplementation #{{{
   def onopen
     signals = @a[0]
@@ -408,8 +384,6 @@ class SSE < Riddl::SSEImplementation #{{{
   end
 end #}}}
 
-
-
 class SSE2 < Riddl::SSEImplementation #{{{
   def onopen
     signals = @a[0]
@@ -481,12 +455,6 @@ server = Riddl::Server.new(File.join(__dir__,'/frames.xml'), :host => 'localhost
 
       run DeleteFrame, opts[:signals][idx] if post 'deleteframe'
 
-
-
-
-
-
-
       on resource 'handler' do
         run Handler, opts[:signals2]["handler"] if post
         on resource 'sse' do
@@ -494,8 +462,6 @@ server = Riddl::Server.new(File.join(__dir__,'/frames.xml'), :host => 'localhost
         end
       end
 
-
-
       run Delete, opts[:signals][idx] if delete 'opa'
       run Delete, opts[:signals][idx] if delete 'opb'
       on resource 'sse' do

+ 2 - 0
frames.xml

@@ -31,6 +31,7 @@
     <parameter name="x_amount" type="nonNegativeInteger"/>
     <parameter name="y_amount" type="nonNegativeInteger"/>
     <parameter name="button" type="string"/>
+    <parameter name="style" type="string"/>
     <parameter name="urls" type="string"/>
     <parameter name="default" type="string"/>
   </message>
@@ -41,6 +42,7 @@
     <parameter name="x_amount" type="nonNegativeInteger"/>
     <parameter name="y_amount" type="nonNegativeInteger"/>
     <parameter name="button" type="string"/>
+    <parameter name="style" type="string"/>
     <parameter name="urls" type="string"/>
     <parameter name="default" type="string"/>
   </message>

+ 2 - 2
template/css/frames.css

@@ -41,8 +41,8 @@ body {
 
 .formbutton{
   position: relative;
-  top: -6em;
-  right: 2em;
+  bottom: 4.8em;
+  right: 0.8em;
   z-index: 9;
   padding: 1em;
   float: right;

+ 12 - 5
template/js/ui.js

@@ -15,7 +15,7 @@ function doOverlap(l1x, l1y, r1x, r1y, l2x, l2y, r2x, r2y) {
 }
 
 
-function makeFrame(lx, ly, rx, ry, content = "", id = "", defaultpara = "", showbutton = "") {
+function makeFrame(lx, ly, rx, ry, content = "", id = "", defaultpara = "", showbutton = "", style = "") {
   //check if rects overlap if they do remove old ones
   for (i = 0; i < window.storage.length; i++) {
     if(doOverlap(window.storage[i].lx, window.storage[i].ly, window.storage[i].rx, window.storage[i].ry, lx, ly, rx, ry)){
@@ -69,8 +69,6 @@ function makeFrame(lx, ly, rx, ry, content = "", id = "", defaultpara = "", show
       }
     }
     
-    //defaultpara
-    console.log(defaultpara);
     
     
     fullurl = encodeURI(fullurl);
@@ -80,6 +78,15 @@ function makeFrame(lx, ly, rx, ry, content = "", id = "", defaultpara = "", show
       $(".item" + lx + "-" + ly).append('<button class="formbutton" type="button" onclick="sendForm(\'' + '.item' + lx + '-' + ly +'\', \'' + encodeURIComponent(id) + '\', \'' + lx  + '\', \'' + ly  + '\')">' + showbutton + '</button>')
     }
     
+    if(style){    
+      $(".item" + lx + "-" + ly).find("iframe").on('load', function(){
+        $(this).contents().find("head").append($("<link/>", 
+          { rel: "stylesheet", href: style, type: "text/css" }
+        ));
+      });      
+    }
+    
+    
     //hideRectangel(lx, ly, rx, ry)
   }
   else{
@@ -180,7 +187,7 @@ function showDocument() {
         url: 'frames.json',
         success: function(ret2) {
           for (i in ret2.data) {
-            makeFrame(ret2.data[i].lx,ret2.data[i].ly,ret2.data[i].rx,ret2.data[i].ry, ret2.data[i].url, ret2.data[i].callback, ret2.data[i].default, ret2.data[i].showbutton);
+            makeFrame(ret2.data[i].lx,ret2.data[i].ly,ret2.data[i].rx,ret2.data[i].ry, ret2.data[i].url, ret2.data[i].callback, ret2.data[i].default, ret2.data[i].showbutton, ret2.data[i].style);
           }
         }
       });
@@ -308,7 +315,7 @@ function init() {
         try {
           //alert(e.data)
           var frd = JSON.parse(e.data)
-          makeFrame(frd.lx,frd.ly,frd.rx,frd.ry, frd.url, frd.callback, frd.default, frd.showbutton);
+          makeFrame(frd.lx,frd.ly,frd.rx,frd.ry, frd.url, frd.callback, frd.default, frd.showbutton, frd.style);
         }
         catch (e) {
         }