Created
September 18, 2015 17:09
-
-
Save gimntut/9f81b8e123ae60c564d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> | |
<script type="text/javascript" src="dpd.js"></script> | |
</head> | |
<body> | |
<h1>Welcome to Deployd!</h1> | |
<p>You've just created a Deployd app. You can add front-end files in the <code>public</code> folder.</p> | |
<p>If you're new to Deployd, have a look at the <a href="http://docs.deployd.com/docs/getting-started/what-is-deployd.html">Getting Started Guide</a> or <a href="http://docs.deployd.com/docs/getting-started/your-first-api.html">Hello World Tutorial</a>.</p> | |
<div id="content"></div> | |
<script> | |
$(test); | |
function test() { | |
$.get('http://www.tzhimmash.ru/').success(addAllToDB); | |
}; | |
function addAllToDB(text, xh, error) { | |
text = text.replace(/img/gi, 'div').replace(/<(title|html|head|body)/gi, '<div id="$1"').replace(/<\/(title|html|head|body)/gi, "</div"); | |
$html = $(text); | |
window.html_title = $html.find('#title').text(); | |
var el = $html.find('a'); | |
el.each(addToDB); | |
} | |
function addToDB(index, element) { | |
var href = $(element).attr('href'); | |
dpd.pages.get({ | |
pageAddress: href | |
}, function(result, error) { | |
if (result.length != 0) { | |
return; | |
} | |
dpd.pages.post({ | |
title: window.html_title, | |
loaded: false, | |
pageAddress: href | |
}, log); | |
}) | |
} | |
function log(result, error) { | |
console.log(result); | |
console.log(error); | |
} | |
function out(a, b, c) { | |
var el = $(a).find('a'); | |
el.each(function(index, e, c) { | |
console.log(); | |
}); | |
} | |
//dpd.pages.del({id:{$ne:0},loaded:false},log) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment