Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
testjquery.py
$(document).ready(function() {
$('a.moreorless').click(function() {
var $firstPara = $('p:eq(1)');
$firstPara.slideToggle('slow');
var $link = $(this);
if ( $link.text() == "read more" ) {
$link.text('read less');
} else {
$link.text('read more');
}
return false;
});
});
<!DOCTYPE html>
<html>
<head>
<title>Jquery Test Page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="moreorless.js"></script>
</head>
<body>
<font size=20>
<p> Thank you for downloading Pythonista! </p>
<p>You now have everything you need to build and run Python scripts directly on your iPhone or iPad. </p>
<a href="#" class="moreorless">read less</a>
</font>
</body>
</html>
import ui
import os
def readmore(sender):
status = v['webview1'].eval_js(''' (function(){
var $firstPara = $('p:eq(1)');
$firstPara.slideToggle('slow');
var $link = $('a');
if ( $link.text() == "read more" ) {
$link.text('read less');
return 'read less';
} else {
$link.text('read more');
return 'read more'
}
})()''')
if sender.title == 'readmore':
sender.title = 'readless'
else:
sender.title = 'readmore'
with open('testjquery.html') as fp:
html_text = fp.read()
file_path = os.path.abspath('testjquery.html')
v = ui.View(frame=(0,0,600,600))
w = ui.WebView(frame=(0,0,600,400), name='webview1')
w.load_url('File://'+file_path)
v.add_subview(w)
v.add_subview(ui.Button(frame=(100, 500,300,100), title='readless', name='button1',
action=readmore))
v['button1'].width = 300
v.present('sheet')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.