38 lines
No EOL
2.2 KiB
JavaScript
38 lines
No EOL
2.2 KiB
JavaScript
(function(browserchrome, $) {
|
|
var htmlTemplate = '<div class="browser-chrome-container"><div class="browser-chrome-header"><i class="icon-remove-sign"></i> <i class="icon-minus-sign"></i> <i class="icon-plus-sign"></i><div class="browser-chrome-tab"><div class="browser-chrome-tab-wrapper"><div class="browser-chrome-tab-content"><i class="icon-file-alt icon-large"></i> <span class="tab-title">Tab Title</span></div></div></div><div class="user-icon-container"><i class="icon-user icon-2x"></i></div></div><div class="browser-chrome-url-bar"><div class="left-controls"><i class="icon-arrow-left icon-large"></i> <i class="icon-arrow-right icon-large"></i> <i class="icon-rotate-right icon-large"></i> </div><div class="right-controls"> <i class="icon-reorder icon-large"></i></div><div class="browser-chrome-url"><span class="protocol-https" style="display: none"><i class="icon-lock"></i>https</span><span class="protocol-http"><i class="icon-file-alt"></i>http</span><span class="url-text">://google.com/</span></div></div></div>'
|
|
|
|
browserchrome.update = function() {
|
|
$('[data-screenshot-url]').each(function(index, element) {
|
|
var elem = $(element);
|
|
if (!elem.data('has-chrome')) {
|
|
// Create chrome
|
|
var createdHtml = $(htmlTemplate);
|
|
|
|
// Add the new chrome to the page where the image was
|
|
elem.replaceWith(createdHtml);
|
|
|
|
// Add the image to the new browser chrome html
|
|
createdHtml.append(elem);
|
|
|
|
// Set the tab title
|
|
var tabTitle = elem.attr('title') || elem.data('tab-title');
|
|
createdHtml.find('.tab-title').text(tabTitle);
|
|
|
|
// Pick the protocol and set the url
|
|
var url = elem.data('screenshot-url');
|
|
if (url.substring(0, 6) === 'https:') {
|
|
createdHtml.find('.protocol-http').hide();
|
|
createdHtml.find('.protocol-https').show();
|
|
url = url.substring(5);
|
|
} else {
|
|
createdHtml.find('.protocol-http').hide();
|
|
createdHtml.find('.protocol-https').show();
|
|
url = url.substring(4);
|
|
}
|
|
createdHtml.find('.url-text').text(url);
|
|
|
|
elem.data('has-chrome', 'true');
|
|
}
|
|
});
|
|
};
|
|
}(window.browserchrome = window.browserchrome || {}, window.jQuery)); |