Created
October 4, 2017 15:32
-
-
Save anonymous/619e923059d7643841e6f889655d8bf1 to your computer and use it in GitHub Desktop.
testjquery.py
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
$(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; | |
}); | |
}); |
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> | |
<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> |
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
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