1
0
mirror of synced 2025-11-06 04:21:11 +08:00

Add: Resources iframe support

This commit is contained in:
surunzi
2018-02-05 16:52:25 +08:00
parent 7e5a67205f
commit 42e987b59f
2 changed files with 54 additions and 11 deletions

View File

@@ -126,6 +126,25 @@
{{/if}}
</ul>
</div>
<div class="eruda-section eruda-iframe">
<h2 class="eruda-title">
Iframe
<div class="eruda-btn eruda-refresh-iframe">
<span class="eruda-icon-repeat"></span>
</div>
</h2>
<ul class="eruda-link-list">
{{#if iframeData}}
{{#each iframeData}}
<li>
<a href="{{this}}" target="_blank" class="eruda-iframe-link">{{this}}</a>
</li>
{{/each}}
{{else}}
<li>Empty</li>
{{/if}}
</ul>
</div>
<div class="eruda-section eruda-image">
<h2 class="eruda-title {{imageState}}">
Image

View File

@@ -34,6 +34,7 @@ export default class Resources extends Tool
this._cookieData = [];
this._scriptData = [];
this._stylesheetData = [];
this._iframeData = [];
this._imageData = [];
this._observeElement = true;
this._tpl = require('./Resources.hbs');
@@ -56,6 +57,7 @@ export default class Resources extends Tool
.refreshCookie()
.refreshScript()
.refreshStylesheet()
.refreshIframe()
.refreshImage()._render();
}
destroy()
@@ -99,6 +101,24 @@ export default class Resources extends Tool
return this;
}
refreshIframe()
{
let iframeData = [];
$('iframe').each(function ()
{
let $this = $(this),
src = $this.attr('src');
if (src) iframeData.push(src);
});
iframeData = unique(iframeData);
this._iframeData = iframeData;
return this;
}
refreshLocalStorage()
{
this._refreshStorage('local');
@@ -226,6 +246,8 @@ export default class Resources extends Tool
.on('click', '.eruda-refresh-session-storage', () => this.refreshSessionStorage()._render())
.on('click', '.eruda-refresh-cookie', () => this.refreshCookie()._render())
.on('click', '.eruda-refresh-script', () => this.refreshScript()._render())
.on('click', '.eruda-refresh-stylesheet', () => this.refreshStylesheet()._render())
.on('click', '.eruda-refresh-iframe', () => this.refreshIframe()._render())
.on('click', '.eruda-refresh-image', () => this.refreshImage()._render())
.on('click', '.eruda-delete-storage', function ()
{
@@ -292,7 +314,8 @@ export default class Resources extends Tool
showSources('img', src);
})
.on('click', '.eruda-css-link', linkFactory('css'))
.on('click', '.eruda-js-link', linkFactory('js'));
.on('click', '.eruda-js-link', linkFactory('js'))
.on('click', '.eruda-iframe-link', linkFactory('iframe'));
orientation.on('change', () => this._render());
@@ -317,9 +340,12 @@ export default class Resources extends Tool
let url = $(this).attr('href');
if (!isCrossOrig(url))
if (type === 'iframe' || isCrossOrig(url))
{
return ajax({
showSources('iframe', url);
} else
{
ajax({
url,
success: data =>
{
@@ -327,10 +353,7 @@ export default class Resources extends Tool
},
dataType: 'raw'
});
} else
{
showSources('iframe', url);
}
}
};
}
}
@@ -371,13 +394,14 @@ export default class Resources extends Tool
this._renderHtml(this._tpl({
localStoreData: this._localStoreData,
sessionStoreData: this._sessionStoreData,
cookieData: cookieData,
cookieData,
cookieState: getState('cookie', cookieData.length),
scriptData: scriptData,
scriptData,
scriptState: getState('script', scriptData.length),
stylesheetData: stylesheetData,
stylesheetData,
stylesheetState: getState('stylesheet', stylesheetData.length),
imageData: imageData,
iframeData: this._iframeData,
imageData,
imageState: getState('image', imageData.length)
}));
}