daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 40 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <style>
  4. .achievement
  5. {
  6.     margin: 0px auto;
  7.     padding: 5px;
  8.     border: 1px solid red;
  9. }
  10. </style>
  11. <script type="text/javascript" src="checkpage.js"></script>
  12. <script type="text/javascript" src="jquery-latest.js"></script>
  13. <script type="text/ruby" src="rb/gather_xml_classless.rb"></script>
  14. <script type="text/javascript">
  15. function nullDataHandler(transaction, results) {}
  16. function errorHandler(transaction, error)
  17. {
  18.     // Error is a human-readable string.
  19.     alert('Error: '+error.message+' (Code '+error.code+')');
  20.  
  21.     return false;
  22. }
  23.  
  24. function openDB()
  25. {
  26.     try
  27.     {
  28.         if (!window.openDatabase)
  29.         {
  30.             alert('Database not supported');
  31.         }
  32.         else
  33.         {
  34.             var character = document.getElementById('character').innerHtml
  35.             var realm = document.getElementById('realm').innerHtml
  36.             var server = document.getElementById('server').innerHtml
  37.        
  38.             var shortName = 'wowach_' + character + "_" + realm + "_" + server;
  39.             var version = '1.0';
  40.             var displayName = 'Database for ' + character + " on " + realm + ":" + server;
  41.             var maxSize = 5242880; // in bytes: 5 megs
  42.             var mydb = openDatabase(shortName, version, displayName, maxSize);
  43.         }
  44.     }
  45.     catch(e)
  46.     {
  47.         // Error handling code goes here.
  48.         if (e == INVALID_STATE_ERR)
  49.         {
  50.             // Version number mismatch.
  51.             alert("Invalid database version.");
  52.         } else
  53.         {
  54.             alert("Unknown error "+e+".");
  55.         }
  56.     return;
  57.     }
  58.    
  59.     //we have a database now, try to create the table in case it is a new database
  60.     mydb.transaction(
  61.         function(transaction)
  62.         {   //Note: No errorhandler here, errors caused by the table existing will be ignored
  63.             transaction.executeSql('CREATE TABLE acheivements(id INTEGER NOT NULL PRIMARY KEY, categoryid INTEGER NOT NULL,dateCompleted TEXT NOT NULL, title TEXT NOT NULL, icon TEXT NOT NULL, desc TEXT NOT NULL);', [], nullDataHandler);      
  64.         }
  65.     );
  66.  
  67. }
  68.  
  69. function insertAchievement()
  70. {
  71.  
  72.     mydb.transaction(
  73.         function(transaction) {
  74.         transaction.executeSQL('Insert into acheivements (id, categoryid, dateCompleted, title, icon, desc) values ("'+id+'","'+categoryid+'","'+dateCompleted+'","'+title+'","'+icon+'","'+desc+'");', [], nullDataHandler, errorHandler);
  75.         }
  76.     );
  77. }
  78.  
  79.  
  80. function parse_data(data)
  81. {
  82.  
  83.     var parser = new DOMParser();
  84.     var dom = parser.parseFromString(data,"text/xml");
  85.     var entries = dom.getElementsByTagName('achievement');
  86.     var toreturn = '';
  87.     var done = '';
  88.    
  89.     var status = document.getElementById('status');
  90.  
  91.     //Open the database corresponding to this character
  92.     openDB();
  93.    
  94.     for (var i = 0; i < entries.length; i++) {
  95.         try {
  96.             done = entries[i].getAttribute('dateCompleted');
  97.             title = entries[i].getAttribute('title');
  98.             icon = entries[i].getAttribute('icon');
  99.             desc = entries[i].getAttribute('desc');
  100.             categoryId = entries[i].getAttribute('categoryId');
  101.            
  102.             if (done.length > 0) {
  103.                 done=done.substr(0,10);
  104.                 //toreturn += '<a id="' + entries[i].getAttribute('id') + '" done="' + done + '"/>';
  105.                 toreturn += "<div class='achievement'><br>ID: " + entries[i].getAttribute('id') + " Completed on:" + done + " Title:" + title +"<br>Description: " + desc +"</div>";
  106.                 insertAchievement();
  107.                 }
  108.         } catch (e) { null; }
  109.     }
  110. /** try {
  111.         if (dom.getElementsByTagName('character').length > 0) {
  112.             var char = dom.getElementsByTagName('character')[0];
  113.                 toreturn += '<c class="' + char.getAttribute('class') +
  114.                 '" faction="' + char.getAttribute('faction') +
  115.                 '" gender="' + char.getAttribute('gender') +
  116.                 '" name="' + char.getAttribute('name') +
  117.                 '" race="' + char.getAttribute('race') +
  118.                 '" realm="' + char.getAttribute('realm') +
  119.                 '"/>';
  120.         }
  121.     } catch (e) { null; }
  122. **/
  123.         if (i == 0) {
  124.             status.innerHTML = 'Error: Armory returned 0 achievements.';
  125.         } else {
  126.             alert("Returning");
  127.            
  128.             status.innerHTML = toreturn;
  129.         }
  130.  
  131. }
  132.  
  133.  
  134. $(document).ready(function(){
  135.     $('#check').click(function () {
  136.         alert("starting file grab");
  137.         try
  138.         {
  139.         var file = Titanium.Filesystem.getFileStream(Titanium.App.appURLToPath('app://temp81.xml'));
  140.         //var file = Titanium.FileSystem.getFile("app://temp81.xml");
  141.         file.open(Titanium.Filesystem.FILESTREAM_MODE_READ);
  142.         var data = file.read();
  143.         }
  144.         catch (e)
  145.         {alert("Error");}
  146.        
  147.         alert(data);
  148.         parse_data(data);
  149.         file.close();
  150.     });
  151.     $('#populate').click(function () {
  152.         getxml.set_charinfo();
  153.     });
  154.     $('#getcharinfo').click(function () {
  155.         getxml.print_charinfo();
  156.     });
  157.     $('#gatherdata').click(function () {
  158.         gatherdata();
  159.     });
  160.    
  161.    
  162. });
  163. </script>
  164. </head>
  165. <body>
  166. <button id="populate">Populate XML</button>
  167. <button id="getcharinfo">Get Char Info</button>
  168. <button id="gatherdata">Gather Data</button>
  169. <button id="check">Parse</button>
  170. <div id="status">Default</div>
  171. <div id="character">Tesandra</div>
  172. <div id="realm">Ghostlands</div>
  173. <div id="server">us</div>
  174. </body>
  175. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top