Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 62873e90a01ad36c790fe80e2da6b3b2ded11061 1 parent 828eb66
@mcongrove mcongrove authored
Showing with 674 additions and 0 deletions.
  1. +556 −0 api-test-tool.js
  2. +83 −0 index.html
  3. +35 −0 json2.js
View
556 api-test-tool.js
@@ -0,0 +1,556 @@
+var api_tool = new function () {
+ this.categories = ["video", "playlist"];
+ this.method = null;
+ this.mode = "v";
+ this.ret = "";
+ this.store = {
+ "token": ""
+ };
+ this.fields_video = ["name", "id", "referenceId", "accountId", "shortDescription", "longDescription", "FLVURL", "renditions", "creationDate", "publishedDate", "lastModifiedDate", "startDate", "endDate", "linkURL", "linkText", "tags", "videoStillURL", "thumbnailURL", "length", "economics", "cuePoints", "playsTotal", "playsTrailingWeek", "FLVFullLength", "videoFullLength"];
+ this.fields_playlist = ["id", "referenceId", "accountId", "name", "shortDescription", "videoIds", "videos", "playlistType", "thumbnailURL"];
+ this.parameters_video = ["token", "output", "page_size", "page_number", "sort_by", "sort_order", "fields", "get_item_count", "video_id", "reference_id", "video_ids", "reference_ids", "user_id", "campaign_id", "text", "and_tags", "or_tags", "video_fields", "from_date", "filter", "custom_fields", "media_delivery"];
+ this.parameters_playlist = ["token", "output", "page_size", "page_number", "sort_by", "sort_order", "fields", "get_item_count", "playlist_id", "reference_id", "playlist_ids", "reference_ids", "player_id", "playlist_fields", "video_fields", "custom_fields", "media_delivery"];
+ this.options_video = [
+ {
+ "method": "find_all_videos",
+ "required": [0],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_video_by_id",
+ "required": [0, 8],
+ "optional": [1, 6, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_related_videos",
+ "required": [0],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [8, 9],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_ids",
+ "required": [0, 10],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_video_by_reference_id",
+ "required": [0, 9],
+ "optional": [1, 6, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_reference_ids",
+ "required": [0, 11],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_user_id",
+ "required": [0, 12],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_campaign_id",
+ "required": [0, 13],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_text",
+ "required": [0, 14],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_videos_by_tags",
+ "required": [0],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 20, 21],
+ "exclusive": [15, 16],
+ "inclusive": []
+ },
+ {
+ "method": "find_modified_videos",
+ "required": [0, 18],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 17, 18, 20, 21],
+ "exclusive": [],
+ "inclusive": []
+ }
+ ];
+ this.options_playlist = [
+ {
+ "method": "find_all_playlists",
+ "required": [0],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_playlist_by_id",
+ "required": [0, 8],
+ "optional": [1, 6, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_playlists_by_ids",
+ "required": [0, 10],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_playlist_by_reference_id",
+ "required": [0, 9],
+ "optional": [1, 6, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_playlists_by_reference_ids",
+ "required": [0, 11],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ },
+ {
+ "method": "find_playlists_for_player_id",
+ "required": [0, 12],
+ "optional": [1, 2, 3, 4, 5, 6, 7, 13, 14, 15, 16],
+ "exclusive": [],
+ "inclusive": []
+ }
+ ];
+ this.tips_video = [
+ { "title": "API READ TOKEN", "tip": "Tokens are required to access the API." },
+ { "title": "OUTPUT FORMAT", "tip": "Valid values are <i>json</i> and <i>mrss</i>. Specifying <i>json</i> will result in a <a href='http://json.org' target='_blank'>Javascript notated object</a> being returned. The <i>mrss</i> format will result in a media rss feed. If nothing is specified, <i>json</i> is assumed." },
+ { "title": "PAGE SIZE", "tip": "The page size can be any number up to 100. This parameter affects the number of videos returned by an API call, and when used with <i>page_number</i>, it will affect the offset of the first returned result." },
+ { "title": "PAGE NUMBER", "tip": "The page number can be any number that falls within the total number of videos divided by the <i>page_size</i> value. For instance, 100 videos will have 5 total pages when a <i>page_size</i> of 20 is specified." },
+ { "title": "SORT BY", "tip": "The <i>sort_by</i> parameter allows for you to specify which attribute of a video to sort the results on. Valid values include <i>PUBLISH_DATE</i>, <i>CREATION_DATE</i>, <i>MODIFIED_DATE</i>, <i>PLAYS_TOTAL</i>, and <i>PLAYS_TRAILING_WEEK</i>." },
+ { "title": "SORT ORDER", "tip": "The order applied to the <i>sort_by</i> parameter. Valid values are either <i>ASC</i> or <i>DESC</i>." },
+ { "title": "OBJECT FIELDS", "tip": "By default, a number of attributes are returned as part of the video DTO. The API allows for these to be modified to suit your needs, so simply check the fields you require and they will be included in the resulting object. Valid values are listed for ease of use." },
+ { "title": "TOTAL ITEM COUNT", "tip": "Sometimes it helps to know exactly how many videos exist, even if you're only fetching a few of them. By setting <i>get_item_count</i> to true, the total video count matching the specified parameters will be included in the API return object. If set to false, -1 is returned." },
+ { "title": "VIDEO ID", "tip": "Videos in the Brightcove system have unique 64 bit integer identifiers. Video IDs can be found in the returned video objects of any call which includes the <i>id</i> field. Identifiers can also be found in the Brightcove console." },
+ { "title": "REFERENCE ID", "tip": "Reference IDs are unique values, specified by you, to make identification of videos easier. These values can be set in the Brightcove console or via the write API." },
+ { "title": "VIDEO ID SET", "tip": "Some methods make use of more than one video ID. When this is the case, those IDs are specified as a comma-separated set. For instance, <i>7220004001,7218020001,7223593001</i> would execute the API call on the three specified videos." },
+ { "title": "REFERENCE ID SET", "tip": "Like video IDs, sometimes you need to request a set of videos by multiple reference IDs. When this is the case, simply use a comma-separated set of reference IDs: <i>apple_juice,eggyweggs,bacon</i>" },
+ { "title": "USER ID", "tip": "Videos uploaded through the CGM module will contain a unique user ID that can be used to retrieve videos." },
+ { "title": "CAMPAIGN ID", "tip": "Videos uploaded through the CGM module will also contain a campaign ID that can be used to determine which campaign the upload originated from." },
+ { "title": "TEXT", "tip": "Videos can be found by searching for specified text values. The text field simply takes a string which is then matched against video properties." },
+ { "title": "REQUIRE ALL TAGS", "tip": "Using <i>and_tags</i> requires that all tags specified exist on the returned videos. This is a stricter tag match than that of <i>or_tags</i>. When more than one tag is specified, use a comma-separated set: tag_one,tag_two,tag_three" },
+ { "title": "REQUIRE ANY TAGS", "tip": "When you need to find videos containing any of a number of tags, <i>or_tags</i> is the way to go. Like <i>and_tags</i>, this parameter takes one or more tags and matches videos against them. In this case, however, videos will be returned if they match any number of the given tags, rather than requiring that it match them all." }
+ ];
+ this.tips_playlist = [
+ { "title": "API READ TOKEN", "tip": "Tokens are required to access the API." },
+ { "title": "OUTPUT FORMAT", "tip": "Valid values are <i>json</i> and <i>mrss</i>. Specifying <i>json</i> will result in a <a href='http://json.org' target='_blank'>Javascript notated object</a> being returned. The <i>mrss</i> format will result in a media rss feed. If nothing is specified, <i>json</i> is assumed." },
+ { "title": "PAGE SIZE", "tip": "The page size can be any number up to 100. This parameter affects the number of playlists returned by an API call, and when used with <i>page_number</i>, it will affect the offset of the first returned result." },
+ { "title": "PAGE NUMBER", "tip": "The page number can be any number that falls within the total number of playlists divided by the <i>page_size</i> value. For instance, 100 playlists will have 5 total pages when a <i>page_size</i> of 20 is specified." },
+ { "title": "SORT BY", "tip": "The <i>sort_by</i> parameter allows for you to specify which attribute of a playlist to sort the results on. Valid values include <i>PUBLISH_DATE</i>, <i>CREATION_DATE</i>, and <i>MODIFIED_DATE</i>." },
+ { "title": "SORT ORDER", "tip": "The order applied to the <i>sort_by</i> parameter. Valid values are either <i>ASC</i> or <i>DESC</i>." },
+ { "title": "OBJECT FIELDS", "tip": "By default, a number of attributes are returned as part of the playlist DTO. The API allows for these to be modified to suit your needs, so simply check the fields you require and they will be included in the resulting object. Valid values are listed for ease of use." },
+ { "title": "TOTAL ITEM COUNT", "tip": "Sometimes it helps to know exactly how many playlists exist, even if you're only fetching a few of them. By setting <i>get_item_count</i> to true, the total playlist count matching the specified parameters will be included in the API return object. If set to false, -1 is returned." },
+ { "title": "PLAYLIST ID", "tip": "Playlists in the Brightcove system have unique 64 bit integer identifiers. Playlist IDs can be found in the returned playlist objects of any call which includes the <i>id</i> field. Identifiers can also be found in the Brightcove console." },
+ { "title": "REFERENCE ID", "tip": "Reference IDs are unique values, specified by you, to make identification of playlists easier. These values can be set in the Brightcove console or via the write API." },
+ { "title": "PLAYLIST ID SET", "tip": "Some methods make use of more than one playlist ID. When this is the case, those IDs are specified as a comma-separated set. For instance, <i>7220004001,7218020001,7223593001</i> would execute the API call on the three specified playlists." },
+ { "title": "REFERENCE ID SET", "tip": "Like playlist IDs, sometimes you need to request a set of playlists by multiple reference IDs. When this is the case, simply use a comma-separated set of reference IDs: <i>apple_juice,eggyweggs,bacon</i>" },
+ { "title": "PLAYER ID", "tip": "Playlists are sometimes assigned to players, such as with a tabbed video player. When you have a player ID, it is possible to select the assigned playlists by specifying it." }
+ ];
+
+ this.init = function () {
+ document.write("<select id='api_tool_methods' onchange='api_tool.builder();'>");
+ document.write("<option>VIDEO</option>");
+
+ for (var i = 0; i < this.options_video.length; i++) {
+ document.write("<option value='" + this.options_video[i].method + "'>" + this.options_video[i].method + "</option>");
+ }
+
+ document.write("<option></option><option>PLAYLIST</option>");
+
+ for (var i = 0; i < this.options_playlist.length; i++) {
+ document.write("<option value='" + this.options_playlist[i].method + "'>" + this.options_playlist[i].method + "</option>");
+ }
+
+ document.write("</select>");
+ }
+
+ this.builder = function () {
+ var s = document.getElementById("api_tool_methods").value;
+ var m = (s.indexOf("video") > 0) ? "v" : "p";
+
+ api_tool.test(m, s);
+ api_tool.make();
+
+ return false;
+ }
+
+ this.test = function (v, s) {
+ api_tool.method = s;
+ api_tool.mode = v;
+
+ if (v == "v") {
+ for (var i = 0; i < api_tool.options_video.length; i++) {
+ if (api_tool.options_video[i].method == s) {
+ document.getElementById("api_tool_pie").innerHTML = "";
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Required</h2>";
+
+ for (var j = 0; j < api_tool.options_video[i].required.length; j++) {
+ var z = api_tool.parameters_video[api_tool.options_video[i].required[j]];
+
+ if (z == "token") {
+ v = api_tool.store.token;
+ } else {
+ v = "";
+ }
+
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' value='" + v + "' />" + q + ": </div>";
+ }
+
+ if (api_tool.options_video[i].exclusive.length > 0) {
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Choose Only One</h2>";
+ }
+
+ for (var j = 0; j < api_tool.options_video[i].exclusive.length; j++) {
+ z = api_tool.parameters_video[api_tool.options_video[i].exclusive[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+
+ if (api_tool.options_video[i].inclusive.length > 0) {
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Choose At Least One</h2>";
+ }
+
+ for (var j = 0; j < api_tool.options_video[i].inclusive.length; j++) {
+ z = api_tool.parameters_video[api_tool.options_video[i].inclusive[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Optional</h2>";
+
+ for (var j = 0; j < api_tool.options_video[i].optional.length; j++) {
+ z = api_tool.parameters_video[api_tool.options_video[i].optional[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ if (z == "fields") {
+ var x = "<h2><span onclick='api_tool.raw(false, \"tip\", \"fields\")'>Fields</span></h2>";
+ x += "<div id='api_tool_fields'><input class='text' style='display:none;' type='text' name='fields' value='hi!' />";
+
+ for (var k = 0; k < api_tool.fields_video.length; k++) {
+ x += "<div class='api_tool_field_row'><input type='checkbox' onclick='api_tool.make();' name='" + api_tool.fields_video[k] + "' />" + api_tool.fields_video[k] + ": </div>";
+ }
+
+ x += "</div>";
+
+ document.getElementById("api_tool_juice").innerHTML = x;
+ } else if (z == "get_item_count") {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><select onchange='api_tool.make();' id='api_tool_" + z + "'><option value='true'>True</option><option value='false'>False</option></select>" + q + ": </div>";
+ } else if (z == "output") {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><select onchange='api_tool.make();' id='api_tool_" + z + "'><option value='json'>JSON</option><option value='mrss'>MRSS</option></select>" + q + ": </div>";
+ } else {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+ }
+ }
+ }
+ } else {
+ for (var i = 0; i < api_tool.options_playlist.length; i++) {
+ if (api_tool.options_playlist[i].method == s) {
+ document.getElementById("api_tool_pie").innerHTML = "";
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Required</h2>";
+
+ for (var j = 0; j < api_tool.options_playlist[i].required.length; j++) {
+ var z = api_tool.parameters_playlist[api_tool.options_playlist[i].required[j]];
+
+ if (z == "token") {
+ v = api_tool.store.token;
+ } else {
+ v = "";
+ }
+
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' value='" + v + "' />" + q + ": </div>";
+ }
+
+ if (api_tool.options_playlist[i].exclusive.length > 0) {
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Choose Only One</h2>";
+ }
+
+ for (var j = 0; j < api_tool.options_playlist[i].exclusive.length; j++) {
+ z = api_tool.parameters_playlist[api_tool.options_playlist[i].exclusive[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+
+ if (api_tool.options_playlist[i].inclusive.length > 0) {
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Choose At Least One</h2>";
+ }
+
+ for (var j = 0; j < api_tool.options_playlist[i].inclusive.length; j++) {
+ z = api_tool.parameters_playlist[api_tool.options_playlist[i].inclusive[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+
+ document.getElementById("api_tool_pie").innerHTML += "<h2>Optional</h2>";
+
+ for (var j = 0; j < api_tool.options_playlist[i].optional.length; j++) {
+ z = api_tool.parameters_playlist[api_tool.options_playlist[i].optional[j]];
+ var q = "<span onclick='api_tool.raw(false, \"tip\", \"" + z + "\")'>" + z + "</span>";
+
+ if (z == "fields") {
+ var x = "<h2><span onclick='api_tool.raw(false, \"tip\", \"fields\")'>Fields</span></h2>";
+ x += "<div id='api_tool_fields'><input class='text' style='display:none;' type='text' name='fields' value='hi!' />";
+
+ for (var k = 0; k < api_tool.fields_playlist.length; k++) {
+ x += "<div class='api_tool_field_row'><input type='checkbox' onclick='api_tool.make();' name='" + api_tool.fields_playlist[k] + "' />" + api_tool.fields_playlist[k] + ": </div>";
+ }
+
+ x += "</div>";
+
+ document.getElementById("api_tool_juice").innerHTML = x;
+ } else if (z == "get_item_count") {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><select onchange='api_tool.make();' id='api_tool_" + z + "'><option value='true'>True</option><option value='false'>False</option></select>" + q + ": </div>";
+ } else if (z == "output") {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><select onchange='api_tool.make();' id='api_tool_" + z + "'><option value='json'>JSON</option><option value='mrss'>MRSS</option></select>" + q + ": </div>";
+ } else {
+ document.getElementById("api_tool_pie").innerHTML += "<div class='api_tool_row'><input class='text' onblur='api_tool.make();' type='text' name='" + z + "' />" + q + ": </div>";
+ }
+ }
+ }
+ }
+ }
+ }
+
+ this.make = function () {
+ var u = "";
+ var s = document.getElementById("api_tool_wrapper").getElementsByTagName("input");
+
+ if ("v" == "\v") {
+ for (var i in s) {
+ if ((s[i].getAttribute("type") == "text") && (s[i].value.length > 0) && (s[i].id != "api_tool_cake")) {
+ if (s[i].getAttribute("name") == "fields") {
+ var z = "";
+ var f = document.getElementsByTagName("input");
+
+ for (var l in f) {
+ if ((f[l].getAttribute("type") == "checkbox") && (f[l].checked)) {
+ z += f[l].getAttribute("name") + ",";
+ }
+ }
+
+ z = z.substr(0, (z.length - 1));
+
+ if (z.length > 0) {
+ u += s[i].getAttribute("name") + "=" + z + "&";
+ }
+ } else {
+ u += s[i].getAttribute("name") + "=" + s[i].value + "&";
+
+ if (s[i].getAttribute("name") == "token") {
+ api_tool.store.token = s[i].value;
+ }
+ }
+ }
+ }
+ } else {
+ for (var i = 0; i < s.length; i++) {
+ if ((s[i].getAttribute("type") == "text") && (s[i].value.length > 0) && (s[i].id != "api_tool_cake")) {
+ if (s[i].getAttribute("name") == "fields") {
+ var z = "";
+ var f = document.getElementsByTagName("input");
+
+ for (var l = 0; l < f.length; l++) {
+ if ((f[l].getAttribute("type") == "checkbox") && (f[l].checked)) {
+ z += f[l].getAttribute("name") + ",";
+ }
+ }
+
+ z = z.substr(0, (z.length - 1));
+
+ if (z.length > 0) {
+ u += s[i].getAttribute("name") + "=" + escape(z) + "&";
+ }
+ } else {
+ u += s[i].getAttribute("name") + "=" + escape(s[i].value) + "&";
+
+ if (s[i].getAttribute("name") == "token") {
+ api_tool.store.token = s[i].value;
+ }
+ }
+ }
+ }
+ }
+
+ if (document.getElementById("api_tool_get_item_count") != undefined) {
+ var c = document.getElementById("api_tool_get_item_count").value || false;
+ c = (c == "true") ? "&get_item_count=true" : "";
+ } else {
+ var c = "";
+ }
+
+ var j = document.getElementById("api_tool_output").value;
+ api_tool.store.output = j;
+ j = (j == "mrss") ? "&output=mrss" : "";
+
+ var v = "http://api.brightcove.com/services/library?command=" + api_tool.method + "&" + u.substr(0, (u.length - 1)) + c + j;
+
+ document.getElementById("api_tool_cake").value = v;
+
+ if (api_tool.store.output != "json") {
+ api_tool.raw(true);
+
+ document.getElementById("api_tool_berries").src = v;
+ document.getElementById("api_tool_cookies").innerHTML = "";
+
+ return;
+ } else {
+ api_tool.raw(false, "formatted");
+ }
+
+ api_tool.inject(v);
+ }
+
+ this.inject = function (s) {
+ var n = document.createElement("script");
+ n.setAttribute("src", s + "&callback=api_tool.handler");
+ n.setAttribute("type", "text/javascript");
+
+ document.getElementsByTagName("head")[0].appendChild(n);
+ };
+
+ this.handler = function (s) {
+ api_tool.ret = "";
+ api_tool.handle(s);
+
+ document.getElementById("api_tool_ice_cream").innerHTML = api_tool.ret;
+ document.getElementById("api_tool_cookies").innerHTML = JSON.stringify(s, null, "<span></span>");
+ }
+
+ this.handle = function (s, z) {
+ z = z || 10;
+
+ for (var v in s) {
+ if ((typeof s[v] != "string") && (typeof s[v] != "number") && (s[v] != null)) {
+ j = "<div class='api_tool_state'>&ndash;</div>";
+
+ api_tool.ret += "<div class='api_tool_nest-" + z + "' onclick='api_tool.click(this); return false;'>" + j + v + ":</div><div class='api_tool_collapse'>";
+ api_tool.handle(s[v], z + 20);
+ api_tool.ret += "</div>";
+ } else {
+ api_tool.ret += "<div class='api_tool_nest-" + z + "'>" + v + ": " + s[v] + "</div>";
+ }
+ }
+ }
+
+ this.click = function (s) {
+ if (s.nextSibling.className == "api_tool_collapse") {
+ if (s.nextSibling.style.display == "none") {
+ s.nextSibling.style.display = "block";
+
+ s.getElementsByTagName("div")[0].innerHTML = "&ndash;";
+ } else {
+ s.nextSibling.style.display = "none";
+
+ s.getElementsByTagName("div")[0].innerHTML = "+";
+ }
+ }
+ }
+
+ this.collapse_all = function () {
+ var d = document.getElementsByTagName("div");
+
+ for (var i = 0; i < d.length; i++) {
+ if (d[i].className == "api_tool_collapse") {
+ d[i].style.display = "none";
+ }
+ }
+ }
+
+ this.expand_all = function () {
+ var d = document.getElementsByTagName("div");
+
+ for (var i = 0; i < d.length; i++) {
+ if (d[i].className == "api_tool_collapse") {
+ d[i].style.display = "block";
+ }
+ }
+ }
+
+ this.raw = function (v, x, q) {
+ v = v || false;
+ x = x || "raw";
+ q = q || false;
+
+ var m = document.getElementById("api_tool_right");
+ var r = document.getElementById("api_tool_cookies");
+ var f = document.getElementById("api_tool_ice_cream");
+ var s = document.getElementById("api_tool_steak");
+ var b = document.getElementById("api_tool_berries");
+ var c = document.getElementById("api_tool_cookbook");
+
+ if (v) {
+ m.style.display = "block";
+ r.style.display = "none";
+ f.style.display = "none";
+ c.style.display = "none";
+ b.style.display = "block";
+ } else if (x == "tip") {
+ m.style.display = "none";
+ r.style.display = "none";
+ f.style.display = "none";
+ b.style.display = "none";
+ c.style.display = "block";
+
+ if (api_tool.mode == "v") {
+ for (var i = 0; i < api_tool.parameters_video.length; i++) {
+ if (api_tool.parameters_video[i] == q) {
+ c.innerHTML = "<h2>" + api_tool.tips_video[i].title + "</h2><div class='api_tool_row'>" + api_tool.tips_video[i].tip + "</div>";
+ }
+ }
+ } else {
+ for (var i = 0; i < api_tool.parameters_playlist.length; i++) {
+ if (api_tool.parameters_playlist[i] == q) {
+ c.innerHTML = "<h2>" + api_tool.tips_playlist[i].title + "</h2><div class='api_tool_row'>" + api_tool.tips_playlist[i].tip + "</div>";
+ }
+ }
+ }
+
+ s.innerHTML = "back";
+ } else if ((r.style.display == "none") && (x == "raw")) {
+ m.style.display = "block";
+ r.style.display = "block";
+ f.style.display = "none";
+ b.style.display = "none";
+ c.style.display = "none";
+
+ s.innerHTML = "formatted";
+ } else {
+ m.style.display = "block";
+ c.style.display = "none";
+ r.style.display = "none";
+ b.style.display = "none";
+ f.style.display = "block";
+
+ s.innerHTML = "raw";
+ }
+ }
+}();
View
83 index.html
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <script src="api-test-tool.js" type="text/javascript"></script>
+ <script src="json2.js" type="text/javascript"></script>
+</head>
+<body>
+
+<div id="api_tool_wrapper">
+ <div class="api_tool_header">
+ <h1>
+ API Method:
+ </h1>
+
+ <script type="text/javascript">
+ api_tool.init();
+ </script>
+
+ <br class="clear" />
+ </div>
+
+ <div id="api_tool_stripe">
+ <input id="api_tool_cake" type="text" onfocus="this.select();" />
+
+ <br class="clear" />
+ </div>
+
+ <div id="api_tool_left">
+ <div id="api_tool_pie">
+ <h2 class="api_tool_welcome">
+ Welcome
+ </h2>
+
+ <div class="api_tool_row">
+ This tool will allow you to test the Brightcove Media Read API methods.
+ </div>
+ </div>
+
+ <div id="api_tool_juice">
+ <div class="api_tool_row">
+ On the top left of this page, you"ll notice a drop-down menu containing API methods grouped by which media type they relate to; videos or playlists. To get started, select the method you would like to try out. You'll need your Brightcove read API token handy, as you'll need to enter it in the resulting form.
+ </div>
+
+ <div class="api_tool_row">
+ Choosing methods causes forms on the page to dynamically update, making it clear which parameters can, and need, to be specified. As the values of these parameters are altered, the results of the API call will appear in a formatted tree view in the "return" box to the right, and the URL used to get that data will appear in the header of the page.
+ </div>
+
+ <div class="api_tool_row">
+ The tree view allows you to expand and collapse sections of the return in order to traverse it easily and inspect the data returned. This view can also be toggled to show the exact return data by clicking the "raw" link in the header of the return box.
+ </div>
+ </div>
+ </div>
+
+ <div id="api_tool_cookbook" style="display:none;"></div>
+
+ <div id="api_tool_right">
+ <div class="api_tool_heading">
+ <div class="api_tool_state" onclick="api_tool.raw(); return false;" id="api_tool_steak">raw</div>
+ <div class="api_tool_state" onclick="api_tool.expand_all(); return false;">+</div>
+ <div class="api_tool_state" onclick="api_tool.collapse_all(); return false;">&ndash;</div>
+
+ <h2>
+ Return
+ </h2>
+ </div>
+
+ <div id="api_tool_ice_cream">
+ <div class="api_tool_nest-10">
+ API return data will appear here.
+ </div>
+ </div>
+
+ <pre id="api_tool_cookies" style="display:none;"></pre>
+
+ <iframe id="api_tool_berries" style="display:none;" src="about:blank"></iframe>
+ </div>
+
+ <br class="clear" />
+</div>
+
+</body>
+</html>
View
35 json2.js
@@ -0,0 +1,35 @@
+/*
+ http://www.JSON.org/json2.js
+ 2010-11-17
+ Public Domain: NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
+ See http://www.JSON.org/js.html
+*/
+
+if(!this.JSON){this.JSON={};}
+(function(){"use strict";function f(n){return n<10?'0'+n:n;}
+if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+
+f(this.getUTCMonth()+1)+'-'+
+f(this.getUTCDate())+'T'+
+f(this.getUTCHours())+':'+
+f(this.getUTCMinutes())+':'+
+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}
+var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}
+function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}
+if(typeof rep==='function'){value=rep.call(holder,key,value);}
+switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}
+gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}
+v=partial.length===0?'[]':gap?'[\n'+gap+
+partial.join(',\n'+gap)+'\n'+
+mind+']':'['+partial.join(',')+']';gap=mind;return v;}
+if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}
+v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+
+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}
+if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}
+rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}
+return str('',{'':value});};}
+if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}
+return reviver.call(holder,key,value);}
+text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+
+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}
+if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}
+throw new SyntaxError('JSON.parse');};}}());

0 comments on commit 62873e9

Please sign in to comment.
Something went wrong with that request. Please try again.