При ошибке обновления:
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=genclo error was
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
var b_gps=option.GPS;
var commaPos=b_gps.indexOf(',');
var coordinatesLat=parseFloat(b_gps.substring(0,commaPos));
var coordinatesLong=parseFloat(b_gps.substring(commaPos+1,b_gps.length));
PlacemarkB=new ymaps.Placemark([coordinatesLat,coordinatesLong],{
https://gist.github.com/chrislkeller/3553967
Удалить непечатаемые символы
$item['content']=preg_replace('/[[:cntrl:]]/','',$item['content']);
Еще вариант
$item['content']=preg_replace('/[\x00-\x1F\x7F]/','',$item['content']);
Оставить перенос строк \r и \n
$item['content']=preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/','',$item['content']);
https://stackoverflow.com/questions/1497885/remove-control-characters-from-php-string
Для всех ссылок которые начинаются с tel:
$("a[href^='tel']").on('click',function(){
//
});
По аналогии для ссылок которые заканчиваются на:
$("a[href$='.jpg'],a[href$='.jpeg'],a[href$='.png'],a[href$='.gif']").on('click',function(){
//
});
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate{
var webView: WKWebView!
lazy var progressbar: UIProgressView = UIProgressView();
deinit {
self.webView.removeObserver(self, forKeyPath: "estimatedProgress")
self.webView.scrollView.removeObserver(self, forKeyPath: "contentOffset")
}
override func viewDidLoad() {
super.viewDidLoad()
let webConfiguration = WKWebViewConfiguration();
webConfiguration.dataDetectorTypes = [.all]
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
webView.translatesAutoresizingMaskIntoConstraints = false
self.webView.navigationDelegate = self
view.addSubview(webView)
self.webView.frame = self.view.frame
self.webView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
webView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
webView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor),
webView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
webView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor)
])
self.webView.addSubview(self.progressbar)
self.setProgressBarPosition()
webView.scrollView.addObserver(self, forKeyPath: "contentOffset", options: .new, context: nil)
self.progressbar.progress = 0.1
self.progressbar.trackTintColor = .white
self.progressbar.progressTintColor = UIColor(red:244/255.0, green: 66/255.0, blue: 8/255.0, alpha: 1)
webView.addObserver(self, forKeyPath: "estimatedProgress",options: .new, context: nil)
let myURL = URL(string:"https://ya.ru")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(reloadWebView(_:)), for: .valueChanged)
webView.scrollView.addSubview(refreshControl)
if #available(iOS 11.0, *){
webView.scrollView.contentInsetAdjustmentBehavior = .never;
}
webView.navigationDelegate = self
webView.allowsBackForwardNavigationGestures = true
}
func setProgressBarPosition(){
self.progressbar.translatesAutoresizingMaskIntoConstraints = false
self.webView.removeConstraints(self.webView.constraints)
self.webView.addConstraints([
self.progressbar.topAnchor.constraint(equalTo: self.webView.topAnchor, constant: self.webView.scrollView.contentOffset.y * -1),
self.progressbar.leadingAnchor.constraint(equalTo: self.webView.leadingAnchor),
self.progressbar.trailingAnchor.constraint(equalTo: self.webView.trailingAnchor)
])
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
switch keyPath{
case "estimatedProgress":
if self.webView.estimatedProgress >= 1.0 {
UIView.animate(withDuration: 0.3, animations: {() in
self.progressbar.alpha = 0.0
}, completion: { finished in
self.progressbar.setProgress(0.0, animated: false)
})
} else{
self.progressbar.isHidden = false
self.progressbar.alpha = 1.0
progressbar.setProgress(Float(self.webView.estimatedProgress), animated: true)
}
case "contentOffset":
self.setProgressBarPosition()
default:
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
}
}
@objc func reloadWebView(_ sender: UIRefreshControl){
webView.reload()
sender.endRefreshing()
}
func share(message: String, link: String){
if let link = NSURL(string: link){
let objectsToShare = [message, link] as [Any]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.present(activityVC, animated: true, completion: nil)
}
}
}
extension ViewController: WKNavigationDelegate{
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void){
guard
let url = navigationAction.request.url else{
decisionHandler(.cancel)
return
}
let string = url.absoluteString
if(string.contains("mailto:")){
UIApplication.shared.open(url, options: [:], completionHandler: nil)
decisionHandler(.cancel)
return
}
if(string.contains("tel:")){
UIApplication.shared.open(url, options: [:], completionHandler: nil)
decisionHandler(.cancel)
return
}
if(string.contains("?share")){
let urlArr = string.components(separatedBy: "?")
let link = urlArr[0]
share(message: "", link: link)
decisionHandler(.cancel)
return
}
decisionHandler(.allow)
}
}
https://josh.blog/2020/02/swiftui-webview-with-a-progress-bar
func share(message: String, link: String){
if let link = NSURL(string: link){
let objectsToShare = [message, link] as [Any]
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.present(activityVC, animated: true, completion: nil)
}
}
share(message: "test", link: "https://ya.ru/")
https://stackoverflow.com/questions/37938722/how-to-implement-share-button-in-swift