mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-28 13:39:44 +07:00
* Remove docs folder. This was a redirect from a GitHub pages site that does not appear to be in use. * Rename api folder to api-samples. * Move examples to functional-samples folder. * Move cookbook sample to functional-samples. * Move tutorials to functional-samples folder. * Move mv2 and apps folders to _archive. * Rename tools folder to .repo. * Move reference folder to functional-samples. * Update README. Update README with new relative links for reorg. * Update README.md Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com> --------- Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>
90 lines
2.2 KiB
JavaScript
90 lines
2.2 KiB
JavaScript
function $(q) {
|
|
return document.querySelector(q);
|
|
}
|
|
|
|
function show(q) {
|
|
$(q).classList.remove('hide');
|
|
}
|
|
|
|
function hide(q) {
|
|
$(q).classList.add('hide');
|
|
}
|
|
|
|
function validFileName(path) {
|
|
if (!path.length) {
|
|
error('Empty name was given.');
|
|
return false;
|
|
}
|
|
if (path.indexOf('/') >= 0) {
|
|
error('File name should not contain any slash (/): "' + path + '"');
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function log(msg) {
|
|
document.getElementById('log').innerHTML = msg;
|
|
console.log(msg, arguments);
|
|
}
|
|
|
|
function createElement(name, attributes) {
|
|
var elem = document.createElement(name);
|
|
for (var key in attributes) {
|
|
if (key == 'id')
|
|
elem.id = attributes[key];
|
|
else if (key == 'innerText')
|
|
elem.innerText = attributes[key];
|
|
else
|
|
elem.setAttribute(key, attributes[key]);
|
|
}
|
|
return elem;
|
|
}
|
|
|
|
function info(msg) {
|
|
console.log('INFO: ', arguments);
|
|
var e = document.getElementById('info');
|
|
e.innerText = msg;
|
|
e.classList.remove('hide');
|
|
window.setTimeout(function() { e.innerHTML = ''; }, 5000);
|
|
}
|
|
|
|
function error(msg) {
|
|
console.log('ERROR: ', arguments);
|
|
var message = '';
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
var description = '';
|
|
if (arguments[i] instanceof FileError) {
|
|
switch (arguments[i].code) {
|
|
case FileError.QUOTA_EXCEEDED_ERR:
|
|
description = 'QUOTA_EXCEEDED_ERR';
|
|
break;
|
|
case FileError.NOT_FOUND_ERR:
|
|
description = 'NOT_FOUND_ERR';
|
|
break;
|
|
case FileError.SECURITY_ERR:
|
|
description = 'SECURITY_ERR';
|
|
break;
|
|
case FileError.INVALID_MODIFICATION_ERR:
|
|
description = 'INVALID_MODIFICATION_ERR';
|
|
break;
|
|
case FileError.INVALID_STATE_ERR:
|
|
description = 'INVALID_STATE_ERR';
|
|
break;
|
|
default:
|
|
description = 'Unknown Error';
|
|
break;
|
|
}
|
|
message += ': ' + description;
|
|
} else if (arguments[i].fullPath) {
|
|
message += arguments[i].fullPath + ' ';
|
|
} else {
|
|
message += arguments[i] + ' ';
|
|
}
|
|
}
|
|
var e = document.getElementById('error');
|
|
e.innerText = 'ERROR:' + message;
|
|
e.classList.remove('hide');
|
|
window.setTimeout(function() { e.innerHTML = ''; }, 5000);
|
|
}
|
|
|