script.jsx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //EXAMPLE
  2. //helper function to get URL parameters.
  3. var urlParams;
  4. (window.onpopstate = function () {
  5. var match,
  6. pl = /\+/g, // Regex for replacing addition symbol with a space
  7. search = /([^&=]+)=?([^&]*)/g,
  8. decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
  9. query = window.location.search.substring(1);
  10. urlParams = {};
  11. while (match = search.exec(query))
  12. urlParams[decode(match[1])] = decode(match[2]);
  13. })();
  14. /*------------------*/
  15. var config;
  16. if("config" in urlParams) {
  17. config = urlParams['config'];
  18. } else {
  19. var config = './reactor_config.json'; //default
  20. }
  21. $.ajax({
  22. url: config,
  23. dataType: 'json',
  24. cache: false,
  25. error: function(data) {
  26. console.log(data);
  27. },
  28. success: function(data) {
  29. //map through multiple contracts (this includes multiple ones in 1 file + different files).
  30. console.log(data);
  31. var reactor_config = parseConfig(data);
  32. //fetch template specific config information
  33. $.ajax({
  34. url: "personal_token_config.json",
  35. dataType: 'json',
  36. cache: false,
  37. })
  38. .done(function(data) {
  39. React.render(<Header data={data} />, document.getElementById('top'));
  40. React.render(<ContainerHelper templates={reactor_config.templates} compiled={reactor_config.total_compiled} addresses={reactor_config.addresses} options={reactor_config.options}/>, document.getElementById('contracts'));
  41. });
  42. }
  43. });