Skip to content

Instantly share code, notes, and snippets.

@XP1
Created September 21, 2012 11:07
Show Gist options
  • Save XP1/3760918 to your computer and use it in GitHub Desktop.
Save XP1/3760918 to your computer and use it in GitHub Desktop.
Get Macromedia Breeze URIs: Outputs a list of the URIs for a Macromedia Breeze presentation so that you can download the entire presentation.
/*
* Copyright 2012 XP1
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*jslint browser: true, vars: true, maxerr: 50, indent: 4 */
(function (console, window) {
"use strict";
var uri = {};
uri.webpage = window.location.href;
uri.path = uri.webpage.substring(0, uri.webpage.lastIndexOf("/"));
uri.viewer = uri.path + "/viewer.swf";
uri.viewerData = uri.path + "/data/viewer.xml";
uri.components = uri.path + "/components.swf";
uri.vconfig = uri.path + "/data/vconfig.xml";
var uris = [
uri.path + "/",
uri.webpage,
uri.viewer,
uri.components,
uri.viewerData,
uri.vconfig
];
function pushSearchDataUris(searchDataUri) {
var request = new XMLHttpRequest();
request.open("GET", searchDataUri, false);
request.send(null);
var path = uri.path;
var content = request.responseXML;
var elements = content.querySelectorAll("[href]:not(view-link)");
var i = null;
var length = elements.length;
for (i = 0; i < length; i += 1) {
var element = elements[i];
var current = path + "/" + element.getAttribute("href");
if (uris.indexOf(current) === -1) {
uris.push(current);
}
}
}
function pushViewerDataUris() {
var request = new XMLHttpRequest();
request.open("GET", uri.viewerData, false);
request.send(null);
var path = uri.path;
var content = request.responseXML;
var elements = content.querySelectorAll("[url]");
var i = null;
var length = elements.length;
for (i = 0; i < length; i += 1) {
var element = elements[i];
var current = path + "/data/" + element.getAttribute("url");
if (uris.indexOf(current) === -1) {
uris.push(current);
if (element.nodeName.toLowerCase() === "search") {
pushSearchDataUris(current);
}
}
}
}
pushViewerDataUris();
console.log(uris.join("\r\n"));
}(this.console, this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment