Detect link to GDoc in KPI script report
Change-Id: I181439fdc740b2ed89449d3971ceadd82fde36ce
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var g_doc_pattern = /.*docs.google.com.*\/d\/(.+)\/.*/;
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
function processTextArea() {
|
function processTextArea() {
|
||||||
@@ -15,8 +17,18 @@
|
|||||||
var url_vars = getUrlVars();
|
var url_vars = getUrlVars();
|
||||||
|
|
||||||
if ("url" in url_vars) {
|
if ("url" in url_vars) {
|
||||||
$("#kpi_url").val(url_vars["url"]);
|
var url = url_vars["url"];
|
||||||
$.get(url_vars["url"],function (data) {
|
$("#kpi_url").val(url);
|
||||||
|
$("#source_link").attr("href", url);
|
||||||
|
|
||||||
|
var pattern_match = g_doc_pattern.exec(url);
|
||||||
|
if (pattern_match) {
|
||||||
|
var doc_id = pattern_match[1];
|
||||||
|
url = "https://docs.google.com/feeds/download/documents/export/Export?id=" + doc_id + "&exportFormat=txt";
|
||||||
|
console.log(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.get(url,function (data) {
|
||||||
$("#kpi_script").val(data);
|
$("#kpi_script").val(data);
|
||||||
processTextArea();
|
processTextArea();
|
||||||
}).fail(function(){
|
}).fail(function(){
|
||||||
@@ -41,6 +53,7 @@
|
|||||||
<label for="kpi_url">URL:</label>
|
<label for="kpi_url">URL:</label>
|
||||||
<input id="kpi_url" style="width: 45em;" name="url"/>
|
<input id="kpi_url" style="width: 45em;" name="url"/>
|
||||||
<input type="submit" value="Load">
|
<input type="submit" value="Load">
|
||||||
|
<span><a href="" id="source_link">View Source</a></span>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<label for="kpi_script"></label>
|
<label for="kpi_script"></label>
|
||||||
|
Reference in New Issue
Block a user