Giter VIP home page Giter VIP logo

yarsii-ia's Introduction

Yarsii-IA Inteligencia artificial

Ah// Variables utilizadas por Scriptable. // Estos deben estar en la parte superior del archivo. No edites. // icon-color: rojo; icon-glyph: periódico; // Este script muestra artículos de MacStories. El script se puede usar en la aplicación, como widget en su pantalla de inicio o a través de accesos directos. El comportamiento del script variará ligeramente dependiendo de dónde se use. let items = await loadItems() if (config.runsInWidget) { // Dile al widget en la pantalla de inicio que muestre nuestra instancia de ListWidget. deja que widget = espere createWidget(items) Script.setWidget(widget) } else if (config.runsWithSiri) { // Presente una tabla con un subconjunto de las noticias. deja que firstItems = items.slice(0, 5) let table = createTable(firstItems) espera QuickLook.present(tabla) } else { // Presentar la lista completa de noticias. let table = createTable(items) espera QuickLook.present(tabla) } // Llamar a Script.complete() indica a Scriptable que el script ha terminado de ejecutarse. // Esto puede acelerar la ejecución, en particular cuando se ejecuta el script desde Atajos o se usa Siri. Script.complete() función asíncrona createWidget(items) { deja que item = items[0] let authors = item.authors.map(a => { devolver a.name }).join(", ") let imgURL = extractImageURL(item) deja rawDate = item["date_published"] let date = new Date(Date.parse(rawDate)) let dateFormatter = nuevo DateFormatter() dateFormatter.useMediumDateStyle() dateFormatter.useShortTimeStyle() let strDate = dateFormatter.string(date) let gradient = new LinearGradient() gradient.locations = [0, 1] gradient.colors = [ nuevo color ("#b00a0fe6"), nuevo color ("#b00a0fb3") ] let widget = nuevo ListWidget() if (imgURL! = null) { let imgReq = nueva solicitud (imgURL) let img = esperar imgReq.loadImage() widget.backgroundImage = img } widget.backgroundColor = nuevo Color("#b00a0f") widget.backgroundGradiente = degradado // Agregue un espaciador sobre el contenido para centrarlo verticalmente. widget.addSpacer() // Mostrar el titular del artículo. let title = decode(item.title) deja que titleElement = widget.addText(title) titleElement.font = Font.boldSystemFont(16) titleElement.textColor = Color.white() titleElement.minimumScaleFactor = 0,75 // Agregue espaciado debajo del encabezado. widget.addSpacer(8) // Agregue el pie de página con los autores y la fecha. let footerStack = widget.addStack() let authorsElement = footerStack.addText(authors) authorsElement.font = Font.mediumSystemFont(12) authorsElement.textColor = Color.white() authorsElement.textOpacity = 0,9 footerStack.addSpacer() let dateElement = footerStack.addText(strDate) dateElement.font = Font.mediumSystemFont(12) dateElement.textColor = Color.white() dateElement.textOpacidad = 0,9 // Agregue espaciado debajo del contenido para centrarlo verticalmente. widget.addSpacer() // Establezca la URL para abrir al tocar el widget. widget.url = item.url widget de retorno } función createTable(items) { let table = nuevo UITable() para (tema de los temas) { let row = new UITableRow() deja que imageURL = extractImageURL(item) let title = decode(item.title) deja que imageCell = row.addImageAtURL(imageURL) deja que titleCell = row.addText(title) imageCell.widthPeso = 20 titleCell.widthPeso = 80 row.height = 60 row.cellSpacing = 10 row.onSelect = (idx) => { deja que item = items[idx] Safari.open (item.url) } row.dismissOnSelect = false table.addRow(fila) } tabla de devolución } función asíncrona loadItems() { let url = "https://macstories.net/feed/json" let req = new Request(url) let json = esperar req.loadJSON() devolver json.items } función extractImageURL(item) { let regex = /<img src="(.*)" alt="/ let html = item["content_html"] deja que coincida = html.match(regex) if (coincidencias && coincide.length >= 2) { partidos de devolución[1] } else { devolver null } } función decodificación(str) { let regex = /&#(\d+);/g return str.replace(regex, (match, dec) => { devuelve String.fromCharCode(dec) }) }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.