Skip to content

Commit

Permalink
switch chrome.runtime for chrome.extension
Browse files Browse the repository at this point in the history
  • Loading branch information
kived committed Oct 30, 2013
1 parent f98b870 commit c9b4757
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion WebContent/background.js
Expand Up @@ -50,7 +50,7 @@ function refreshMenuEntry() {
}

function init() {
chrome.extension.onConnect.addListener(function(port) {
chrome.runtime.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
var workerFormatter, workerJSONLint, json = msg.json;

Expand Down
12 changes: 6 additions & 6 deletions WebContent/content.js
@@ -1,12 +1,12 @@
var port = chrome.extension.connect(), collapsers, options, jsonObject;
var port = chrome.runtime.connect(), collapsers, options, jsonObject;

function displayError(error, loc, offset) {
var link = document.createElement("link"), pre = document.body.firstChild.firstChild, text = pre.textContent.substring(offset), start = 0, ranges = [], idx = 0, end, range = document
.createRange(), imgError = document.createElement("img"), content = document.createElement("div"), errorPosition = document.createElement("span"), container = document
.createElement("div"), closeButton = document.createElement("div");
link.rel = "stylesheet";
link.type = "text/css";
link.href = chrome.extension.getURL("content_error.css");
link.href = chrome.runtime.getURL("content_error.css");
document.head.appendChild(link);
while (idx != -1) {
idx = text.indexOf("\n", start);
Expand All @@ -23,7 +23,7 @@ function displayError(error, loc, offset) {
errorPosition.className = "error-position";
errorPosition.id = "error-position";
range.surroundContents(errorPosition);
imgError.src = chrome.extension.getURL("error.gif");
imgError.src = chrome.runtime.getURL("error.gif");
errorPosition.insertBefore(imgError, errorPosition.firstChild);
content.className = "content";
closeButton.className = "close-error";
Expand All @@ -41,7 +41,7 @@ function displayError(error, loc, offset) {

function displayUI(theme, html) {
var statusElement, toolboxElement, expandElement, reduceElement, viewSourceElement, optionsElement, content = "";
content += '<link rel="stylesheet" type="text/css" href="' + chrome.extension.getURL("jsonview-core.css") + '">';
content += '<link rel="stylesheet" type="text/css" href="' + chrome.runtime.getURL("jsonview-core.css") + '">';
content += "<style>" + theme + "</style>";
content += html;
document.body.innerHTML = content;
Expand All @@ -66,7 +66,7 @@ function displayUI(theme, html) {
viewSourceElement.href = "view-source:" + location.href;
optionsElement = document.createElement("img");
optionsElement.title = "options";
optionsElement.src = chrome.extension.getURL("options.png");
optionsElement.src = chrome.runtime.getURL("options.png");
toolboxElement.appendChild(expandElement);
toolboxElement.appendChild(reduceElement);
toolboxElement.appendChild(viewSourceElement);
Expand All @@ -79,7 +79,7 @@ function displayUI(theme, html) {
expandElement.addEventListener('click', onexpand, false);
reduceElement.addEventListener('click', onreduce, false);
optionsElement.addEventListener("click", function() {
window.open(chrome.extension.getURL("options.html"));
window.open(chrome.runtime.getURL("options.html"));
}, false);
copyPathElement.addEventListener("click", function() {
port.postMessage({
Expand Down
2 changes: 1 addition & 1 deletion WebContent/csseditor.js
Expand Up @@ -4,7 +4,7 @@
var SAMPLE_PART2 = '</style><div id="json"><div class="collapser"></div>{<span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable"><span class="property">hey</span>: <span class="type-string">"guy"</span>,</div></li><li><div class="hoverable"><span class="property">anumber</span>: <span class="type-number">243</span>,</div></li><li><div class="hoverable"><span class="property">anobject</span>: <div class="collapser"></div>{<span class="ellipsis"></span><ul class="obj collapsible"><li><div class="hoverable"><span class="property">whoa</span>: <span class="type-string">"nuts"</span>,</div></li><li><div class="hoverable collapsed"><span class="property">anarray</span>: <div class="collapser"></div>[<span class="ellipsis"></span><ul class="array collapsible"><li><div class="hoverable"><span class="type-number">1</span>,</div></li><li><div class="hoverable"><span class="type-number">2</span>,</div></li><li><div class="hoverable"><span class="type-string">"thr&lt;h1&gt;ee"</span></div></li></ul>],</div></li><li><div class="hoverable hovered"><span class="property">more</span>: <span class="type-string">"stuff"</span></div></li></ul>},</div></li><li><div class="hoverable"><span class="property">awesome</span>: <span class="type-boolean">true</span>,</div></li><li><div class="hoverable"><span class="property">bogus</span>: <span class="type-boolean">false</span>,</div></li><li><div class="hoverable"><span class="property">meaning</span>: <span class="type-null">null</span>,</div></li><li><div class="hoverable"><span class="property">link</span>: <span class="type-string">"</span><a href="#">http://jsonview.com</a><span class="type-string">"</span>,</div></li><li><div class="hoverable"><span class="property">notLink</span>: <span class="type-string">"http://jsonview.com is great"</span></div></li></ul>}</div></body></html>';
var PASSIVE_KEYS = [ "Down", "Up", "Left", "Right", "End", "Home", "PageDown", "PageUp", "Control", "Alt", "Shift", "Insert" ];

var bgPage = chrome.extension.getBackgroundPage(), editor = document.getElementById("editor"), resetButton = document.getElementById("reset-button"), saveButton = document
var bgPage = chrome.runtime.getBackgroundPage(), editor = document.getElementById("editor"), resetButton = document.getElementById("reset-button"), saveButton = document
.getElementById("save-button"), previewer = document.getElementById("previewer").contentWindow, codemirror;

function updatePreview() {
Expand Down
2 changes: 1 addition & 1 deletion WebContent/manifest.json
Expand Up @@ -4,7 +4,7 @@
"16": "jsonview16.png",
"48": "jsonview48.png",
"128": "jsonview128.png"},
"version": "0.0.32",
"version": "0.0.32.1",
"description": "Validate and view JSON documents",
"options_page": "options.html",
"background" : {
Expand Down
2 changes: 1 addition & 1 deletion WebContent/options.js
@@ -1,5 +1,5 @@
function initOptions() {
var bgPage = chrome.extension.getBackgroundPage(), options = localStorage.options ? JSON.parse(localStorage.options) : {};
var bgPage = chrome.runtime.getBackgroundPage(), options = localStorage.options ? JSON.parse(localStorage.options) : {};
var safeMethodInput = document.getElementById("safeMethodInput"), injectInFrameInput = document.getElementById("injectInFrameInput"), addContextMenuInput = document.getElementById("addContextMenuInput");
safeMethodInput.checked = options.safeMethod;
injectInFrameInput.checked = options.injectInFrame;
Expand Down

0 comments on commit c9b4757

Please sign in to comment.