-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml-element.html
More file actions
65 lines (56 loc) · 1.53 KB
/
xml-element.html
File metadata and controls
65 lines (56 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!--bower elements-->
<link rel="import" href="../polymer/polymer.html">
<link href="../xml_display/XMLDisplay.css" rel="stylesheet" async>
<!--scripts-->
<script src="../jquery/dist/jquery.min.js"></script>
<script src="../xml_display/XMLDisplay.js" async></script>
<dom-module id="xml-element">
<template>
<style>
:host {
width: 100%;
height: 100%
}
</style>
<div id="XMLViewer"></div>
</template>
<script>
Polymer({
is: 'xml-element',
properties: {
file: {
type: String,
value: null,
observer: 'fileChanged'
}
},
/**
* Observer for changes in the file url/path
* Loads the xml
* @return void
*/
fileChanged: function(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
LoadXMLString('XMLViewer', this.response);
}
};
xmlhttp.open("GET", this.file, true);
xmlhttp.send();
},
/**
* Force reload content by adding a parameter that will
* trigger a new download of the content
* @return void
*/
loadContent: function() {
if(this.file)
if(this.file.indexOf("?") > -1)
this.file = this.file.substring(0, this.file.indexOf("?")+1) + new Date().getTime();
else
this.file = this.file + "?" + new Date().getTime();
}
});
</script>
</dom-module>