View Single Post
  #1  
Old 11-03-2011, 07:47 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
QR Code Generator Problem

I have recently been playing around with googles API for generating QR codes and have thought, hey why not make one in graal.
So I went on my merry way to script it and this is what I have so far, but theres one huge problem... It doesnt display the image, instead it displays some sort of Binary Dump, any suggestions are appriciated.
In case you do not know what a QR code is click here and it will explain it in greater depth, its a 2D image that stores Binary and can be read extremly fast, it was designed for car parts originally but when they realised how powerful it was they then went on to use it for alot more.
Im not even sure if this task can be achieved in the boundaries of GS2 but hey, its worth a shot.

My Script..
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
Generate_Window.destroy();
  
Generated_Window.destroy();
}

function 
onPlayerChats() {
  if (
player.chat == "/generate") {
    if (
Generate_Window.visible == "1") {
      
Generate_Window.destroy();
      return;
    }
    
CreateGenGUI();
  }
}

function 
CreateGeneratedGUI() {
  new 
GuiWindowCtrl("Generated_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "300,  250";

    
canclose true;
    
canmaximize false;
    
canminimize false;
    
canmove false;
    
canresize false;
    
closequery false;
    
destroyonhide false;
    
isexternal false;
    
text "Generated QR Code";
    
screenwidth width 2;
    
screenheight height 2;
    
alpha 1;

    new 
GuiScrollCtrl("Generated_MultiLine_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 249;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 300;
      
0;
      
0;

      new 
GuiMLTextCtrl("Generated_MultiLine") {
        
profile GuiBlueMLTextProfile;
        
height 231;
        
horizsizing "width";
        
text "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
        
width 296;
      }
    }
  }
}

function 
CreateGenGUI() {
  new 
GuiWindowCtrl("Generate_Window") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "150,82";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text " QR Code Generator";
    
screenwidth width 2;
    
screenheight height 2;

    new 
GuiTextEditCtrl("Generate_Encode") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 137;
      
7;
      
23;
    }
    new 
GuiTextCtrl("Generate_Text") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Enter the text to encode!";
      
width 139;
      
6;
    }
    new 
GuiButtonCtrl("Generate_Generate") {
      
profile GuiBlueButtonProfile;
      
text "Generate";
      
width 137;
      
7;
      
48;
    }
  }
}

function 
Generate_Generate.onAction() {
  if (
Generate_Encode.text != null) {
    
Generated_Window.destroy();
    
Generate_Window.destroy();
    
CreateGeneratedGUI();
    
Generated_MultiLine.text "<center><br><br><br><br><br>Generating QR Code.<br>Please wait.";
    
temp.req requesturl("http://chart.apis.google.com/chart?chs=150x150&cht=qr&chld=L|0&chl=" Generate_Encode.text "");
    
this.catchevent(temp.req"onReceiveData""onSiteDownloaded");
  }
}

function 
onSiteDownloaded(obj) {
  
Generated_MultiLine.text "<img src=" obj.fulldata ">";

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote