mxVsdxModel.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * mxVsdxModel
  3. *
  4. */
  5. function mxVsdxModel()
  6. {
  7. };
  8. mxVsdxModel.prototype.decode = function(data)
  9. {
  10. var unzipFinished = 0;
  11. var srcDocs = new mxDictionary();
  12. zip.workerScripts = 'js/deflate/';
  13. zip.useWebWorkers = false;
  14. var unzipBlob = function(blob, callback)
  15. {
  16. zip.createReader(new zip.BlobReader(blob), function(zipReader)
  17. {
  18. zipReader.getEntries(function(entries)
  19. {
  20. for (var i = 0; i < entries.length; i++)
  21. {
  22. unzipFinished = unzipFinished + 1;
  23. (function(entry)
  24. {
  25. entry.getData(new zip.TextWriter(), function(text) {
  26. callback(entry, text);
  27. }, function()
  28. {
  29. // console.log('progress', arguments);
  30. });
  31. })(entries[i]);
  32. }
  33. });
  34. }, onerror);
  35. }
  36. var doc;
  37. var parser = new DOMParser();
  38. unzipBlob(data, function(entry, data)
  39. {
  40. doc = parser.parseFromString(data, 'text/xml');
  41. srcDocs.put(entry.filename, doc);
  42. unzipFinished = unzipFinished - 1;
  43. if (unzipFinished == 0)
  44. {
  45. //the point when we have a filled array of unzipped DOM documents.
  46. //getDocument(srcDocs, "visio/pages/page1.xml");
  47. };
  48. return null;
  49. });
  50. };