Advertisement
Guest User

frontend.html to backend python.py

a guest
Jan 24th, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.73 KB | None | 0 0
  1. frontend.html + utils.js    with backend python script coefficient.py
  2.  
  3. <head>
  4.     <script type="text/javascript" src="utils.js"></script>
  5.    
  6.    
  7. </head>
  8. <body>
  9. <center>
  10.     <h2> Newtonian Coefficient</h2>
  11.     <p/>
  12.     <input type="text" name="filename" value="input.dat" onblur="ClearDefValue (this)" onfocus="SetDefValue (this)" />
  13.     <input type="button" width="15" value="run" onclick="RunExe();"/></input>
  14.     </p>
  15.  
  16. <div style="display: block; width: 100px; height: 20px; overflow: hidden;">
  17. <button style="width: 110px; height: 30px; position: relative; top: -5px; left: -5px;">
  18. <a href="javascript: void(0)">Upload File</a></button>
  19. <input type="file" id="upload_input" name="upload" style="font-size: 50px; width: 120px; opacity: 0; filter:alpha(opacity: 0);  position: relative; top: -40px;; left: -20px" />
  20.  
  21. </div>
  22.    
  23. <script type="text/javascript">
  24. function RunExe()
  25. {
  26. alert("In fun RunExe()..");
  27. netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
  28. alert("Done");
  29.  
  30. var exe = window.Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
  31. exe.initWithPath("coefficient.py");
  32. alert("exe");
  33. var run = window.Components.classes['@mozilla.org/process/util;1'].createInstance(Components.interfaces.nsIProcess);
  34. run.init(exe);
  35. var parameters = [""];
  36. run.run(false, parameters,parameters.length);
  37. alert("in function RunBat");
  38.  
  39. }
  40. <b> kappa front end study </b><br>
  41.    
  42.     </center>
  43.     </body>
  44.  
  45.  
  46. Utils.js
  47. function ClearDefValue (input) {
  48.         if (input.value == '')  {
  49.             input.value = input.defaultValue;
  50.         }
  51. }
  52. function SetDefValue (input) {
  53.         if (input.value == input.defaultValue) {
  54.             input.value = '';
  55.         }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement